示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void releaseId(long stableGeneration, long unstableGeneration, long id) throws java.io.IOException
        public override void ReleaseId(long stableGeneration, long unstableGeneration, long id)
        {
            using (PageCursor cursor = _pagedFile.io(_writePageId, Org.Neo4j.Io.pagecache.PagedFile_Fields.PfSharedWriteLock))
            {
                PageCursorUtil.GoTo(cursor, "free-list write page", _writePageId);
                _freelistNode.write(cursor, unstableGeneration, id, _writePos);
                _writePos++;
            }

            if (_writePos >= _freelistNode.maxEntries())
            {
                // Current free-list write page is full, allocate a new one.
                long nextFreelistPage = AcquireNewId(stableGeneration, unstableGeneration, false);
                using (PageCursor cursor = _pagedFile.io(_writePageId, Org.Neo4j.Io.pagecache.PagedFile_Fields.PfSharedWriteLock))
                {
                    PageCursorUtil.GoTo(cursor, "free-list write page", _writePageId);
                    FreelistNode.Initialize(cursor);
                    // Link previous --> new writer page
                    FreelistNode.SetNext(cursor, nextFreelistPage);
                }
                _writePageId = nextFreelistPage;
                _writePos    = 0;
                _monitor.acquiredFreelistPageId(nextFreelistPage);
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReadAndWriteFreeListEntries()
        internal virtual void ShouldReadAndWriteFreeListEntries()
        {
            // GIVEN
            long generationA = 34;
            long pointerA    = 56;
            long generationB = 78;
            long pointerB    = 90;

            // WHEN
            _freelist.write(_cursor, generationA, pointerA, 0);
            _freelist.write(_cursor, generationB, pointerB, 1);
            long readPointerA = _freelist.read(_cursor, generationA + 1, 0);
            long readPointerB = _freelist.read(_cursor, generationB + 1, 1);

            // THEN
            assertEquals(pointerA, readPointerA);
            assertEquals(pointerB, readPointerB);
        }