use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class StorageLayerTest method readOps.
protected ReadOperations readOps() {
DependencyResolver dependencyResolver = db.getDependencyResolver();
Statement statement = dependencyResolver.resolveDependency(ThreadToStatementContextBridge.class).get();
return statement.readOperations();
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class NeoStoreIndexStoreViewTest method getOrCreateIds.
private void getOrCreateIds() throws KernelException {
try (Transaction tx = graphDb.beginTx()) {
ThreadToStatementContextBridge bridge = graphDb.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
try (Statement statement = bridge.get()) {
labelId = statement.tokenWriteOperations().labelGetOrCreateForName("Person");
propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName("name");
}
tx.success();
}
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class BuiltInProcedures method listConstraints.
@Description("List all constraints in the database.")
@Procedure(name = "db.constraints", mode = READ)
public Stream<ConstraintResult> listConstraints() {
Statement statement = tx.acquireStatement();
ReadOperations operations = statement.readOperations();
TokenNameLookup tokens = new StatementTokenNameLookup(operations);
return asList(operations.constraintsGetAll()).stream().map((constraint) -> constraint.prettyPrint(tokens)).sorted().map(ConstraintResult::new).onClose(statement::close);
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class IndexPopulationJobTest method before.
@Before
public void before() throws Exception {
db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase();
kernel = db.getDependencyResolver().resolveDependency(KernelAPI.class);
stateHolder = new KernelSchemaStateStore(NullLogProvider.getInstance());
indexStoreView = indexStoreView();
try (KernelTransaction tx = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
Statement statement = tx.acquireStatement()) {
labelId = statement.tokenWriteOperations().labelGetOrCreateForName(FIRST.name());
statement.tokenWriteOperations().labelGetOrCreateForName(SECOND.name());
tx.success();
}
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class IndexRecoveryIT method createSomeBananas.
private Set<IndexEntryUpdate> createSomeBananas(Label label) {
Set<IndexEntryUpdate> updates = new HashSet<>();
try (Transaction tx = db.beginTx()) {
ThreadToStatementContextBridge ctxSupplier = db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
try (Statement statement = ctxSupplier.get()) {
int labelId = statement.readOperations().labelGetForName(label.name());
int propertyKeyId = statement.readOperations().propertyKeyGetForName(key);
LabelSchemaDescriptor schemaDescriptor = SchemaDescriptorFactory.forLabel(labelId, propertyKeyId);
for (int number : new int[] { 4, 10 }) {
Node node = db.createNode(label);
node.setProperty(key, number);
updates.add(IndexEntryUpdate.add(node.getId(), schemaDescriptor, number));
}
}
tx.success();
return updates;
}
}
Aggregations