//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldSetAndGetNext() internal virtual void ShouldSetAndGetNext() { // GIVEN long nextId = 12345; // WHEN FreelistNode.SetNext(_cursor, nextId); long readNextId = FreelistNode.Next(_cursor); // THEN assertEquals(nextId, readNextId); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private long acquireNewIdFromFreelistOrEnd(long stableGeneration, long unstableGeneration, boolean allowTakeLastFromPage) throws java.io.IOException private long AcquireNewIdFromFreelistOrEnd(long stableGeneration, long unstableGeneration, bool allowTakeLastFromPage) { if ((_readPageId != _writePageId || _readPos < _writePos) && (allowTakeLastFromPage || _readPos < _freelistNode.maxEntries() - 1)) { // It looks like reader isn't even caught up to the writer page-wise, // or the read pos is < write pos so check if we can grab the next id (generation could still mismatch). using (PageCursor cursor = _pagedFile.io(_readPageId, Org.Neo4j.Io.pagecache.PagedFile_Fields.PF_SHARED_READ_LOCK)) { if (!cursor.Next()) { throw new IOException("Couldn't go to free-list read page " + _readPageId); } long resultPageId; do { resultPageId = _freelistNode.read(cursor, stableGeneration, _readPos); } while (cursor.ShouldRetry()); if (resultPageId != FreelistNode.NoPageId) { // FreelistNode compares generation and so this means that we have an available // id in the free list which we can acquire from a stable generation. Increment readPos _readPos++; if (_readPos >= _freelistNode.maxEntries()) { // The current reader page is exhausted, go to the next free-list page. _readPos = 0; do { _readPageId = FreelistNode.Next(cursor); } while (cursor.ShouldRetry()); // Put the exhausted free-list page id itself on the free-list long exhaustedFreelistPageId = cursor.CurrentPageId; ReleaseId(stableGeneration, unstableGeneration, exhaustedFreelistPageId); _monitor.releasedFreelistPageId(exhaustedFreelistPageId); } return(resultPageId); } } } // Fall-back to acquiring at the end of the file return(NextLastId()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void visitFreelist(IdProvider_IdProviderVisitor visitor) throws java.io.IOException public override void VisitFreelist(IdProvider_IdProviderVisitor visitor) { if (_readPageId == FreelistNode.NoPageId) { return; } using (PageCursor cursor = _pagedFile.io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PF_SHARED_READ_LOCK)) { GenerationKeeper generation = new GenerationKeeper(); long prevPage; long pageId = _readPageId; int pos = _readPos; do { PageCursorUtil.GoTo(cursor, "free-list", pageId); visitor.BeginFreelistPage(pageId); int targetPos = pageId == _writePageId ? _writePos : _freelistNode.maxEntries(); while (pos < targetPos) { // Read next un-acquired id long unacquiredId; do { unacquiredId = _freelistNode.read(cursor, long.MaxValue, pos, generation); } while (cursor.ShouldRetry()); visitor.FreelistEntry(unacquiredId, generation.Generation, pos); pos++; } visitor.EndFreelistPage(pageId); prevPage = pageId; pos = 0; do { pageId = FreelistNode.Next(cursor); } while (cursor.ShouldRetry()); } while (prevPage != _writePageId); } }