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);
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class Neo4jTransactionalContextFactory method create.
@Deprecated
public static TransactionalContextFactory create(GraphDatabaseQueryService queryService, PropertyContainerLocker locker) {
DependencyResolver resolver = queryService.getDependencyResolver();
ThreadToStatementContextBridge txBridge = resolver.resolveDependency(ThreadToStatementContextBridge.class);
Guard guard = resolver.resolveDependency(Guard.class);
Neo4jTransactionalContext.Creator contextCreator = (Supplier<Statement> statementSupplier, InternalTransaction tx, Statement initialStatement, ExecutingQuery executingQuery) -> new Neo4jTransactionalContext(queryService, statementSupplier, guard, txBridge, locker, tx, initialStatement, executingQuery);
return new Neo4jTransactionalContextFactory(txBridge, contextCreator);
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class Neo4jTransactionalContextFactory method newContext.
@Override
public final Neo4jTransactionalContext newContext(ClientConnectionInfo clientConnection, InternalTransaction tx, String queryText, Map<String, Object> queryParameters) {
Statement initialStatement = statementSupplier.get();
ClientConnectionInfo connectionWithUserName = clientConnection.withUsername(tx.securityContext().subject().username());
ExecutingQuery executingQuery = initialStatement.queryRegistration().startQueryExecution(connectionWithUserName, queryText, queryParameters);
return contextCreator.create(statementSupplier, tx, initialStatement, executingQuery);
}
Aggregations