//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void add(org.neo4j.kernel.api.index.IndexEntryUpdate<?> update, org.neo4j.io.pagecache.PageCursor pageCursor) throws java.io.IOException
        public override void Add <T1>(IndexEntryUpdate <T1> update, PageCursor pageCursor)
        {
            int        entrySize  = TYPE_SIZE;
            UpdateMode updateMode = update.UpdateMode();

            switch (updateMode.innerEnumValue)
            {
            case UpdateMode.InnerEnum.ADDED:
                initializeKeyAndValueFromUpdate(_key1, _value, update.EntityId, update.Values());
                entrySize += BlockEntry.EntrySize(_layout, _key1, _value);
                break;

            case UpdateMode.InnerEnum.REMOVED:
                initializeKeyFromUpdate(_key1, update.EntityId, update.Values());
                entrySize += BlockEntry.KeySize(_layout, _key1);
                break;

            case UpdateMode.InnerEnum.CHANGED:
                initializeKeyFromUpdate(_key1, update.EntityId, update.BeforeValues());
                initializeKeyAndValueFromUpdate(_key2, _value, update.EntityId, update.Values());
                entrySize += BlockEntry.KeySize(_layout, _key1) + BlockEntry.EntrySize(_layout, _key2, _value);
                break;

            default:
                throw new System.ArgumentException("Unknown update mode " + updateMode);
            }

            prepareWrite(entrySize);

            pageCursor.PutByte(( sbyte )updateMode.ordinal());
            IndexUpdateEntry.Write(pageCursor, _layout, updateMode, _key1, _key2, _value);
        }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void add(KEY key, VALUE value) throws java.io.IOException
        public virtual void Add(KEY key, VALUE value)
        {
            Preconditions.checkState(!_doneAdding, "Cannot add more after done adding");

            int entrySize = BlockEntry.EntrySize(_layout, key, value);

            if (_currentBufferSize + entrySize > _blockSize)
            {
                // append buffer to file and clear buffers
                FlushAndResetBuffer();
                _numberOfBlocksInCurrentFile++;
            }

            _bufferedEntries.add(new BlockEntry <>(key, value));
            _currentBufferSize += entrySize;
            _monitor.entryAdded(entrySize);
        }
Exemple #3
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);
        }