コード例 #1
0
ファイル: IndexUpdateStorage.cs プロジェクト: Neo4Net/Neo4Net
//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);
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static <KEY extends NativeIndexKey<KEY>, VALUE extends NativeIndexValue> void processAdd(KEY treeKey, VALUE treeValue, org.neo4j.kernel.api.index.IndexEntryUpdate<?> update, org.neo4j.index.internal.gbptree.Writer<KEY,VALUE> writer, ConflictDetectingValueMerger<KEY,VALUE,org.neo4j.values.storable.Value[]> conflictDetectingValueMerger) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        private static void ProcessAdd <KEY, VALUE, T1>(KEY treeKey, VALUE treeValue, IndexEntryUpdate <T1> update, Writer <KEY, VALUE> writer, ConflictDetectingValueMerger <KEY, VALUE, Value[]> conflictDetectingValueMerger) where KEY : NativeIndexKey <KEY> where VALUE : NativeIndexValue
        {
            InitializeKeyAndValueFromUpdate(treeKey, treeValue, update.EntityId, update.Values());
            conflictDetectingValueMerger.ControlConflictDetection(treeKey);
            writer.Merge(treeKey, treeValue, conflictDetectingValueMerger);
            conflictDetectingValueMerger.CheckConflict(update.Values());
        }
コード例 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void process(org.neo4j.kernel.api.index.IndexEntryUpdate<?> update) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void Process <T1>(IndexEntryUpdate <T1> update)
        {
            switch (update.UpdateMode())
            {
            case ADDED:
                Select(update.Values()[0].valueGroup()).process(update);
                break;

            case CHANGED:
                // These are both temporal, but could belong in different parts
                IndexUpdater from = Select(update.BeforeValues()[0].valueGroup());
                IndexUpdater to   = Select(update.Values()[0].valueGroup());
                // There are two cases:
                // - both before/after go into the same updater --> pass update into that updater
                if (from == to)
                {
                    from.Process(update);
                }
                // - before go into one and after into the other --> REMOVED from one and ADDED into the other
                else
                {
                    from.Process(IndexEntryUpdate.remove(update.EntityId, update.IndexKey(), update.BeforeValues()));
                    to.Process(IndexEntryUpdate.add(update.EntityId, update.IndexKey(), update.Values()));
                }
                break;

            case REMOVED:
                Select(update.Values()[0].valueGroup()).process(update);
                break;

            default:
                throw new System.ArgumentException("Unknown update mode");
            }
        }
コード例 #4
0
            public override void Process <T1>(IndexEntryUpdate <T1> update)
            {
                // we do not support adding partial entries
                Debug.Assert(update.IndexKey().schema().Equals(outerInstance.Descriptor.schema()));

                switch (update.UpdateMode())
                {
                case ADDED:
                    if (Idempotent)
                    {
                        AddIdempotent(update.EntityId, update.Values());
                    }
                    else
                    {
                        Add(update.EntityId, update.Values());
                    }
                    break;

                case CHANGED:
                    Change(update.EntityId, update.Values());
                    break;

                case REMOVED:
                    Remove(update.EntityId);
                    break;

                default:
                    throw new System.NotSupportedException();
                }
                HasChanges = true;
            }
コード例 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static <KEY extends NativeIndexKey<KEY>, VALUE extends NativeIndexValue> void processChange(KEY treeKey, VALUE treeValue, org.neo4j.kernel.api.index.IndexEntryUpdate<?> update, org.neo4j.index.internal.gbptree.Writer<KEY,VALUE> writer, ConflictDetectingValueMerger<KEY,VALUE,org.neo4j.values.storable.Value[]> conflictDetectingValueMerger) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        private static void ProcessChange <KEY, VALUE, T1>(KEY treeKey, VALUE treeValue, IndexEntryUpdate <T1> update, Writer <KEY, VALUE> writer, ConflictDetectingValueMerger <KEY, VALUE, Value[]> conflictDetectingValueMerger) where KEY : NativeIndexKey <KEY> where VALUE : NativeIndexValue
        {
            // Remove old entry
            InitializeKeyFromUpdate(treeKey, update.EntityId, update.BeforeValues());
            writer.Remove(treeKey);
            // Insert new entry
            InitializeKeyFromUpdate(treeKey, update.EntityId, update.Values());
            treeValue.From(update.Values());
            conflictDetectingValueMerger.ControlConflictDetection(treeKey);
            writer.Merge(treeKey, treeValue, conflictDetectingValueMerger);
            conflictDetectingValueMerger.CheckConflict(update.Values());
        }
コード例 #6
0
 private static void ProcessRemove <KEY, VALUE, T1>(KEY treeKey, IndexEntryUpdate <T1> update, Writer <KEY, VALUE> writer) where KEY : NativeIndexKey <KEY> where VALUE : NativeIndexValue
 {
     // todo Do we need to verify that we actually removed something at all?
     // todo Difference between online and recovery?
     InitializeKeyFromUpdate(treeKey, update.EntityId, update.Values());
     writer.Remove(treeKey);
 }
コード例 #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void process(org.neo4j.kernel.api.index.IndexEntryUpdate<?> update) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void Process <T1>(IndexEntryUpdate <T1> update)
        {
            IndexUpdater to = Select((( PointValue )update.Values()[0]).CoordinateReferenceSystem);

            switch (update.UpdateMode())
            {
            case ADDED:
            case REMOVED:
                to.Process(update);
                break;

            case CHANGED:
                IndexUpdater from = Select((( PointValue )update.BeforeValues()[0]).CoordinateReferenceSystem);
                // There are two cases:
                // - both before/after go into the same updater --> pass update into that updater
                if (from == to)
                {
                    from.Process(update);
                }
                // - before go into one and after into the other --> REMOVED from one and ADDED into the other
                else
                {
                    from.Process(IndexEntryUpdate.remove(update.EntityId, update.IndexKey(), update.BeforeValues()));
                    to.Process(IndexEntryUpdate.add(update.EntityId, update.IndexKey(), update.Values()));
                }
                break;

            default:
                throw new System.ArgumentException("Unknown update mode");
            }
        }
コード例 #8
0
                public void process <T1>(IndexEntryUpdate <T1> update)
                {
                    switch (update.UpdateMode())
                    {
                    case ADDED:
                    case CHANGED:
                        _outerInstance.added[update.EntityId] = update.Values()[0].asObjectCopy();
                        break;

                    case REMOVED:
                        _outerInstance.removed[update.EntityId] = update.Values()[0].asObjectCopy();                                           // on remove, value is the before value
                        break;

                    default:
                        throw new System.ArgumentException(update.UpdateMode().name());
                    }
                }
コード例 #9
0
 internal virtual void Add <T1>(IndexEntryUpdate <T1> update)
 {
     if (update.EntityId == 2)
     {
         JobConflict.update(IndexEntryUpdate.remove(NodeToDelete, Index, ValueToDelete));
     }
     Added[update.EntityId] = update.Values()[0].asObjectCopy();
 }
コード例 #10
0
 internal virtual void Add <T1>(IndexEntryUpdate <T1> update)
 {
     if (update.EntityId == 2)
     {
         JobConflict.update(IndexEntryUpdate.change(NodeToChange, Index, PreviousValue, NewValue));
     }
     Added.Add(Pair.of(update.EntityId, update.Values()[0].asObjectCopy()));
 }
コード例 #11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void process(org.neo4j.kernel.api.index.IndexEntryUpdate<?> update) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void Process <T1>(IndexEntryUpdate <T1> update)
        {
            _actual.process(update);
            if (update.UpdateMode() != REMOVED)
            {
                _touchedTuples.Add(ValueTuple.of(update.Values()));
            }
        }
コード例 #12
0
                public void process <T1>(IndexEntryUpdate <T1> update)
                {
                    switch (update.UpdateMode())
                    {
                    case ADDED:
                    case CHANGED:
                        _outerInstance.added.Add(Pair.of(update.EntityId, update.Values()[0].asObjectCopy()));
                        break;

                    default:
                        throw new System.ArgumentException(update.UpdateMode().name());
                    }
                }
コード例 #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void process(org.neo4j.kernel.api.index.IndexEntryUpdate<?> update) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void Process <T1>(IndexEntryUpdate <T1> update)
        {
            switch (update.UpdateMode())
            {
            case ADDED:
                InstanceSelector.select(SlotSelector.selectSlot(update.Values(), GroupOf)).process(update);
                break;

            case CHANGED:
                // Hmm, here's a little conundrum. What if we change from a value that goes into native
                // to a value that goes into fallback, or vice versa? We also don't want to blindly pass
                // all CHANGED updates to both updaters since not all values will work in them.
                IndexUpdater from = InstanceSelector.select(SlotSelector.selectSlot(update.BeforeValues(), GroupOf));
                IndexUpdater to   = InstanceSelector.select(SlotSelector.selectSlot(update.Values(), GroupOf));
                // There are two cases:
                // - both before/after go into the same updater --> pass update into that updater
                if (from == to)
                {
                    from.Process(update);
                }
                // - before go into one and after into the other --> REMOVED from one and ADDED into the other
                else
                {
                    from.Process(IndexEntryUpdate.remove(update.EntityId, update.IndexKey(), update.BeforeValues()));
                    to.Process(IndexEntryUpdate.add(update.EntityId, update.IndexKey(), update.Values()));
                }
                break;

            case REMOVED:
                InstanceSelector.select(SlotSelector.selectSlot(update.Values(), GroupOf)).process(update);
                break;

            default:
                throw new System.ArgumentException("Unknown update mode");
            }
        }
コード例 #14
0
 public override void IncludeSample <T1>(IndexEntryUpdate <T1> update)
 {
     Value[] values = update.Values();
     Debug.Assert(values.Length == 1);
     UncheckedSelect((( PointValue )values[0]).CoordinateReferenceSystem).includeSample(update);
 }
コード例 #15
0
 public override void IncludeSample <T1>(IndexEntryUpdate <T1> update)
 {
     _sampler.include(LuceneDocumentStructure.encodedStringValuesForSampling(update.Values()));
 }
コード例 #16
0
 protected internal override void Changed <T1>(IndexEntryUpdate <T1> update)
 {
     _updatedValueTuples.Add(update.Values());
 }
コード例 #17
0
        protected internal override void Changed <T1>(IndexEntryUpdate <T1> update)
        {
            string encodedValueBefore = LuceneDocumentStructure.encodedStringValuesForSampling(update.BeforeValues());

            _sampler.exclude(encodedValueBefore);

            string encodedValueAfter = LuceneDocumentStructure.encodedStringValuesForSampling(update.Values());

            _sampler.include(encodedValueAfter);
        }
コード例 #18
0
        protected internal override void Removed <T1>(IndexEntryUpdate <T1> update)
        {
            string removedValue = LuceneDocumentStructure.encodedStringValuesForSampling(update.Values());

            _sampler.exclude(removedValue);
        }
コード例 #19
0
 private void StoreUpdate <T1>(IndexEntryUpdate <T1> update, BlockStorage <KEY, VALUE> blockStorage)
 {
     StoreUpdate(update.EntityId, update.Values(), blockStorage);
 }
コード例 #20
0
ファイル: IndexCRUDIT.cs プロジェクト: Neo4Net/Neo4Net
 public override void IncludeSample <T1>(IndexEntryUpdate <T1> update)
 {
     AddValueToSample(update.EntityId, update.Values()[0]);
 }
コード例 #21
0
 private Document UpdateAsDocument <T1>(IndexEntryUpdate <T1> update)
 {
     return(LuceneFulltextDocumentStructure.DocumentRepresentingProperties(update.EntityId, _descriptor.propertyNames(), update.Values()));
 }
コード例 #22
0
 public override void IncludeSample <T1>(IndexEntryUpdate <T1> update)
 {
     InstanceSelector.select(SlotSelector.selectSlot(update.Values(), GroupOf)).includeSample(update);
 }
コード例 #23
0
            public override void Process <T1>(IndexEntryUpdate <T1> update)
            {
                Debug.Assert(update.IndexKey().schema().Equals(outerInstance.descriptor.Schema()));
                try
                {
                    switch (update.UpdateMode())
                    {
                    case ADDED:
                        long nodeId = update.EntityId;
                        outerInstance.LuceneIndex.IndexWriter.updateDocument(LuceneFulltextDocumentStructure.NewTermForChangeOrRemove(nodeId), LuceneFulltextDocumentStructure.DocumentRepresentingProperties(nodeId, outerInstance.descriptor.PropertyNames(), update.Values()));

                        goto case CHANGED;

                    case CHANGED:
                        long nodeId1 = update.EntityId;
                        outerInstance.LuceneIndex.IndexWriter.updateDocument(LuceneFulltextDocumentStructure.NewTermForChangeOrRemove(nodeId1), LuceneFulltextDocumentStructure.DocumentRepresentingProperties(nodeId1, outerInstance.descriptor.PropertyNames(), update.Values()));
                        break;

                    case REMOVED:
                        outerInstance.LuceneIndex.IndexWriter.deleteDocuments(LuceneFulltextDocumentStructure.NewTermForChangeOrRemove(update.EntityId));
                        break;

                    default:
                        throw new System.NotSupportedException();
                    }
                }
                catch (IOException e)
                {
                    throw new UncheckedIOException(e);
                }
            }
コード例 #24
0
        public override void Process <T1>(IndexEntryUpdate <T1> update)
        {
            long nodeId = update.EntityId;

            try
            {
                switch (update.UpdateMode())
                {
                case ADDED:
                    Added(update);
                    _writer.updateDocument(LuceneDocumentStructure.newTermForChangeOrRemove(nodeId), LuceneDocumentStructure.documentRepresentingProperties(nodeId, update.Values()));
                    break;

                case CHANGED:
                    Changed(update);
                    _writer.updateDocument(LuceneDocumentStructure.newTermForChangeOrRemove(nodeId), LuceneDocumentStructure.documentRepresentingProperties(nodeId, update.Values()));
                    break;

                case REMOVED:
                    Removed(update);
                    _writer.deleteDocuments(LuceneDocumentStructure.newTermForChangeOrRemove(nodeId));
                    break;

                default:
                    throw new System.InvalidOperationException("Unknown update mode " + Arrays.ToString(update.Values()));
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
コード例 #25
0
 public override void IncludeSample <T1>(IndexEntryUpdate <T1> update)
 {
     Value[] values = update.Values();
     Debug.Assert(values.Length == 1);
     UncheckedSelect(values[0].ValueGroup()).includeSample(update);
 }
コード例 #26
0
 private static Document UpdateAsDocument <T1>(IndexEntryUpdate <T1> update)
 {
     return(LuceneDocumentStructure.documentRepresentingProperties(update.EntityId, update.Values()));
 }
コード例 #27
0
 protected internal override void Added <T1>(IndexEntryUpdate <T1> update)
 {
     _sampler.increment(1);
     _updatedValueTuples.Add(update.Values());
 }