//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRejectDuplicateEntryAfterUsingPopulatingUpdater() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRejectDuplicateEntryAfterUsingPopulatingUpdater() { // given _populator = NewPopulator(); string valueString = "value1"; IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor); updater.Process(add(1, _schemaDescriptor, valueString)); AddUpdate(_populator, 2, valueString); Value value = Values.of(valueString); when(_nodePropertyAccessor.getNodePropertyValue(1, PROPERTY_KEY_ID)).thenReturn(value); when(_nodePropertyAccessor.getNodePropertyValue(2, PROPERTY_KEY_ID)).thenReturn(value); // when try { _populator.verifyDeferredConstraints(_nodePropertyAccessor); fail("should have thrown exception"); } // then catch (IndexEntryConflictException conflict) { assertEquals(1, conflict.ExistingNodeId); assertEquals(value, conflict.SinglePropertyValue); assertEquals(2, conflict.AddedNodeId); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private int interleaveLargeAmountOfUpdates(java.util.Random updaterRandom, java.util.Iterator<org.neo4j.kernel.api.index.IndexEntryUpdate<org.neo4j.storageengine.api.schema.IndexDescriptor>> updates) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private int InterleaveLargeAmountOfUpdates(Random updaterRandom, IEnumerator <IndexEntryUpdate <IndexDescriptor> > updates) { int count = 0; for (int i = 0; i < LARGE_AMOUNT_OF_UPDATES; i++) { if (updaterRandom.nextFloat() < 0.1) { using (IndexUpdater indexUpdater = Populator.newPopulatingUpdater(NullPropertyAccessor)) { int numberOfUpdaterUpdates = updaterRandom.Next(100); for (int j = 0; j < numberOfUpdaterUpdates; j++) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: indexUpdater.Process(updates.next()); count++; } } } //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Populator.add(Collections.singletonList(updates.next())); count++; } return(count); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRejectDuplicateEntryWhenUsingPopulatingUpdater() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRejectDuplicateEntryWhenUsingPopulatingUpdater() { // given _populator = NewPopulator(); AddUpdate(_populator, 1, "value1"); AddUpdate(_populator, 2, "value2"); Value value = Values.of("value1"); when(_nodePropertyAccessor.getNodePropertyValue(1, PROPERTY_KEY_ID)).thenReturn(value); when(_nodePropertyAccessor.getNodePropertyValue(3, PROPERTY_KEY_ID)).thenReturn(value); // when try { IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor); updater.Process(add(3, _schemaDescriptor, "value1")); updater.Close(); fail("should have thrown exception"); } // then catch (IndexEntryConflictException conflict) { assertEquals(1, conflict.ExistingNodeId); assertEquals(value, conflict.SinglePropertyValue); assertEquals(3, conflict.AddedNodeId); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void updaterShouldThrowOnDuplicateValues() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void UpdaterShouldThrowOnDuplicateValues() { // given outerInstance.populator.create(); IndexEntryUpdate <IndexDescriptor>[] updates = valueCreatorUtil.someUpdatesWithDuplicateValues(random); IndexUpdater updater = outerInstance.populator.newPopulatingUpdater(NullPropertyAccessor); // when foreach (IndexEntryUpdate <IndexDescriptor> update in updates) { updater.Process(update); } try { updater.Close(); outerInstance.populator.scanCompleted(nullInstance); fail("Updates should have conflicted"); } catch (Exception e) { // then assertTrue(e.Message, Exceptions.contains(e, typeof(IndexEntryConflictException))); } finally { outerInstance.populator.close(true); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustDiscoverRelationshipInStoreMissingFromIndex() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MustDiscoverRelationshipInStoreMissingFromIndex() { GraphDatabaseService db = CreateDatabase(); using (Transaction tx = Db.beginTx()) { Db.execute(format(RELATIONSHIP_CREATE, "rels", array("REL"), array("prop"))).close(); tx.Success(); } StoreIndexDescriptor indexDescriptor; long relId; using (Transaction tx = Db.beginTx()) { Db.schema().awaitIndexesOnline(1, TimeUnit.MINUTES); indexDescriptor = GetIndexDescriptor(first(Db.schema().Indexes)); Node node = Db.createNode(); Relationship rel = node.CreateRelationshipTo(node, RelationshipType.withName("REL")); rel.SetProperty("prop", "value"); relId = rel.Id; tx.Success(); } IndexingService indexes = GetIndexingService(db); IndexProxy indexProxy = indexes.GetIndexProxy(indexDescriptor.Schema()); using (IndexUpdater updater = indexProxy.NewUpdater(IndexUpdateMode.ONLINE)) { updater.Process(IndexEntryUpdate.remove(relId, indexDescriptor, Values.stringValue("value"))); } Db.shutdown(); ConsistencyCheckService.Result result = CheckConsistency(); assertFalse(result.Successful); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void externalUpdate(BlockBasedIndexPopulator<GenericKey,NativeIndexValue> populator, org.neo4j.values.storable.TextValue matata, int matataId) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private void ExternalUpdate(BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator, TextValue matata, int matataId) { using (IndexUpdater indexUpdater = populator.NewPopulatingUpdater()) { // After scanCompleted indexUpdater.Process(add(matataId, _indexDescriptor, matata)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUpdateEntryForNodeThatHasPropertyRemovedAndThenAddedAgain() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUpdateEntryForNodeThatHasPropertyRemovedAndThenAddedAgain() { // given _populator = NewPopulator(); AddUpdate(_populator, 1, "value1"); // when IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor); updater.Process(remove(1, _schemaDescriptor, "value1")); updater.Process(add(1, _schemaDescriptor, "value1")); _populator.close(true); // then assertEquals(asList(1L), GetAllNodes(Directory, "value1")); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void externalUpdates(BlockBasedIndexPopulator<GenericKey,NativeIndexValue> populator, int firstId, int lastId) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private void ExternalUpdates(BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator, int firstId, int lastId) { using (IndexUpdater updater = populator.NewPopulatingUpdater()) { for (int i = firstId; i < lastId; i++) { updater.Process(Add(i)); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void generateUpdates(LuceneIndexAccessor indexAccessor, int nodesToUpdate) throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private void GenerateUpdates(LuceneIndexAccessor indexAccessor, int nodesToUpdate) { using (IndexUpdater updater = indexAccessor.NewUpdater(IndexUpdateMode.ONLINE)) { for (int nodeId = 0; nodeId < nodesToUpdate; nodeId++) { updater.Process(Add(nodeId, nodeId)); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToHandleSwappingOfIndexValues() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToHandleSwappingOfIndexValues() { // given _populator = NewPopulator(); AddUpdate(_populator, 1, "value1"); AddUpdate(_populator, 2, "value2"); // when IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor); updater.Process(change(1, _schemaDescriptor, "value1", "value2")); updater.Process(change(2, _schemaDescriptor, "value2", "value1")); _populator.close(true); // then assertEquals(asList(2L), GetAllNodes(Directory, "value1")); assertEquals(asList(1L), GetAllNodes(Directory, "value2")); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void updatePopulator(org.neo4j.kernel.api.index.IndexPopulator populator, Iterable<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates, org.neo4j.storageengine.api.NodePropertyAccessor accessor) throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private static void UpdatePopulator <T1>(IndexPopulator populator, IEnumerable <T1> updates, NodePropertyAccessor accessor) { using (IndexUpdater updater = populator.NewPopulatingUpdater(accessor)) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (org.neo4j.kernel.api.index.IndexEntryUpdate<?> update : updates) foreach (IndexEntryUpdate <object> update in updates) { updater.Process(update); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(expected = IllegalStateException.class) public void shouldNotUpdateBeforeCreate() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotUpdateBeforeCreate() { // GIVEN IndexProxy inner = mockIndexProxy(); IndexProxy outer = NewContractCheckingIndexProxy(inner); // WHEN using (IndexUpdater updater = outer.NewUpdater(IndexUpdateMode.Online)) { updater.Process(null); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void updateAndCommit(org.neo4j.kernel.api.index.IndexAccessor accessor, Iterable<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates) throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private void UpdateAndCommit <T1>(IndexAccessor accessor, IEnumerable <T1> updates) { using (IndexUpdater updater = accessor.NewUpdater(IndexUpdateMode.ONLINE)) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (org.neo4j.kernel.api.index.IndexEntryUpdate<?> update : updates) foreach (IndexEntryUpdate <object> update in updates) { updater.Process(update); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowOnDuplicatedValuesFromExternalUpdates() public virtual void ShouldThrowOnDuplicatedValuesFromExternalUpdates() { // 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<?> firstExternalUpdate = org.neo4j.kernel.api.index.IndexEntryUpdate.add(1, INDEX_DESCRIPTOR, duplicate); IndexEntryUpdate <object> firstExternalUpdate = 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<?> secondExternalUpdate = org.neo4j.kernel.api.index.IndexEntryUpdate.add(2, INDEX_DESCRIPTOR, duplicate); IndexEntryUpdate <object> secondExternalUpdate = IndexEntryUpdate.add(2, _indexDescriptor, duplicate); try { using (IndexUpdater updater = populator.NewPopulatingUpdater()) { updater.Process(firstExternalUpdate); updater.Process(secondExternalUpdate); } 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(expected = IllegalStateException.class) public void shouldNotUpdateAfterClose() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotUpdateAfterClose() { // GIVEN IndexProxy inner = mockIndexProxy(); IndexProxy outer = NewContractCheckingIndexProxy(inner); // WHEN outer.Start(); outer.Close(); using (IndexUpdater updater = outer.NewUpdater(IndexUpdateMode.Online)) { updater.Process(null); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotRejectDuplicateEntryOnSameNodeIdAfterUsingPopulatingUpdater() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotRejectDuplicateEntryOnSameNodeIdAfterUsingPopulatingUpdater() { // given _populator = NewPopulator(); when(_nodePropertyAccessor.getNodePropertyValue(1, PROPERTY_KEY_ID)).thenReturn(Values.of("value1")); IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor); updater.Process(add(1, _schemaDescriptor, "value1")); updater.Process(change(1, _schemaDescriptor, "value1", "value1")); updater.Close(); AddUpdate(_populator, 2, "value2"); AddUpdate(_populator, 3, "value3"); // when _populator.verifyDeferredConstraints(_nodePropertyAccessor); _populator.close(true); // then assertEquals(asList(1L), GetAllNodes(Directory, "value1")); assertEquals(asList(2L), GetAllNodes(Directory, "value2")); assertEquals(asList(3L), GetAllNodes(Directory, "value3")); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void addUpdates(SpatialIndexProvider provider, org.neo4j.storageengine.api.schema.StoreIndexDescriptor schemaIndexDescriptor, ValueCreatorUtil<SpatialIndexKey,NativeIndexValue> layoutUtil) throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private void AddUpdates(SpatialIndexProvider provider, StoreIndexDescriptor schemaIndexDescriptor, ValueCreatorUtil <SpatialIndexKey, NativeIndexValue> layoutUtil) { IndexAccessor accessor = provider.GetOnlineAccessor(schemaIndexDescriptor, SamplingConfig()); using (IndexUpdater updater = accessor.NewUpdater(ONLINE)) { // when foreach (IndexEntryUpdate <IndexDescriptor> update in layoutUtil.SomeUpdates(_randomRule)) { updater.Process(update); } } accessor.Force(Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited); accessor.Dispose(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRemoveEntryForNodeThatHasAlreadyBeenIndexed() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRemoveEntryForNodeThatHasAlreadyBeenIndexed() { // given _populator = NewPopulator(); AddUpdate(_populator, 1, "value1"); // when IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor); updater.Process(remove(1, _schemaDescriptor, "value1")); _populator.close(true); // then assertEquals(Collections.EMPTY_LIST, GetAllNodes(Directory, "value1")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUpdateWithAllValuesDuringPopulation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUpdateWithAllValuesDuringPopulation() { // GIVEN WithPopulator(IndexProvider.getPopulator(Descriptor, IndexSamplingConfig, heapBufferFactory(1024)), p => { using (IndexUpdater updater = p.newPopulatingUpdater(this.valueSet1Lookup)) { foreach (NodeAndValue entry in ValueSet1) { updater.Process(add(entry.NodeId, Descriptor.schema(), entry.Value)); } } }); // THEN AssertHasAllValues(ValueSet1); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNonApplicableUpdaterDoNotUpdatePopulator() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException, org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestNonApplicableUpdaterDoNotUpdatePopulator() { IndexUpdater indexUpdater1 = mock(typeof(IndexUpdater)); IndexPopulator indexPopulator1 = CreateIndexPopulator(indexUpdater1); AddPopulator(indexPopulator1, 2); IndexUpdater multipleIndexUpdater = _multipleIndexPopulator.newPopulatingUpdater(mock(typeof(NodePropertyAccessor))); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> propertyUpdate = createIndexEntryUpdate(index1); IndexEntryUpdate <object> propertyUpdate = CreateIndexEntryUpdate(_index1); multipleIndexUpdater.Process(propertyUpdate); verifyZeroInteractions(indexUpdater1); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSampleUpdatesIfConfiguredForOnlineSampling() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSampleUpdatesIfConfiguredForOnlineSampling() { // GIVEN try { outerInstance.populator.create(); IndexEntryUpdate <IndexDescriptor>[] scanUpdates = valueCreatorUtil.someUpdates(random); outerInstance.populator.add(Arrays.asList(scanUpdates)); IEnumerator <IndexEntryUpdate <IndexDescriptor> > generator = valueCreatorUtil.randomUpdateGenerator(random); Value[] updates = new Value[5]; //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: updates[0] = generator.next().values()[0]; //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: updates[1] = generator.next().values()[0]; updates[2] = updates[1]; //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: updates[3] = generator.next().values()[0]; updates[4] = updates[3]; using (IndexUpdater updater = outerInstance.populator.newPopulatingUpdater(NullPropertyAccessor)) { long nodeId = 1000; foreach (Value value in updates) { IndexEntryUpdate <IndexDescriptor> update = valueCreatorUtil.add(nodeId++, value); updater.Process(update); } } // WHEN outerInstance.populator.scanCompleted(nullInstance); IndexSample sample = outerInstance.populator.sampleResult(); // THEN Value[] allValues = Arrays.copyOf(updates, updates.Length + scanUpdates.Length); Array.Copy(AsValues(scanUpdates), 0, allValues, updates.Length, scanUpdates.Length); assertEquals(updates.Length + scanUpdates.Length, sample.SampleSize()); assertEquals(countUniqueValues(allValues), sample.UniqueValues()); assertEquals(updates.Length + scanUpdates.Length, sample.IndexSize()); } finally { outerInstance.populator.close(true); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPropertyUpdateFailure() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException, org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestPropertyUpdateFailure() { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> propertyUpdate = createIndexEntryUpdate(index1); IndexEntryUpdate <object> propertyUpdate = CreateIndexEntryUpdate(_index1); IndexUpdater indexUpdater1 = mock(typeof(IndexUpdater)); IndexPopulator indexPopulator1 = CreateIndexPopulator(indexUpdater1); AddPopulator(indexPopulator1, 1); doThrow(PopulatorException).when(indexUpdater1).process(propertyUpdate); IndexUpdater multipleIndexUpdater = _multipleIndexPopulator.newPopulatingUpdater(mock(typeof(NodePropertyAccessor))); multipleIndexUpdater.Process(propertyUpdate); verify(indexUpdater1).close(); CheckPopulatorFailure(indexPopulator1); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void updaterShouldApplyDuplicateValues() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void UpdaterShouldApplyDuplicateValues() { // given outerInstance.populator.create(); IndexEntryUpdate <IndexDescriptor>[] updates = valueCreatorUtil.someUpdatesWithDuplicateValues(random); using (IndexUpdater updater = outerInstance.populator.newPopulatingUpdater(NullPropertyAccessor)) { // when foreach (IndexEntryUpdate <IndexDescriptor> update in updates) { updater.Process(update); } } // then outerInstance.populator.scanCompleted(nullInstance); outerInstance.populator.close(true); verifyUpdates(updates); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void updaterMustThrowIfProcessAfterClose() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void UpdaterMustThrowIfProcessAfterClose() { // given Populator.create(); IndexUpdater updater = Populator.newPopulatingUpdater(NullPropertyAccessor); // when updater.Close(); // then try { updater.Process(valueCreatorUtil.add(1, Values.of(long.MaxValue))); fail("Expected process to throw on closed updater"); } catch (System.InvalidOperationException) { // good } Populator.close(true); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void applyInterleaved(org.neo4j.kernel.api.index.IndexEntryUpdate<org.neo4j.storageengine.api.schema.IndexDescriptor>[] updates, NativeIndexPopulator<KEY,VALUE> populator) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private void ApplyInterleaved(IndexEntryUpdate <IndexDescriptor>[] updates, NativeIndexPopulator <KEY, VALUE> populator) { bool useUpdater = true; ICollection <IndexEntryUpdate <IndexDescriptor> > populatorBatch = new List <IndexEntryUpdate <IndexDescriptor> >(); IndexUpdater updater = populator.NewPopulatingUpdater(NullPropertyAccessor); foreach (IndexEntryUpdate <IndexDescriptor> update in updates) { if (random.Next(100) < 20) { if (useUpdater) { updater.Close(); populatorBatch = new List <IndexEntryUpdate <IndexDescriptor> >(); } else { populator.Add(populatorBatch); updater = populator.NewPopulatingUpdater(NullPropertyAccessor); } useUpdater = !useUpdater; } if (useUpdater) { updater.Process(update); } else { populatorBatch.Add(update); } } if (useUpdater) { updater.Close(); } else { populator.Add(populatorBatch); } }
//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 target a bug around minimal splitter in gbpTree and unique index populator. It goes like this: /// Given a set of updates (value,entityId): /// - ("A01",1), ("A90",3), ("A9",2) /// If ("A01",1) and ("A90",3) would cause a split to occur they would produce a minimal splitter ("A9",3). /// Note that the value in this minimal splitter is equal to our last update ("A9",2). /// When making insertions with the unique populator we don't compare entityId which would means ("A9",2) /// ends up to the right of ("A9",3), even though it belongs to the left because of entityId being smaller. /// At this point the tree is in an inconsistent (key on wrong side of splitter). /// /// To work around this problem the entityId is only kept in minimal splitter if strictly necessary to divide /// left from right. This means the minimal splitter between ("A01",1) and ("A90",3) is ("A9",-1) and ("A9",2) /// will correctly be placed on the right side of this splitter. /// /// To trigger this scenario this test first insert a bunch of values that are all unique and that will cause a /// split to happen. This is the firstBatch. /// The second batch are constructed so that at least one of them will have a value equal to the splitter key /// constructed during the firstBatch. /// It's important that the secondBatch has ids that are lower than the first batch to align with example described above. /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPopulateAndRemoveEntriesWithSimilarMinimalSplitter() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPopulateAndRemoveEntriesWithSimilarMinimalSplitter() { string prefix = "Work out your own salvation. Do not depend on others. "; int nbrOfNodes = 200; long nodeId = 0; // Second batch has lower ids IList <NodeAndValue> secondBatch = new List <NodeAndValue>(); for (int i = 0; i < nbrOfNodes; i++) { secondBatch.Add(new NodeAndValue(nodeId++, stringValue(prefix + i))); } // First batch has higher ids and minimal splitter among values in first batch will be found among second batch IList <NodeAndValue> firstBatch = new List <NodeAndValue>(); for (int i = 0; i < nbrOfNodes; i++) { firstBatch.Add(new NodeAndValue(nodeId++, stringValue(prefix + i + " " + i))); } WithPopulator(IndexProvider.getPopulator(Descriptor, IndexSamplingConfig, heapBufferFactory(1024)), p => { p.add(Updates(firstBatch)); p.add(Updates(secondBatch)); // Index should be consistent }); IList <NodeAndValue> toRemove = new List <NodeAndValue>(); ((IList <NodeAndValue>)toRemove).AddRange(firstBatch); ((IList <NodeAndValue>)toRemove).AddRange(secondBatch); Collections.shuffle(toRemove); // And we should be able to remove the entries in any order using (IndexAccessor accessor = IndexProvider.getOnlineAccessor(Descriptor, IndexSamplingConfig)) { // WHEN using (IndexUpdater updater = accessor.NewUpdater(IndexUpdateMode.ONLINE)) { foreach (NodeAndValue nodeAndValue in toRemove) { updater.Process(IndexEntryUpdate.Remove(nodeAndValue.NodeId, Descriptor, nodeAndValue.Value)); } } // THEN using (IndexReader reader = new QueryResultComparingIndexReader(accessor.NewReader())) { int propertyKeyId = Descriptor.schema().PropertyId; foreach (NodeAndValue nodeAndValue in toRemove) { NodeValueIterator nodes = new NodeValueIterator(); reader.Query(nodes, IndexOrder.NONE, false, IndexQuery.exact(propertyKeyId, nodeAndValue.Value)); bool anyHits = false; StringJoiner nodesStillLeft = new StringJoiner(", ", "[", "]"); while (nodes.HasNext()) { anyHits = true; nodesStillLeft.add(Convert.ToString(nodes.Next())); } assertFalse("Expected this query to have zero hits but found " + nodesStillLeft.ToString(), anyHits); } } } }