//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReadWriteSingleEntry() internal virtual void ShouldReadWriteSingleEntry() { // given MutableLong writeKey = _layout.key(Rnd.nextLong()); MutableLong writeValue = _layout.value(Rnd.nextLong()); int offset = _pageCursor.Offset; BlockEntry.Write(_pageCursor, _layout, writeKey, writeValue); // when MutableLong readKey = _layout.newKey(); MutableLong readValue = _layout.newValue(); _pageCursor.Offset = offset; BlockEntry.Read(_pageCursor, _layout, readKey, readValue); // then assertEquals(0, _layout.Compare(writeKey, readKey)); assertEquals(0, _layout.Compare(writeValue, readValue)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReadWriteMultipleEntries() internal virtual void ShouldReadWriteMultipleEntries() { IList <BlockEntry <MutableLong, MutableLong> > expectedEntries = new List <BlockEntry <MutableLong, MutableLong> >(); int nbrOfEntries = 10; int offset = _pageCursor.Offset; for (int i = 0; i < nbrOfEntries; i++) { BlockEntry <MutableLong, MutableLong> entry = new BlockEntry <MutableLong, MutableLong>(_layout.key(Rnd.nextLong()), _layout.value(Rnd.nextLong())); BlockEntry.Write(_pageCursor, _layout, entry); expectedEntries.Add(entry); } _pageCursor.Offset = offset; foreach (BlockEntry <MutableLong, MutableLong> expectedEntry in expectedEntries) { BlockEntry <MutableLong, MutableLong> actualEntry = BlockEntry.Read(_pageCursor, _layout); AssertBlockEquals(expectedEntry, actualEntry); } }
public static void Write <KEY, VALUE>(PageCursor cursor, Layout <KEY, VALUE> layout, UpdateMode updateMode, KEY key1, KEY key2, VALUE value) { switch (updateMode.innerEnumValue) { case UpdateMode.InnerEnum.ADDED: BlockEntry.Write(cursor, layout, key1, value); break; case UpdateMode.InnerEnum.REMOVED: BlockEntry.Write(cursor, layout, key1); break; case UpdateMode.InnerEnum.CHANGED: BlockEntry.Write(cursor, layout, key1); BlockEntry.Write(cursor, layout, key2, value); break; default: throw new System.ArgumentException("Unknown update mode " + updateMode); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static <KEY, VALUE> long writeEntries(org.neo4j.io.fs.StoreChannel targetChannel, ByteBuffer byteBuffer, org.neo4j.index.internal.gbptree.Layout<KEY,VALUE> layout, BlockEntryCursor<KEY,VALUE> blockEntryCursor, Cancellation cancellation, System.Action<int> entryCountReporter) throws java.io.IOException private static long WriteEntries <KEY, VALUE>(StoreChannel targetChannel, ByteBuffer byteBuffer, Layout <KEY, VALUE> layout, BlockEntryCursor <KEY, VALUE> blockEntryCursor, Cancellation cancellation, System.Action <int> entryCountReporter) { // Loop over block entries long actualDataSize = BlockHeaderSize; ByteArrayPageCursor pageCursor = new ByteArrayPageCursor(byteBuffer); int entryCountToReport = 0; while (blockEntryCursor.Next()) { KEY key = blockEntryCursor.Key(); VALUE value = blockEntryCursor.Value(); int entrySize = BlockEntry.EntrySize(layout, key, value); actualDataSize += entrySize; entryCountToReport++; if (byteBuffer.remaining() < entrySize) { // First check if this merge have been cancelled, if so just break here, it's fine. if (cancellation.Cancelled()) { break; } // flush and reset + DON'T PAD!!! byteBuffer.flip(); targetChannel.WriteAll(byteBuffer); byteBuffer.clear(); entryCountReporter(entryCountToReport); entryCountToReport = 0; } BlockEntry.Write(pageCursor, layout, key, value); } if (entryCountToReport > 0) { entryCountReporter(entryCountToReport); } return(actualDataSize); }