use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.
the class IndexAccessorCompatibility method before.
@Before
public void before() throws Exception {
IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
IndexPopulator populator = indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup);
populator.create();
populator.close(true, NULL);
accessor = indexProvider.getOnlineAccessor(descriptor, indexSamplingConfig, tokenNameLookup);
}
use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.
the class SimpleIndexPopulatorCompatibility method shouldApplyUpdatesIdempotently.
@Test
public void shouldApplyUpdatesIdempotently() throws Exception {
// GIVEN
IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
final Value propertyValue = Values.of("value1");
withPopulator(indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup), p -> {
long nodeId = 1;
// update using populator...
IndexEntryUpdate<SchemaDescriptor> update = add(nodeId, descriptor.schema(), propertyValue);
p.add(singletonList(update), NULL);
// ...is the same as update using updater
try (IndexUpdater updater = p.newPopulatingUpdater((node, propertyId, cursorContext) -> propertyValue, NULL)) {
updater.process(update);
}
});
// THEN
try (IndexAccessor accessor = indexProvider.getOnlineAccessor(descriptor, indexSamplingConfig, tokenNameLookup)) {
try (ValueIndexReader reader = accessor.newValueReader();
NodeValueIterator nodes = new NodeValueIterator()) {
int propertyKeyId = descriptor.schema().getPropertyId();
reader.query(NULL_CONTEXT, nodes, unconstrained(), PropertyIndexQuery.exact(propertyKeyId, propertyValue));
assertEquals(asSet(1L), PrimitiveLongCollections.toSet(nodes));
}
}
}
use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.
the class SimpleIndexPopulatorCompatibility method shouldStorePopulationFailedForRetrievalFromProviderLater.
@Test
public void shouldStorePopulationFailedForRetrievalFromProviderLater() throws Exception {
// GIVEN
String failure = "The contrived failure";
IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
// WHEN (this will attempt to call close)
withPopulator(indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup), p -> p.markAsFailed(failure), false);
// THEN
assertThat(indexProvider.getPopulationFailure(descriptor, NULL)).contains(failure);
}
use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.
the class TokenIndexPopulatorCompatibility method shouldBeAbleToDropAClosedIndexPopulator.
@Test
public void shouldBeAbleToDropAClosedIndexPopulator() {
// GIVEN
IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
final IndexPopulator p = indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup);
p.close(false, NULL);
// WHEN
p.drop();
// THEN - no exception should be thrown (it's been known to!)
}
use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.
the class TokenIndexPopulatorCompatibility method shouldStorePopulationFailedForRetrievalFromProviderLater.
@Test
public void shouldStorePopulationFailedForRetrievalFromProviderLater() throws Exception {
// GIVEN
String failure = "The contrived failure";
IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
// WHEN (this will attempt to call close)
withPopulator(indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup), p -> p.markAsFailed(failure), false);
// THEN
assertThat(indexProvider.getPopulationFailure(descriptor, NULL)).contains(failure);
}
Aggregations