示例#1
0
//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);
        }
示例#2
0
 private void InitializeInstanceFields()
 {
     _pageCursor = ByteArrayPageCursor.wrap(_data);
 }