use of org.neo4j.kernel.api.index.IndexEntryUpdate.add in project neo4j by neo4j.
the class SimpleIndexPopulatorCompatibility method shouldApplyUpdatesIdempotently.
@Test
public void shouldApplyUpdatesIdempotently() throws Exception {
// GIVEN
IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.empty());
IndexPopulator populator = indexProvider.getPopulator(17, descriptor, indexSamplingConfig);
populator.create();
populator.configureSampling(true);
long nodeId = 1;
final String propertyValue = "value1";
PropertyAccessor propertyAccessor = (nodeId1, propertyKeyId) -> Property.stringProperty(propertyKeyId, propertyValue);
// this update (using add())...
populator.add(singletonList(IndexEntryUpdate.add(nodeId, descriptor.schema(), propertyValue)));
// ...is the same as this update (using update())
try (IndexUpdater updater = populator.newPopulatingUpdater(propertyAccessor)) {
updater.process(add(nodeId, descriptor.schema(), propertyValue));
}
populator.close(true);
// then
IndexAccessor accessor = indexProvider.getOnlineAccessor(17, descriptor, indexSamplingConfig);
try (IndexReader reader = accessor.newReader()) {
int propertyKeyId = descriptor.schema().getPropertyId();
PrimitiveLongIterator nodes = reader.query(IndexQuery.exact(propertyKeyId, propertyValue));
assertEquals(asSet(1L), PrimitiveLongCollections.toSet(nodes));
}
accessor.close();
}
Aggregations