use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class IndexStatisticsTest method dropIndex.
private void dropIndex(NewIndexDescriptor index) throws KernelException {
try (Transaction tx = db.beginTx()) {
Statement statement = bridge.get();
statement.schemaWriteOperations().indexDrop(index);
tx.success();
}
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class IndexIT method committedAndTransactionalIndexRulesShouldBeMerged.
@Test
public void committedAndTransactionalIndexRulesShouldBeMerged() throws Exception {
// GIVEN
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
NewIndexDescriptor existingRule = schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
commit();
// WHEN
Statement statement = statementInNewTransaction(AnonymousContext.AUTH_DISABLED);
NewIndexDescriptor addedRule = statement.schemaWriteOperations().indexCreate(SchemaDescriptorFactory.forLabel(labelId, 10));
Set<NewIndexDescriptor> indexRulesInTx = asSet(statement.readOperations().indexesGetForLabel(labelId));
commit();
// THEN
assertEquals(asSet(existingRule, addedRule), indexRulesInTx);
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class SchemaImpl method getConstraints.
@Override
public Iterable<ConstraintDefinition> getConstraints(RelationshipType type) {
actions.assertInOpenTransaction();
try (Statement statement = statementContextSupplier.get()) {
int typeId = statement.readOperations().relationshipTypeGetForName(type.name());
if (typeId == KeyReadOperations.NO_SUCH_RELATIONSHIP_TYPE) {
return emptyList();
}
Iterator<ConstraintDescriptor> constraints = statement.readOperations().constraintsGetForRelationshipType(typeId);
return asConstraintDefinitions(constraints, statement.readOperations());
}
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class SchemaImpl method getIndexes.
@Override
public Iterable<IndexDefinition> getIndexes() {
try (Statement statement = statementContextSupplier.get()) {
List<IndexDefinition> definitions = new ArrayList<>();
addDefinitions(definitions, statement.readOperations(), statement.readOperations().indexesGetAll(), false);
addDefinitions(definitions, statement.readOperations(), statement.readOperations().uniqueIndexesGetAll(), true);
return definitions;
}
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class GraphDatabaseFacade method nodesByLabelAndProperty.
private ResourceIterator<Node> nodesByLabelAndProperty(Label myLabel, String key, Object value) {
Statement statement = spi.currentStatement();
ReadOperations readOps = statement.readOperations();
int propertyId = readOps.propertyKeyGetForName(key);
int labelId = readOps.labelGetForName(myLabel.name());
if (propertyId == NO_SUCH_PROPERTY_KEY || labelId == NO_SUCH_LABEL) {
statement.close();
return emptyIterator();
}
NewIndexDescriptor descriptor = findAnyIndexByLabelAndProperty(readOps, propertyId, labelId);
try {
if (null != descriptor) {
// Ha! We found an index - let's use it to find matching nodes
IndexQuery.ExactPredicate query = IndexQuery.exact(descriptor.schema().getPropertyId(), value);
return map2nodes(readOps.indexQuery(descriptor, query), statement);
}
} catch (KernelException e) {
// weird at this point but ignore and fallback to a label scan
}
return getNodesByLabelAndPropertyWithoutIndex(propertyId, value, statement, labelId);
}
Aggregations