예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void pageModificationTracksHighestModifierTransactionId() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void PageModificationTracksHighestModifierTransactionId()
        {
            TestVersionContext     cursorContext          = new TestVersionContext(() => 0);
            VersionContextSupplier versionContextSupplier = new ConfiguredVersionContextSupplier(cursorContext);

            using (MuninnPageCache pageCache = createPageCache(fs, 2, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, versionContextSupplier), PagedFile pagedFile = map(pageCache, file("a"), 8))
            {
                cursorContext.InitWrite(1);
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                {
                    assertTrue(cursor.Next());
                    cursor.PutLong(1);
                }
                cursorContext.InitWrite(12);
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                {
                    assertTrue(cursor.Next());
                    cursor.PutLong(2);
                }
                cursorContext.InitWrite(7);
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                {
                    assertTrue(cursor.Next());
                    cursor.PutLong(3);
                }

                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_READ_LOCK))
                {
                    assertTrue(cursor.Next());
                    MuninnPageCursor pageCursor = ( MuninnPageCursor )cursor;
                    assertEquals(12, pageCursor.PagedFile.getLastModifiedTxId(pageCursor.PinnedPageRef));
                    assertEquals(3, cursor.Long);
                }
            }
        }
예제 #2
0
 private void ClearCursorError(MuninnPageCursor cursor)
 {
     while (cursor != null)
     {
         cursor._cursorException = null;
         cursor = cursor.LinkedCursor;
     }
 }
예제 #3
0
 private void CloseLinks(MuninnPageCursor cursor)
 {
     while (cursor != null && cursor.PagedFile != null)
     {
         cursor.UnpinCurrentPage();
         // We null out the pagedFile field to allow it and its (potentially big) translation table to be garbage
         // collected when the file is unmapped, since the cursors can stick around in thread local caches, etc.
         cursor.PagedFile = null;
         cursor           = cursor.LinkedCursor;
     }
 }
예제 #4
0
        public override bool CheckAndClearBoundsFlag()
        {
            MuninnPageCursor cursor = this;
            bool             result = false;

            do
            {
                result |= cursor._outOfBounds;
                cursor._outOfBounds = false;
                cursor = cursor.LinkedCursor;
            } while (cursor != null);
            return(result);
        }
예제 #5
0
        public override int CopyTo(int sourceOffset, PageCursor targetCursor, int targetOffset, int lengthInBytes)
        {
            int sourcePageSize = CurrentPageSize;
            int targetPageSize = targetCursor.CurrentPageSize;

            if (targetCursor.GetType() != typeof(MuninnWritePageCursor))
            {
                throw new System.ArgumentException("Target cursor must be writable");
            }
            if (sourceOffset >= 0 & targetOffset >= 0 & sourceOffset < sourcePageSize & targetOffset < targetPageSize & lengthInBytes >= 0)
            {
                MuninnPageCursor cursor = ( MuninnPageCursor )targetCursor;
                int remainingSource     = sourcePageSize - sourceOffset;
                int remainingTarget     = targetPageSize - targetOffset;
                int bytes = Math.Min(lengthInBytes, Math.Min(remainingSource, remainingTarget));
                UnsafeUtil.copyMemory(_pointer + sourceOffset, cursor._pointer + targetOffset, bytes);
                return(bytes);
            }
            _outOfBounds = true;
            return(0);
        }
예제 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void markCursorContextDirtyWhenRepositionCursorOnItsCurrentPage() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void MarkCursorContextDirtyWhenRepositionCursorOnItsCurrentPage()
        {
            TestVersionContext     cursorContext          = new TestVersionContext(() => 3);
            VersionContextSupplier versionContextSupplier = new ConfiguredVersionContextSupplier(cursorContext);

            using (MuninnPageCache pageCache = createPageCache(fs, 2, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, versionContextSupplier), PagedFile pagedFile = map(pageCache, file("a"), 8))
            {
                cursorContext.InitRead();
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                {
                    assertTrue(cursor.Next(0));
                    assertFalse(cursorContext.Dirty);

                    MuninnPageCursor pageCursor = ( MuninnPageCursor )cursor;
                    pageCursor.PagedFile.setLastModifiedTxId((( MuninnPageCursor )cursor).PinnedPageRef, 17);

                    assertTrue(cursor.Next(0));
                    assertTrue(cursorContext.Dirty);
                }
            }
        }
예제 #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void checkAndClearCursorException() throws org.neo4j.io.pagecache.CursorException
        public override void CheckAndClearCursorException()
        {
            MuninnPageCursor cursor = this;

            do
            {
                object error = cursor._cursorException;
                if (error != null)
                {
                    ClearCursorError(cursor);
                    if (_usePreciseCursorErrorStackTraces)
                    {
                        throw ( CursorExceptionWithPreciseStackTrace )error;
                    }
                    else
                    {
                        throw new CursorException(( string )error);
                    }
                }
                cursor = cursor.LinkedCursor;
            } while (cursor != null);
        }
예제 #8
0
        public override PageCursor OpenLinkedCursor(long pageId)
        {
            CloseLinkedCursorIfAny();
            MuninnPagedFile pf = PagedFile;

            if (pf == null)
            {
                // This cursor has been closed
                throw new System.InvalidOperationException("Cannot open linked cursor on closed page cursor");
            }
            if (LinkedCursor != null)
            {
                LinkedCursor.initialise(pf, pageId, PfFlags);
                LinkedCursor.rewind();
            }
            else
            {
                LinkedCursor = ( MuninnPageCursor )pf.Io(pageId, PfFlags);
                LinkedCursor.isLinkedCursor = true;
            }
            return(LinkedCursor);
        }
예제 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void pageModificationTrackingNoticeWriteFromAnotherThread() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void PageModificationTrackingNoticeWriteFromAnotherThread()
        {
            TestVersionContext     cursorContext          = new TestVersionContext(() => 0);
            VersionContextSupplier versionContextSupplier = new ConfiguredVersionContextSupplier(cursorContext);

            using (MuninnPageCache pageCache = createPageCache(fs, 2, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, versionContextSupplier), PagedFile pagedFile = map(pageCache, file("a"), 8))
            {
                cursorContext.InitWrite(7);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?> future = executor.submit(() ->
                Future <object> future = executor.submit(() =>
                {
                    try
                    {
                        using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                        {
                            assertTrue(cursor.Next());
                            cursor.PutLong(1);
                        }
                    }
                    catch (IOException e)
                    {
                        throw new Exception(e);
                    }
                });
                future.get();

                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_READ_LOCK))
                {
                    assertTrue(cursor.Next());
                    MuninnPageCursor pageCursor = ( MuninnPageCursor )cursor;
                    assertEquals(7, pageCursor.PagedFile.getLastModifiedTxId(pageCursor.PinnedPageRef));
                    assertEquals(1, cursor.Long);
                }
            }
        }
예제 #10
0
 internal CursorPageAccessor(MuninnPageCursor @delegate) : base(-1, PageCursorTracer.NULL, EmptyVersionContextSupplier.EMPTY)
 {
     this.Delegate = @delegate;
 }