//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUpdateCorrectIndexes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUpdateCorrectIndexes()
        {
            OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates(_nodeStore, _relationshipStore, _indexingService, _propertyPhysicalToLogicalConverter);

            long relId = 0;
            RelationshipRecord inUse    = GetRelationship(relId, true, ENTITY_TOKEN);
            Value propertyValue         = Values.of("hej");
            Value propertyValue2        = Values.of("da");
            long  propertyId            = CreateRelationshipProperty(inUse, propertyValue, 1);
            long  propertyId2           = CreateRelationshipProperty(inUse, propertyValue2, 4);
            RelationshipRecord notInUse = GetRelationship(relId, false, ENTITY_TOKEN);

            _relationshipStore.updateRecord(inUse);

            Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand(inUse, notInUse);
            PropertyRecord propertyBlocks = new PropertyRecord(propertyId);

            propertyBlocks.RelId = relId;
            Command.PropertyCommand propertyCommand = new Command.PropertyCommand(_recordAccess.getIfLoaded(propertyId).forReadingData(), propertyBlocks);

            PropertyRecord propertyBlocks2 = new PropertyRecord(propertyId2);

            propertyBlocks2.RelId = relId;
            Command.PropertyCommand propertyCommand2 = new Command.PropertyCommand(_recordAccess.getIfLoaded(propertyId2).forReadingData(), propertyBlocks2);

            StoreIndexDescriptor indexDescriptor0 = forSchema(multiToken(_entityTokens, RELATIONSHIP, 1, 4, 6), EMPTY.ProviderDescriptor).withId(0);
            StoreIndexDescriptor indexDescriptor1 = forSchema(multiToken(_entityTokens, RELATIONSHIP, 2, 4, 6), EMPTY.ProviderDescriptor).withId(1);
            StoreIndexDescriptor indexDescriptor2 = forSchema(multiToken(new int[] { ENTITY_TOKEN, OTHER_ENTITY_TOKEN }, RELATIONSHIP, 1), EMPTY.ProviderDescriptor).withId(2);
            StoreIndexDescriptor indexDescriptor3 = forSchema(multiToken(new int[] { OTHER_ENTITY_TOKEN }, RELATIONSHIP, 1), EMPTY.ProviderDescriptor).withId(3);

            _indexingService.createIndexes(indexDescriptor0, indexDescriptor1, indexDescriptor2);
            _indexingService.getIndexProxy(indexDescriptor0.Schema()).awaitStoreScanCompleted(0, MILLISECONDS);
            _indexingService.getIndexProxy(indexDescriptor1.Schema()).awaitStoreScanCompleted(0, MILLISECONDS);
            _indexingService.getIndexProxy(indexDescriptor2.Schema()).awaitStoreScanCompleted(0, MILLISECONDS);

            onlineIndexUpdates.Feed(NodeGroup(null), RelationshipGroup(relationshipCommand, propertyCommand, propertyCommand2));
            assertTrue(onlineIndexUpdates.HasUpdates());
            assertThat(onlineIndexUpdates, containsInAnyOrder(IndexEntryUpdate.remove(relId, indexDescriptor0, propertyValue, propertyValue2, null), IndexEntryUpdate.remove(relId, indexDescriptor1, null, propertyValue2, null), IndexEntryUpdate.remove(relId, indexDescriptor2, propertyValue)));
            assertThat(onlineIndexUpdates, not(containsInAnyOrder(indexDescriptor3)));                     // This index is only for a different relationship type.
        }
Example #2
0
 public override void IncludeSample <T1>(IndexEntryUpdate <T1> update)
 {
     _sampler.include(LuceneDocumentStructure.encodedStringValuesForSampling(update.Values()));
 }
Example #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)
        {
            Delegate.process(update);
        }
Example #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static <KEY extends NativeIndexKey<KEY>, VALUE extends NativeIndexValue> void processUpdate(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
        internal static void ProcessUpdate <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
        {
            switch (update.UpdateMode())
            {
            case ADDED:
                ProcessAdd(treeKey, treeValue, update, writer, conflictDetectingValueMerger);
                break;

            case CHANGED:
                ProcessChange(treeKey, treeValue, update, writer, conflictDetectingValueMerger);
                break;

            case REMOVED:
                ProcessRemove(treeKey, update, writer);
                break;

            default:
                throw new System.ArgumentException();
            }
        }
Example #5
0
 public override void AcceptUpdate <T1>(MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate <T1> update, long currentlyIndexedNodeId)
 {
     if (update.EntityId <= currentlyIndexedNodeId)
     {
         updater.Process(update);
     }
 }
Example #6
0
 /// <summary>
 /// Method is invoked when <seealso cref="IndexEntryUpdate"/> with <seealso cref="UpdateMode.REMOVED"/> is processed.
 /// </summary>
 /// <param name="update"> the update being processed. </param>
 protected internal abstract void removed <T1>(IndexEntryUpdate <T1> update);
Example #7
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());
        }
Example #8
0
 /// <summary>
 /// A transaction happened that produced the given updates. Let this job incorporate its data,
 /// feeding it to the <seealso cref="IndexPopulator"/>.
 /// </summary>
 /// <param name="update"> <seealso cref="IndexEntryUpdate"/> to queue. </param>
 public virtual void Update <T1>(IndexEntryUpdate <T1> update)
 {
     _multiPopulator.queueUpdate(update);
 }
 /// <summary>
 /// Queues an update to be fed into the index populators. These updates come from changes being made
 /// to storage while a concurrent scan is happening to keep populators up to date with all latest changes.
 /// </summary>
 /// <param name="update"> <seealso cref="IndexEntryUpdate"/> to queue. </param>
 internal virtual void QueueUpdate <T1>(IndexEntryUpdate <T1> update)
 {
     UpdatesQueue.AddLast(update);
 }
Example #10
0
 public abstract void includeSample <T1>(IndexEntryUpdate <T1> update);
Example #11
0
 protected internal virtual IndexEntryUpdate <IndexDescriptor> Add(long nodeId, Value value)
 {
     return(IndexEntryUpdate.add(nodeId, IndexDescriptorConflict, value));
 }
Example #12
0
 private static Document UpdateAsDocument <T1>(IndexEntryUpdate <T1> update)
 {
     return(LuceneDocumentStructure.documentRepresentingProperties(update.EntityId, update.Values()));
 }
Example #13
0
 public override void IncludeSample <T1>(IndexEntryUpdate <T1> update)
 {
     //Index sampling is not our thing, really.
 }
Example #14
0
 private Document UpdateAsDocument <T1>(IndexEntryUpdate <T1> update)
 {
     return(LuceneFulltextDocumentStructure.DocumentRepresentingProperties(update.EntityId, _descriptor.propertyNames(), update.Values()));
 }
Example #15
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: private org.neo4j.kernel.api.index.IndexEntryUpdate<?> add(long nodeId, Object value)
        private IndexEntryUpdate <object> Add(long nodeId, object value)
        {
            return(IndexEntryUpdate.add(nodeId, _descriptor.schema(), Values.of(value)));
        }
Example #16
0
 public override void IncludeSample <T1>(IndexEntryUpdate <T1> update)
 {
     throw new System.NotSupportedException("Multiple index populator can't perform index sampling.");
 }
Example #17
0
 /// <summary>
 /// Method is invoked when <seealso cref="IndexEntryUpdate"/> with <seealso cref="UpdateMode.CHANGED"/> is processed.
 /// </summary>
 /// <param name="update"> the update being processed. </param>
 protected internal abstract void changed <T1>(IndexEntryUpdate <T1> update);
Example #18
0
 public virtual bool Batch <T1>(IndexEntryUpdate <T1> update)
 {
     BatchedUpdates.Add(update);
     return(BatchedUpdates.Count >= outerInstance.BatchSize);
 }
Example #19
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());
        }
Example #20
0
 public override void AcceptUpdate <T1>(MultipleIndexUpdater updater, IndexEntryUpdate <T1> update, long currentlyIndexedNodeId)
 {
     Delegate.acceptUpdate(updater, update, currentlyIndexedNodeId);
 }
Example #21
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)
        {
            AssertOpen();
            ProcessUpdate(_treeKey, _treeValue, update, _writer, _conflictDetectingValueMerger);
        }
Example #22
0
 public override void IncludeSample <T1>(IndexEntryUpdate <T1> update)
 {
     Value[] values = update.Values();
     Debug.Assert(values.Length == 1);
     UncheckedSelect(values[0].ValueGroup()).includeSample(update);
 }
Example #23
0
 public override void IncludeSample <T1>(IndexEntryUpdate <T1> update)
 {
     AddValueToSample(update.EntityId, update.Values()[0]);
 }
Example #24
0
                    public void process <T1>(IndexEntryUpdate <T1> update)
                    {
                        bool added = entitiesByUpdater.add(update.EntityId);

                        assertTrue(added);                            // we know that in this test we won't apply multiple updates for an entityId
                    }
Example #25
0
        protected internal override void Removed <T1>(IndexEntryUpdate <T1> update)
        {
            string removedValue = LuceneDocumentStructure.encodedStringValuesForSampling(update.Values());

            _sampler.exclude(removedValue);
        }
Example #26
0
 public void includeSample <T1>(IndexEntryUpdate <T1> update)
 {
 }
Example #27
0
        public virtual void EnqueueUpdate <T1, T2>(DatabaseIndex <T1> index, IndexUpdater indexUpdater, IndexEntryUpdate <T2> update) where T1 : Org.Neo4j.Storageengine.Api.schema.IndexReader
        {
            _updateQueueLimit.acquireUninterruptibly();
            ThreadStart eventualUpdate = () =>
            {
                try
                {
                    indexUpdater.Process(update);
                }
                catch (IndexEntryConflictException e)
                {
                    MarkAsFailed(index, e);
                }
                finally
                {
                    _updateQueueLimit.release();
                }
            };

            try
            {
                _scheduler.schedule(Group.INDEX_UPDATING, eventualUpdate);
            }
            catch (Exception e)
            {
                _updateQueueLimit.release();                         // Avoid leaking permits if job scheduling fails.
                throw e;
            }
        }
 public override void IncludeSample <T1>(IndexEntryUpdate <T1> update)
 {
     _actual.includeSample(update);
 }
Example #29
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 void process <T1>(IndexEntryUpdate <T1> update)
                {
                    throw new IndexEntryConflictException(0, 1, Values.numberValue(0));
                }
Example #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDifferentiateNodesAndRelationships() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDifferentiateNodesAndRelationships()
        {
            OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates(_nodeStore, _relationshipStore, _indexingService, _propertyPhysicalToLogicalConverter);

            int        nodeId            = 0;
            NodeRecord inUseNode         = GetNode(nodeId, true);
            Value      nodePropertyValue = Values.of("hej");
            long       nodePropertyId    = CreateNodeProperty(inUseNode, nodePropertyValue, 1);
            NodeRecord notInUseNode      = GetNode(nodeId, false);

            _nodeStore.updateRecord(inUseNode);

            Command.NodeCommand nodeCommand        = new Command.NodeCommand(inUseNode, notInUseNode);
            PropertyRecord      nodePropertyBlocks = new PropertyRecord(nodePropertyId);

            nodePropertyBlocks.NodeId = nodeId;
            Command.PropertyCommand nodePropertyCommand = new Command.PropertyCommand(_recordAccess.getIfLoaded(nodePropertyId).forReadingData(), nodePropertyBlocks);

            StoreIndexDescriptor nodeIndexDescriptor = forSchema(multiToken(_entityTokens, NODE, 1, 4, 6), EMPTY.ProviderDescriptor).withId(0);

            _indexingService.createIndexes(nodeIndexDescriptor);
            _indexingService.getIndexProxy(nodeIndexDescriptor.Schema()).awaitStoreScanCompleted(0, MILLISECONDS);

            long relId = 0;
            RelationshipRecord inUse        = GetRelationship(relId, true, ENTITY_TOKEN);
            Value relationshipPropertyValue = Values.of("da");
            long  propertyId            = CreateRelationshipProperty(inUse, relationshipPropertyValue, 1);
            RelationshipRecord notInUse = GetRelationship(relId, false, ENTITY_TOKEN);

            _relationshipStore.updateRecord(inUse);

            Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand(inUse, notInUse);
            PropertyRecord relationshipPropertyBlocks       = new PropertyRecord(propertyId);

            relationshipPropertyBlocks.RelId = relId;
            Command.PropertyCommand relationshipPropertyCommand = new Command.PropertyCommand(_recordAccess.getIfLoaded(propertyId).forReadingData(), relationshipPropertyBlocks);

            StoreIndexDescriptor relationshipIndexDescriptor = forSchema(multiToken(_entityTokens, RELATIONSHIP, 1, 4, 6), EMPTY.ProviderDescriptor).withId(1);

            _indexingService.createIndexes(relationshipIndexDescriptor);
            _indexingService.getIndexProxy(relationshipIndexDescriptor.Schema()).awaitStoreScanCompleted(0, MILLISECONDS);

            onlineIndexUpdates.Feed(NodeGroup(nodeCommand, nodePropertyCommand), RelationshipGroup(relationshipCommand, relationshipPropertyCommand));
            assertTrue(onlineIndexUpdates.HasUpdates());
            assertThat(onlineIndexUpdates, containsInAnyOrder(IndexEntryUpdate.remove(relId, relationshipIndexDescriptor, relationshipPropertyValue, null, null), IndexEntryUpdate.remove(nodeId, nodeIndexDescriptor, nodePropertyValue, null, null)));
        }