//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void withCursor(java.io.File storeFile, boolean create, System.Action<org.neo4j.io.pagecache.PageCursor> cursorConsumer) throws java.io.IOException private void WithCursor(File storeFile, bool create, System.Action <PageCursor> cursorConsumer) { OpenOption[] openOptions = create ? new OpenOption[] { StandardOpenOption.WRITE, StandardOpenOption.CREATE } : new OpenOption[] { StandardOpenOption.WRITE }; using (PageCache pageCache = PageCacheRule.getPageCache(GlobalFs.get()), PagedFile pagedFile = pageCache.Map(storeFile, pageCache.PageSize(), openOptions), PageCursor cursor = pagedFile.Io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PfSharedWriteLock)) { cursor.Next(); cursorConsumer(cursor); } }
/// <summary> /// Throws <seealso cref="FormatViolationException"/> if format has changed. /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("EmptyTryBlock") @Override protected void verifyFormat(java.io.File storeFile) throws java.io.IOException, FormatViolationException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: protected internal override void VerifyFormat( File storeFile ) { PageCache pageCache = _pageCacheRule.getPageCache( GlobalFs.get() ); try { using ( GBPTree<MutableLong, MutableLong> ignored = ( new GBPTreeBuilder<MutableLong, MutableLong>( pageCache, storeFile, Layout ) ).build() ) { } } catch ( MetadataMismatchException e ) { throw new FormatViolationException( this, e ); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected void createStoreFile(java.io.File storeFile) throws java.io.IOException protected internal override void CreateStoreFile( File storeFile ) { IList<long> initialKeys = initialKeys(); PageCache pageCache = _pageCacheRule.getPageCache( GlobalFs.get() ); using ( GBPTree<MutableLong, MutableLong> tree = ( new GBPTreeBuilder<MutableLong, MutableLong>( pageCache, storeFile, Layout ) ).build() ) { using ( Writer<MutableLong, MutableLong> writer = tree.Writer() ) { foreach ( long? key in initialKeys ) { Put( writer, key.Value ); } } tree.Checkpoint( Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited ); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void verifyContent(java.io.File storeFile) throws java.io.IOException public override void VerifyContent( File storeFile ) { PageCache pageCache = _pageCacheRule.getPageCache( GlobalFs.get() ); using ( GBPTree<MutableLong, MutableLong> tree = ( new GBPTreeBuilder<MutableLong, MutableLong>( pageCache, storeFile, Layout ) ).build() ) { { // WHEN reading from the tree // THEN initial keys should be there tree.ConsistencyCheck(); using ( RawCursor<Hit<MutableLong, MutableLong>, IOException> cursor = tree.Seek( Layout.key( 0 ), Layout.key( long.MaxValue ) ) ) { foreach ( long? expectedKey in _initialKeys ) { AssertHit( cursor, expectedKey ); } assertFalse( cursor.Next() ); } } { // WHEN writing more to the tree // THEN we should not see any format conflicts using ( Writer<MutableLong, MutableLong> writer = tree.Writer() ) { while ( _keysToAdd.Count > 0 ) { int next = _random.Next( _keysToAdd.Count ); Put( writer, _keysToAdd[next] ); _keysToAdd.RemoveAt( next ); } } } { // WHEN reading from the tree again // THEN all keys including newly added should be there tree.ConsistencyCheck(); using ( RawCursor<Hit<MutableLong, MutableLong>, IOException> cursor = tree.Seek( Layout.key( 0 ), Layout.key( 2 * INITIAL_KEY_COUNT ) ) ) { foreach ( long? expectedKey in _allKeys ) { AssertHit( cursor, expectedKey ); } assertFalse( cursor.Next() ); } } { // WHEN randomly removing half of tree content // THEN we should not see any format conflicts using ( Writer<MutableLong, MutableLong> writer = tree.Writer() ) { int size = _allKeys.Count; while ( _allKeys.Count > size / 2 ) { int next = _random.Next( _allKeys.Count ); MutableLong key = Layout.key( _allKeys[next] ); writer.Remove( key ); _allKeys.RemoveAt( next ); } } } { // WHEN reading from the tree after remove // THEN we should see everything that is left in the tree tree.ConsistencyCheck(); using ( RawCursor<Hit<MutableLong, MutableLong>, IOException> cursor = tree.Seek( Layout.key( 0 ), Layout.key( 2 * INITIAL_KEY_COUNT ) ) ) { foreach ( long? expectedKey in _allKeys ) { AssertHit( cursor, expectedKey ); } assertFalse( cursor.Next() ); } } } }