//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.util.List<java.util.List<BlockEntry<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong>>> addACoupleOfBlocksOfEntries(TrackingMonitor monitor, BlockStorage<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong> storage, int numberOfBlocks) throws java.io.IOException private IList <IList <BlockEntry <MutableLong, MutableLong> > > AddACoupleOfBlocksOfEntries(TrackingMonitor monitor, BlockStorage <MutableLong, MutableLong> storage, int numberOfBlocks) { Debug.Assert(numberOfBlocks != 1); MutableLongSet uniqueKeys = LongSets.mutable.empty(); IList <IList <BlockEntry <MutableLong, MutableLong> > > expected = new List <IList <BlockEntry <MutableLong, MutableLong> > >(); IList <BlockEntry <MutableLong, MutableLong> > currentExpected = new List <BlockEntry <MutableLong, MutableLong> >(); long currentBlock = 0; while (monitor.BlockFlushedCallCount < numberOfBlocks - 1) { MutableLong key = UniqueKey(uniqueKeys); MutableLong value = new MutableLong(Random.nextLong(10_000_000)); storage.Add(key, value); if (monitor.BlockFlushedCallCount > currentBlock) { Sort(currentExpected); expected.Add(currentExpected); currentExpected = new List <BlockEntry <MutableLong, MutableLong> >(); currentBlock = monitor.BlockFlushedCallCount; } currentExpected.Add(new BlockEntry <>(key, value)); } storage.DoneAdding(); if (currentExpected.Count > 0) { expected.Add(currentExpected); } return(expected); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNoticeCancelRequest() throws java.io.IOException, java.util.concurrent.ExecutionException, InterruptedException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldNoticeCancelRequest() { // given Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control(); TrackingMonitor monitor = new TrackingMonitorAnonymousInnerClass(this, barrier); int blocks = 10; int mergeFactor = 2; MutableLongSet uniqueKeys = new LongHashSet(); AtomicBoolean cancelled = new AtomicBoolean(); using (BlockStorage <MutableLong, MutableLong> storage = new BlockStorage <MutableLong, MutableLong>(_layout, heapBufferFactory(100), _fileSystem, _file, monitor), OtherThreadExecutor <Void> t2 = new OtherThreadExecutor <Void>("T2", null)) { while (monitor.BlockFlushedCallCount < blocks) { storage.Add(UniqueKey(uniqueKeys), new MutableLong()); } storage.DoneAdding(); // when starting to merge Future <object> merge = t2.ExecuteDontWait(command(() => storage.merge(mergeFactor, cancelled.get))); barrier.AwaitUninterruptibly(); // one merge iteration have now been done, set the cancellation flag cancelled.set(true); barrier.Release(); merge.get(); } // then there should not be any more merge iterations done, i.e. merge was cancelled assertEquals(1, monitor.MergeIterationCallCount); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldSortAndAddMultipleEntriesInLastBlock() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldSortAndAddMultipleEntriesInLastBlock() { // given TrackingMonitor monitor = new TrackingMonitor(); int blockSize = 1_000; IList <BlockEntry <MutableLong, MutableLong> > expected = new List <BlockEntry <MutableLong, MutableLong> >(); using (BlockStorage <MutableLong, MutableLong> storage = new BlockStorage <MutableLong, MutableLong>(_layout, heapBufferFactory(blockSize), _fileSystem, _file, monitor)) { // when for (int i = 0; i < 10; i++) { long keyNumber = Random.nextLong(10_000_000); MutableLong key = new MutableLong(keyNumber); MutableLong value = new MutableLong(i); storage.Add(key, value); expected.Add(new BlockEntry <>(key, value)); } storage.DoneAdding(); // then Sort(expected); AssertContents(_layout, storage, singletonList(expected)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.util.List<BlockEntry<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong>> addEntries(BlockStorage<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong> storage, int numberOfEntries) throws java.io.IOException private IList <BlockEntry <MutableLong, MutableLong> > AddEntries(BlockStorage <MutableLong, MutableLong> storage, int numberOfEntries) { MutableLongSet uniqueKeys = LongSets.mutable.empty(); IList <BlockEntry <MutableLong, MutableLong> > entries = new List <BlockEntry <MutableLong, MutableLong> >(); for (int i = 0; i < numberOfEntries; i++) { MutableLong key = UniqueKey(uniqueKeys); MutableLong value = new MutableLong(Random.nextLong(10_000_000)); storage.Add(key, value); entries.Add(new BlockEntry <>(key, value)); } Sort(entries); return(entries); }
private void StoreUpdate(long entityId, Value[] values, BlockStorage <KEY, VALUE> blockStorage) { try { KEY key = layout.newKey(); VALUE value = layout.newValue(); initializeKeyFromUpdate(key, entityId, values); value.From(values); blockStorage.Add(key, value); } catch (IOException e) { throw new UncheckedIOException(e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldAddSingleEntryInLastBlock() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldAddSingleEntryInLastBlock() { // given TrackingMonitor monitor = new TrackingMonitor(); int blockSize = 100; MutableLong key = new MutableLong(10); MutableLong value = new MutableLong(20); using (BlockStorage <MutableLong, MutableLong> storage = new BlockStorage <MutableLong, MutableLong>(_layout, heapBufferFactory(blockSize), _fileSystem, _file, monitor)) { // when storage.Add(key, value); storage.DoneAdding(); // then assertEquals(1, monitor.BlockFlushedCallCount); assertEquals(1, monitor.LastKeyCount); assertEquals(BlockStorage.BlockHeaderSize + monitor.TotalEntrySize, monitor.LastNumberOfBytes); assertEquals(blockSize, monitor.LastPositionAfterFlush); assertThat(monitor.LastNumberOfBytes, lessThan(blockSize)); AssertContents(_layout, storage, singletonList(singletonList(new BlockEntry <>(key, value)))); } }