use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaImplMockTest method mockKernelTransaction.
private static KernelTransaction mockKernelTransaction() throws IndexNotFoundKernelException {
SchemaRead schemaRead = mock(SchemaRead.class);
when(schemaRead.indexGetState(any(IndexDescriptor.class))).thenReturn(InternalIndexState.FAILED);
when(schemaRead.indexGetFailure(any(IndexDescriptor.class))).thenReturn(Exceptions.stringify(cause));
KernelTransaction kt = mock(KernelTransaction.class);
when(kt.tokenRead()).thenReturn(mock(TokenRead.class));
when(kt.schemaRead()).thenReturn(schemaRead);
when(kt.isTerminated()).thenReturn(false);
return kt;
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class BatchInsertIndexTest method batchInserterShouldUseConfiguredIndexProvider.
@ParameterizedTest
@EnumSource(SchemaIndex.class)
void batchInserterShouldUseConfiguredIndexProvider(SchemaIndex schemaIndex) throws Exception {
configure(schemaIndex);
BatchInserter inserter = newBatchInserter();
inserter.createDeferredSchemaIndex(LABEL_ONE).on("key").create();
inserter.shutdown();
GraphDatabaseService db = startGraphDatabaseServiceAndAwaitIndexes();
try (Transaction tx = db.beginTx()) {
KernelTransaction kernelTransaction = ((InternalTransaction) tx).kernelTransaction();
TokenRead tokenRead = kernelTransaction.tokenRead();
SchemaRead schemaRead = kernelTransaction.schemaRead();
int labelId = tokenRead.nodeLabel(LABEL_ONE.name());
int propertyId = tokenRead.propertyKey("key");
IndexDescriptor index = single(schemaRead.index(SchemaDescriptor.forLabel(labelId, propertyId)));
assertTrue(schemaIndex.providerName().contains(index.getIndexProvider().getKey()), unexpectedIndexProviderMessage(index));
assertTrue(schemaIndex.providerName().contains(index.getIndexProvider().getVersion()), unexpectedIndexProviderMessage(index));
tx.commit();
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaImpl method getIndexPopulationProgress.
@Override
public IndexPopulationProgress getIndexPopulationProgress(IndexDefinition index) {
try {
transaction.assertOpen();
SchemaRead schemaRead = transaction.schemaRead();
IndexDescriptor descriptor = getIndexReference(schemaRead, transaction.tokenRead(), (IndexDefinitionImpl) index);
PopulationProgress progress = schemaRead.indexGetPopulationProgress(descriptor);
return progress.toIndexPopulationProgress();
} catch (KernelException e) {
throw newIndexNotFoundException(index, e);
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaImpl method getIndexes.
@Override
public Iterable<IndexDefinition> getIndexes(final Label label) {
transaction.assertOpen();
TokenRead tokenRead = transaction.tokenRead();
SchemaRead schemaRead = transaction.schemaRead();
List<IndexDefinition> definitions = new ArrayList<>();
int labelId = tokenRead.nodeLabel(label.name());
if (labelId == TokenRead.NO_TOKEN) {
return emptyList();
}
Iterator<IndexDescriptor> indexes = schemaRead.indexesGetForLabel(labelId);
addDefinitions(definitions, tokenRead, IndexDescriptor.sortByType(indexes));
return definitions;
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaImpl method getIndexFailure.
@Override
public String getIndexFailure(IndexDefinition index) {
try {
transaction.assertOpen();
SchemaRead schemaRead = transaction.schemaRead();
IndexDescriptor descriptor = getIndexReference(schemaRead, transaction.tokenRead(), (IndexDefinitionImpl) index);
return schemaRead.indexGetFailure(descriptor);
} catch (KernelException e) {
throw newIndexNotFoundException(index, e);
}
}
Aggregations