use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method checkIndexIsOnline.
private void checkIndexIsOnline(int labelId) throws IndexNotFoundKernelException {
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyId);
IndexDescriptor index = single(schemaCache.indexesForSchema(schema));
IndexProxy indexProxy = indexService.getIndexProxy(index);
assertSame(InternalIndexState.ONLINE, indexProxy.getState());
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method indexDroppedDuringPopulationDoesNotExist.
@ParameterizedTest
@MethodSource("parameters")
void indexDroppedDuringPopulationDoesNotExist(GraphDatabaseSettings.SchemaIndex schemaIndex) throws Throwable {
Integer labelToDropId = labelsNameIdMap.get(COLOR_LABEL);
launchCustomIndexPopulation(schemaIndex, labelsNameIdMap, propertyId, new IndexDropAction(labelToDropId));
labelsNameIdMap.remove(COLOR_LABEL);
waitAndActivateIndexes(labelsNameIdMap, propertyId);
assertThrows(IndexNotFoundKernelException.class, () -> {
Iterator<IndexDescriptor> iterator = schemaCache.indexesForSchema(SchemaDescriptor.forLabel(labelToDropId, propertyId));
while (iterator.hasNext()) {
IndexDescriptor index = iterator.next();
indexService.getIndexProxy(index);
}
});
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method createIndexRules.
private IndexDescriptor[] createIndexRules(GraphDatabaseSettings.SchemaIndex schemaIndex, Map<String, Integer> labelNameIdMap, int propertyId) {
final IndexProviderMap indexProviderMap = getIndexProviderMap();
IndexProvider indexProvider = indexProviderMap.lookup(schemaIndex.providerName());
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
List<IndexDescriptor> list = new ArrayList<>();
for (Integer labelId : labelNameIdMap.values()) {
final LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyId);
IndexDescriptor index = IndexPrototype.forSchema(schema, providerDescriptor).withName("index_" + labelId).materialise(labelId);
index = indexProvider.completeConfiguration(index);
list.add(index);
}
return list.toArray(new IndexDescriptor[0]);
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method waitIndexOnline.
private void waitIndexOnline(IndexingService indexService, int propertyId, int labelId) throws IndexNotFoundKernelException, IndexPopulationFailedKernelException, InterruptedException, IndexActivationFailedKernelException {
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyId);
IndexDescriptor index = single(schemaCache.indexesForSchema(schema));
IndexProxy indexProxy = indexService.getIndexProxy(index);
indexProxy.awaitStoreScanCompleted(0, TimeUnit.MILLISECONDS);
while (indexProxy.getState() != InternalIndexState.ONLINE) {
Thread.sleep(10);
}
indexProxy.activate();
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class NodeScanIT method trackPageCacheAccessOnNodeLabelScan.
@Test
void trackPageCacheAccessOnNodeLabelScan() throws KernelException {
var testLabel = Label.label("testLabel");
try (KernelTransaction tx = kernel.beginTransaction(IMPLICIT, read())) {
var cursorContext = tx.cursorContext();
assertThat(cursorContext.getCursorTracer().pins()).isZero();
var label = tx.tokenRead().nodeLabel(testLabel.name());
IndexDescriptor index = tx.schemaRead().index(SchemaDescriptor.forAnyEntityTokens(EntityType.NODE)).next();
TokenReadSession tokenReadSession = tx.dataRead().tokenReadSession(index);
try (NodeLabelIndexCursor cursor = tx.cursors().allocateNodeLabelIndexCursor(cursorContext)) {
tx.dataRead().nodeLabelScan(tokenReadSession, cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(label));
assertThat(cursorContext.getCursorTracer().pins()).isNotZero();
}
}
}
Aggregations