//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("ConstantConditions") private <INDEX_KEY extends org.neo4j.internal.kernel.api.schema.SchemaDescriptorSupplier> Iterable<org.neo4j.kernel.api.index.IndexEntryUpdate<INDEX_KEY>> gatherUpdatesForPotentials(Iterable<INDEX_KEY> potentiallyRelevant) private IEnumerable <IndexEntryUpdate <INDEX_KEY> > GatherUpdatesForPotentials <INDEX_KEY>(IEnumerable <INDEX_KEY> potentiallyRelevant) where INDEX_KEY : [email protected] { IList <IndexEntryUpdate <INDEX_KEY> > indexUpdates = new List <IndexEntryUpdate <INDEX_KEY> >(); foreach (INDEX_KEY indexKey in potentiallyRelevant) { SchemaDescriptor schema = indexKey.schema(); bool relevantBefore = relevantBefore(schema); bool relevantAfter = relevantAfter(schema); int[] propertyIds = Schema.PropertyIds; if (relevantBefore && !relevantAfter) { indexUpdates.Add(IndexEntryUpdate.remove(_entityId, indexKey, ValuesBefore(propertyIds))); } else if (!relevantBefore && relevantAfter) { indexUpdates.Add(IndexEntryUpdate.add(_entityId, indexKey, ValuesAfter(propertyIds))); } else if (relevantBefore && relevantAfter) { if (ValuesChanged(propertyIds, Schema.propertySchemaType())) { indexUpdates.Add(IndexEntryUpdate.change(_entityId, indexKey, ValuesBefore(propertyIds), ValuesAfter(propertyIds))); } } } return(indexUpdates); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addingANodeWithPropertyShouldGetIndexed() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void AddingANodeWithPropertyShouldGetIndexed() { // Given string indexProperty = "indexProperty"; GatheringIndexWriter writer = NewWriter(); createIndex(_db, _myLabel, indexProperty); // When int value1 = 12; string otherProperty = "otherProperty"; int otherValue = 17; Node node = CreateNode(map(indexProperty, value1, otherProperty, otherValue), _myLabel); // Then, for now, this should trigger two NodePropertyUpdates using (Transaction tx = _db.beginTx()) { KernelTransaction ktx = _ctxSupplier.getKernelTransactionBoundToThisThread(true); TokenRead tokenRead = ktx.TokenRead(); int propertyKey1 = tokenRead.PropertyKey(indexProperty); int label = tokenRead.NodeLabel(_myLabel.name()); LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(label, propertyKey1); assertThat(writer.UpdatesCommitted, equalTo(asSet(IndexEntryUpdate.add(node.Id, descriptor, Values.of(value1))))); tx.Success(); } // We get two updates because we both add a label and a property to be indexed // in the same transaction, in the future, we should optimize this down to // one NodePropertyUpdate. }
//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(update.Values()[0].valueGroup()); switch (update.UpdateMode()) { case ADDED: case REMOVED: to.Process(update); break; case CHANGED: IndexUpdater from = Select(update.BeforeValues()[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; default: throw new System.ArgumentException("Unknown update mode"); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void makeSureIndexHasSomeData(org.neo4j.kernel.api.index.IndexProvider provider) throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private void MakeSureIndexHasSomeData(IndexProvider provider) { using (IndexAccessor accessor = provider.GetOnlineAccessor(_storeIndexDescriptor, _samplingConfig), IndexUpdater updater = accessor.NewUpdater(IndexUpdateMode.ONLINE)) { updater.Process(IndexEntryUpdate.add(1, _storeIndexDescriptor, Values.of("some string"))); } }
private IList <IndexEntryUpdate <SchemaDescriptorSupplier> > GenerateSomeUpdates(int count) { IList <IndexEntryUpdate <SchemaDescriptorSupplier> > updates = new List <IndexEntryUpdate <SchemaDescriptorSupplier> >(); for (int i = 0; i < count; i++) { long entityId = Random.nextLong(10_000_000); switch (Random.among(UpdateMode.MODES)) { case ADDED: updates.Add(IndexEntryUpdate.add(entityId, _descriptor, Random.nextValue())); break; case REMOVED: updates.Add(IndexEntryUpdate.remove(entityId, _descriptor, Random.nextValue())); break; case CHANGED: updates.Add(IndexEntryUpdate.change(entityId, _descriptor, Random.nextValue(), Random.nextValue())); break; default: throw new System.ArgumentException(); } } return(updates); }
private long AddPointsToLists <T1>(IList <Value> pointValues, IList <T1> updates, long nodeId, params PointValue[] values) { foreach (PointValue value in values) { pointValues.Add(value); updates.Add(IndexEntryUpdate.add(nodeId++, _descriptor, value)); } return(nodeId); }
internal static IndexEntryUpdate <LabelSchemaDescriptor> Add(params Value[] value) { switch (value.Length) { case 1: return(IndexEntryUpdate.add(0, _indexKey, value)); case 2: return(IndexEntryUpdate.add(0, _compositeIndexKey, value)); default: return(null); } }
private static IndexEntryUpdate <SchemaDescriptorSupplier> AsUpdate(IndexUpdateCursor <GenericKey, NativeIndexValue> reader) { switch (reader.UpdateMode()) { case ADDED: return(IndexEntryUpdate.add(reader.Key().EntityId, _descriptor, reader.Key().asValue())); case CHANGED: return(IndexEntryUpdate.change(reader.Key().EntityId, _descriptor, reader.Key().asValue(), reader.Key2().asValue())); case REMOVED: return(IndexEntryUpdate.remove(reader.Key().EntityId, _descriptor, reader.Key().asValue())); default: throw new System.ArgumentException(); } }
/* getOnlineAccessor */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotCheckConflictsWhenApplyingUpdatesInOnlineAccessor() throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotCheckConflictsWhenApplyingUpdatesInOnlineAccessor() { // given _provider = NewProvider(); // when StoreIndexDescriptor descriptor = DescriptorUnique(); using (IndexAccessor accessor = _provider.getOnlineAccessor(descriptor, SamplingConfig()), IndexUpdater indexUpdater = accessor.NewUpdater(IndexUpdateMode.ONLINE)) { Value value = SomeValue(); indexUpdater.Process(IndexEntryUpdate.add(1, descriptor.Schema(), value)); // then // ... expect no failure on duplicate value indexUpdater.Process(IndexEntryUpdate.add(2, descriptor.Schema(), value)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowOnDuplicatedValuesFromScanAndExternalUpdates() public virtual void ShouldThrowOnDuplicatedValuesFromScanAndExternalUpdates() { // given BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator = InstantiatePopulator(_uniqueIndexDescriptor); bool closed = false; try { // when Value duplicate = Values.of("duplicate"); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> externalUpdate = org.neo4j.kernel.api.index.IndexEntryUpdate.add(1, INDEX_DESCRIPTOR, duplicate); IndexEntryUpdate <object> externalUpdate = IndexEntryUpdate.add(1, _indexDescriptor, duplicate); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> scanUpdate = org.neo4j.kernel.api.index.IndexEntryUpdate.add(2, INDEX_DESCRIPTOR, duplicate); IndexEntryUpdate <object> scanUpdate = IndexEntryUpdate.add(2, _indexDescriptor, duplicate); try { using (IndexUpdater updater = populator.NewPopulatingUpdater()) { updater.Process(externalUpdate); } populator.Add(singleton(scanUpdate)); populator.ScanCompleted(nullInstance); fail("Expected to throw"); } catch (IndexEntryConflictException) { // then } } finally { if (!closed) { populator.Close(true); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotThrowOnDuplicationsLaterFixedByExternalUpdates() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotThrowOnDuplicationsLaterFixedByExternalUpdates() { // given BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator = InstantiatePopulator(_uniqueIndexDescriptor); bool closed = false; try { // when Value duplicate = Values.of("duplicate"); Value unique = Values.of("unique"); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> firstScanUpdate = org.neo4j.kernel.api.index.IndexEntryUpdate.add(1, INDEX_DESCRIPTOR, duplicate); IndexEntryUpdate <object> firstScanUpdate = IndexEntryUpdate.add(1, _indexDescriptor, duplicate); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> secondScanUpdate = org.neo4j.kernel.api.index.IndexEntryUpdate.add(2, INDEX_DESCRIPTOR, duplicate); IndexEntryUpdate <object> secondScanUpdate = IndexEntryUpdate.add(2, _indexDescriptor, duplicate); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> externalUpdate = org.neo4j.kernel.api.index.IndexEntryUpdate.change(1, INDEX_DESCRIPTOR, duplicate, unique); IndexEntryUpdate <object> externalUpdate = IndexEntryUpdate.change(1, _indexDescriptor, duplicate, unique); populator.Add(singleton(firstScanUpdate)); using (IndexUpdater updater = populator.NewPopulatingUpdater()) { updater.Process(externalUpdate); } populator.Add(singleton(secondScanUpdate)); populator.ScanCompleted(nullInstance); // then AssertHasEntry(populator, unique, 1); AssertHasEntry(populator, duplicate, 2); } finally { if (!closed) { populator.Close(true); } } }
/// <summary> /// This test verify that we correctly handle unique point arrays where every point in every array belong to the same tile on the space filling curve. /// We verify this by asserting that we always get exactly one hit on an exact match and that the value is what we expect. /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustHandlePointArraysWithinSameTile() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException, org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MustHandlePointArraysWithinSameTile() { // given // Many random points that all are close enough to each other to belong to the same tile on the space filling curve. int nbrOfValues = 10000; PointValue origin = Values.pointValue(WGS84, 0.0, 0.0); long? derivedValueForCenterPoint = _curve.derivedValueFor(origin.Coordinate()); double[] centerPoint = _curve.centerPointFor(derivedValueForCenterPoint.Value); double xWidthMultiplier = _curve.getTileWidth(0, _curve.MaxLevel) / 2; double yWidthMultiplier = _curve.getTileWidth(1, _curve.MaxLevel) / 2; IList <Value> pointArrays = new List <Value>(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = new java.util.ArrayList<>(); IList <IndexEntryUpdate <object> > updates = new List <IndexEntryUpdate <object> >(); for (int i = 0; i < nbrOfValues; i++) { int arrayLength = _random.Next(5) + 1; PointValue[] pointValues = new PointValue[arrayLength]; for (int j = 0; j < arrayLength; j++) { double x = (_random.NextDouble() * 2 - 1) * xWidthMultiplier; double y = (_random.NextDouble() * 2 - 1) * yWidthMultiplier; PointValue value = Values.pointValue(WGS84, centerPoint[0] + x, centerPoint[1] + y); AssertDerivedValue(derivedValueForCenterPoint, value); pointValues[j] = value; } PointArray array = Values.pointArray(pointValues); pointArrays.Add(array); updates.Add(IndexEntryUpdate.add(i, _descriptor, array)); } ProcessAll(updates); // then ExactMatchOnAllValues(pointArrays); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPopulateIndexWithOneNode() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPopulateIndexWithOneNode() { // GIVEN string value = "Taylor"; long nodeId = CreateNode(map(_name, value), _first); IndexPopulator populator = spy(IndexPopulator(false)); LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(0, 0); IndexPopulationJob job = NewIndexPopulationJob(populator, new FlippableIndexProxy(), EntityType.NODE, IndexDescriptorFactory.forSchema(descriptor)); // WHEN job.Run(); // THEN //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update = org.neo4j.kernel.api.index.IndexEntryUpdate.add(nodeId, descriptor, org.neo4j.values.storable.Values.of(value)); IndexEntryUpdate <object> update = IndexEntryUpdate.add(nodeId, descriptor, Values.of(value)); verify(populator).create(); verify(populator).includeSample(update); verify(populator, times(2)).add(any(typeof(System.Collections.ICollection))); verify(populator).sampleResult(); verify(populator).close(true); }
//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) { PointValue value = ( PointValue )update.Values()[0]; switch (update.UpdateMode()) { case ADDED: Select(value.CoordinateReferenceSystem).process(update); break; case CHANGED: // These are both spatial, but could belong in different parts PointValue fromValue = ( PointValue )update.BeforeValues()[0]; IndexUpdater from = Select(fromValue.CoordinateReferenceSystem); IndexUpdater to = Select(value.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; case REMOVED: Select(value.CoordinateReferenceSystem).process(update); break; default: throw new System.ArgumentException("Unknown update mode"); } }
//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"); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addingALabelToPreExistingNodeShouldGetIndexed() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void AddingALabelToPreExistingNodeShouldGetIndexed() { // GIVEN string indexProperty = "indexProperty"; GatheringIndexWriter writer = NewWriter(); createIndex(_db, _myLabel, indexProperty); // WHEN string otherProperty = "otherProperty"; int value = 12; int otherValue = 17; Node node = CreateNode(map(indexProperty, value, otherProperty, otherValue)); // THEN assertThat(writer.UpdatesCommitted.Count, equalTo(0)); // AND WHEN using (Transaction tx = _db.beginTx()) { node.AddLabel(_myLabel); tx.Success(); } // THEN using (Transaction tx = _db.beginTx()) { KernelTransaction ktx = _ctxSupplier.getKernelTransactionBoundToThisThread(true); TokenRead tokenRead = ktx.TokenRead(); int propertyKey1 = tokenRead.PropertyKey(indexProperty); int label = tokenRead.NodeLabel(_myLabel.name()); LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(label, propertyKey1); assertThat(writer.UpdatesCommitted, equalTo(asSet(IndexEntryUpdate.add(node.Id, descriptor, Values.of(value))))); tx.Success(); } }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: private java.util.Set<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> createSomeBananas(org.neo4j.graphdb.Label label) private ISet <IndexEntryUpdate <object> > CreateSomeBananas(Label label) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Set<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = new java.util.HashSet<>(); ISet <IndexEntryUpdate <object> > updates = new HashSet <IndexEntryUpdate <object> >(); using (Transaction tx = _db.beginTx()) { ThreadToStatementContextBridge ctxSupplier = _db.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)); KernelTransaction ktx = ctxSupplier.GetKernelTransactionBoundToThisThread(true); int labelId = ktx.TokenRead().nodeLabel(label.Name()); int propertyKeyId = ktx.TokenRead().propertyKey(_key); LabelSchemaDescriptor schemaDescriptor = SchemaDescriptorFactory.forLabel(labelId, propertyKeyId); foreach (int number in new int[] { 4, 10 }) { Node node = _db.createNode(label); node.SetProperty(_key, number); updates.Add(IndexEntryUpdate.add(node.Id, schemaDescriptor, Values.of(number))); } tx.Success(); return(updates); } }
//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))); }
private static IndexEntryUpdate <StoreIndexDescriptor> Add(int i) { return(IndexEntryUpdate.add(i, _indexDescriptor, stringValue("Value" + i))); }
private IndexEntryUpdate <LabelSchemaDescriptor> SomeUpdate() { return(IndexEntryUpdate.add(0, SchemaDescriptorFactory.forLabel(0, 0), Values.numberValue(0))); }
protected internal virtual IndexEntryUpdate <IndexDescriptor> Add(long nodeId, Value value) { return(IndexEntryUpdate.add(nodeId, IndexDescriptorConflict, value)); }