Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void visitMeta(org.neo4j.io.pagecache.PageCursor cursor, GBPTreeVisitor visitor) throws java.io.IOException
        private static void VisitMeta(PageCursor cursor, GBPTreeVisitor visitor)
        {
            PageCursorUtil.GoTo(cursor, "meta page", IdSpace.META_PAGE_ID);
            Meta meta = Meta.Read(cursor, null);

            visitor.meta(meta);
        }
Пример #2
0
        /// <summary>
        /// Let the passed in {@code cursor} point to the root or sub-tree (internal node) of what to visit.
        /// </summary>
        /// <param name="cursor"> <seealso cref="PageCursor"/> placed at root of tree or sub-tree. </param>
        /// <param name="writeCursor"> Currently active <seealso cref="PageCursor write cursor"/> in tree. </param>
        /// <param name="visitor"> <seealso cref="GBPTreeVisitor"/> that should visit the tree. </param>
        /// <exception cref="IOException"> on page cache access error. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void visitTree(org.neo4j.io.pagecache.PageCursor cursor, org.neo4j.io.pagecache.PageCursor writeCursor, GBPTreeVisitor<KEY,VALUE> visitor) throws java.io.IOException
        internal virtual void VisitTree(PageCursor cursor, PageCursor writeCursor, GBPTreeVisitor <KEY, VALUE> visitor)
        {
            // TreeState
            long currentPage = cursor.CurrentPageId;
            Pair <TreeState, TreeState> statePair = TreeStatePair.ReadStatePages(cursor, IdSpace.STATE_PAGE_A, IdSpace.STATE_PAGE_B);

            visitor.TreeState(statePair);
            TreeNode.GoTo(cursor, "back to tree node from reading state", currentPage);

            AssertOnTreeNode(Select(cursor, writeCursor));

            // Traverse the tree
            int level = 0;

            do
            {
                // One level at the time
                visitor.BeginLevel(level);
                long leftmostSibling = cursor.CurrentPageId;

                // Go right through all siblings
                VisitLevel(cursor, writeCursor, visitor);

                visitor.EndLevel(level);
                level++;

                // Then go back to the left-most node on this level
                TreeNode.GoTo(cursor, "back", leftmostSibling);
            } while (GoToLeftmostChild(cursor, writeCursor));
            // And continue down to next level if this level was an internal level
        }
Пример #3
0
        /// <summary>
        /// Visit the header, that is tree state and meta information, about the tree present in the given {@code file}.
        /// </summary>
        /// <param name="pageCache"> <seealso cref="PageCache"/> able to map tree contained in {@code file}. </param>
        /// <param name="file"> <seealso cref="File"/> containing the tree to print header for. </param>
        /// <param name="visitor"> <seealso cref="GBPTreeVisitor"/> that shall visit header. </param>
        /// <exception cref="IOException"> on I/O error. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void visitHeader(org.neo4j.io.pagecache.PageCache pageCache, java.io.File file, GBPTreeVisitor visitor) throws java.io.IOException
        public static void VisitHeader(PageCache pageCache, File file, GBPTreeVisitor visitor)
        {
            using (PagedFile pagedFile = pageCache.Map(file, pageCache.PageSize(), StandardOpenOption.READ))
            {
                using (PageCursor cursor = pagedFile.Io(IdSpace.STATE_PAGE_A, Org.Neo4j.Io.pagecache.PagedFile_Fields.PF_SHARED_READ_LOCK))
                {
                    VisitMeta(cursor, visitor);
                    VisitTreeState(cursor, visitor);
                }
            }
        }
Пример #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void visitLevel(org.neo4j.io.pagecache.PageCursor readCursor, org.neo4j.io.pagecache.PageCursor writeCursor, GBPTreeVisitor<KEY,VALUE> visitor) throws java.io.IOException
        private void VisitLevel(PageCursor readCursor, PageCursor writeCursor, GBPTreeVisitor <KEY, VALUE> visitor)
        {
            long rightSibling = -1;

            do
            {
                PageCursor cursor = Select(readCursor, writeCursor);
                VisitTreeNode(cursor, visitor);

                do
                {
                    rightSibling = TreeNode.RightSibling(cursor, _stableGeneration, _unstableGeneration);
                } while (cursor.ShouldRetry());

                if (TreeNode.IsNode(rightSibling))
                {
                    TreeNode.GoTo(readCursor, "right sibling", rightSibling);
                }
            } while (TreeNode.IsNode(rightSibling));
        }
Пример #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static void visitTreeState(org.neo4j.io.pagecache.PageCursor cursor, GBPTreeVisitor visitor) throws java.io.IOException
        internal static void VisitTreeState(PageCursor cursor, GBPTreeVisitor visitor)
        {
            Pair <TreeState, TreeState> statePair = TreeStatePair.ReadStatePages(cursor, IdSpace.STATE_PAGE_A, IdSpace.STATE_PAGE_B);

            visitor.treeState(statePair);
        }
Пример #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void visitTreeNode(org.neo4j.io.pagecache.PageCursor cursor, GBPTreeVisitor<KEY,VALUE> visitor) throws java.io.IOException
        internal virtual void VisitTreeNode(PageCursor cursor, GBPTreeVisitor <KEY, VALUE> visitor)
        {
            //[TYPE][GEN][KEYCOUNT] ([RIGHTSIBLING][LEFTSIBLING][SUCCESSOR]))
            bool isLeaf;
            int  keyCount;
            long generation = -1;

            do
            {
                isLeaf   = TreeNode.IsLeaf(cursor);
                keyCount = TreeNode.KeyCount(cursor);
                if (!_node.reasonableKeyCount(keyCount))
                {
                    cursor.CursorException = "Unexpected keyCount " + keyCount;
                }
                generation = TreeNode.Generation(cursor);
            } while (cursor.ShouldRetry());
            visitor.BeginNode(cursor.CurrentPageId, isLeaf, generation, keyCount);

            KEY   key   = _layout.newKey();
            VALUE value = _layout.newValue();

            for (int i = 0; i < keyCount; i++)
            {
                long child = -1;
                do
                {
                    _node.keyAt(cursor, key, i, isLeaf ? LEAF : INTERNAL);
                    if (isLeaf)
                    {
                        _node.valueAt(cursor, value, i);
                    }
                    else
                    {
                        child = pointer(_node.childAt(cursor, i, _stableGeneration, _unstableGeneration));
                    }
                } while (cursor.ShouldRetry());

                visitor.Position(i);
                if (isLeaf)
                {
                    visitor.Key(key, isLeaf);
                    visitor.Value(value);
                }
                else
                {
                    visitor.Child(child);
                    visitor.Key(key, isLeaf);
                }
            }
            if (!isLeaf)
            {
                long child;
                do
                {
                    child = pointer(_node.childAt(cursor, keyCount, _stableGeneration, _unstableGeneration));
                } while (cursor.ShouldRetry());
                visitor.Position(keyCount);
                visitor.Child(child);
            }
            visitor.EndNode(cursor.CurrentPageId);
        }