use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.
the class RemoveOrphanConstraintIndexesOnStartup method perform.
public void perform() {
try (KernelTransaction transaction = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
Statement statement = transaction.acquireStatement()) {
for (NewIndexDescriptor index : loop(statement.readOperations().uniqueIndexesGetAll())) {
if (statement.readOperations().indexGetOwningUniquenessConstraintId(index) == null) {
log.info("Removing orphan constraint index: " + index);
statement.schemaWriteOperations().uniqueIndexDrop(index);
}
}
transaction.success();
} catch (KernelException e) {
log.error("Failed to execute orphan index checking transaction.", e);
}
}
use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.
the class StateHandlingStatementOperations method indexCreate.
@Override
public NewIndexDescriptor indexCreate(KernelStatement state, LabelSchemaDescriptor descriptor) {
NewIndexDescriptor indexDescriptor = NewIndexDescriptorFactory.forSchema(descriptor);
state.txState().indexRuleDoAdd(indexDescriptor);
return indexDescriptor;
}
use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.
the class SchemaImpl method getIndexPopulationProgress.
@Override
public IndexPopulationProgress getIndexPopulationProgress(IndexDefinition index) {
actions.assertInOpenTransaction();
try (Statement statement = statementContextSupplier.get()) {
ReadOperations readOps = statement.readOperations();
NewIndexDescriptor descriptor = getIndexDescriptor(readOps, index);
PopulationProgress progress = readOps.indexGetPopulationProgress(descriptor);
return new IndexPopulationProgress(progress.getCompleted(), progress.getTotal());
} catch (SchemaRuleNotFoundException | IndexNotFoundKernelException e) {
throw new NotFoundException(format("No index for label %s on property %s", index.getLabel().name(), index.getPropertyKeys()));
}
}
use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.
the class SchemaImpl method getIndexState.
@Override
public IndexState getIndexState(final IndexDefinition index) {
actions.assertInOpenTransaction();
try (Statement statement = statementContextSupplier.get()) {
ReadOperations readOps = statement.readOperations();
NewIndexDescriptor descriptor = getIndexDescriptor(readOps, index);
InternalIndexState indexState = readOps.indexGetState(descriptor);
switch(indexState) {
case POPULATING:
return POPULATING;
case ONLINE:
return ONLINE;
case FAILED:
return FAILED;
default:
throw new IllegalArgumentException(String.format("Illegal index state %s", indexState));
}
} catch (SchemaRuleNotFoundException | IndexNotFoundKernelException e) {
throw new NotFoundException(format("No index for label %s on property %s", index.getLabel().name(), index.getPropertyKeys()));
}
}
use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.
the class SchemaImpl method getIndexFailure.
@Override
public String getIndexFailure(IndexDefinition index) {
actions.assertInOpenTransaction();
try (Statement statement = statementContextSupplier.get()) {
ReadOperations readOps = statement.readOperations();
NewIndexDescriptor descriptor = getIndexDescriptor(readOps, index);
return readOps.indexGetFailure(descriptor);
} catch (SchemaRuleNotFoundException | IndexNotFoundKernelException e) {
throw new NotFoundException(format("No index for label %s on property %s", index.getLabel().name(), index.getPropertyKeys()));
}
}
Aggregations