use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class NodeProxy method getPropertyKeys.
@Override
public Iterable<String> getPropertyKeys() {
try (Statement statement = actions.statement()) {
List<String> keys = new ArrayList<>();
PrimitiveIntIterator properties = statement.readOperations().nodeGetPropertyKeys(getId());
while (properties.hasNext()) {
keys.add(statement.readOperations().propertyKeyGetName(properties.next()));
}
return keys;
} catch (EntityNotFoundException e) {
throw new NotFoundException("Node not found", e);
} catch (PropertyKeyIdNotFoundKernelException e) {
throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
}
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class GraphPropertiesProxy method getProperties.
@Override
public Map<String, Object> getProperties(String... names) {
try (Statement statement = actions.statement()) {
Map<String, Object> properties = new HashMap<>();
ReadOperations readOperations = statement.readOperations();
for (String name : names) {
int propertyKeyId = readOperations.propertyKeyGetForName(name);
Object value = readOperations.graphGetProperty(propertyKeyId);
if (value != null) {
properties.put(name, value);
}
}
return properties;
}
}
use of org.neo4j.kernel.api.Statement 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.Statement 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.Statement in project neo4j by neo4j.
the class GraphDatabaseFacade method init.
/**
* Create a new Core API facade, backed by the given SPI and using pre-resolved dependencies
*/
public void init(SPI spi, Guard guard, ThreadToStatementContextBridge txBridge, Config config) {
this.spi = spi;
this.defaultTransactionTimeout = config.get(GraphDatabaseSettings.transaction_timeout);
Supplier<Statement> statementSupplier = spi::currentStatement;
Supplier<KernelTransaction> transactionSupplier = spi::currentTransaction;
ThrowingAction<RuntimeException> assertTransactionOpen = this::assertTransactionOpen;
this.schema = new SchemaImpl(statementSupplier);
this.relActions = new StandardRelationshipActions(statementSupplier, transactionSupplier, assertTransactionOpen, (id) -> new NodeProxy(nodeActions, id), this);
this.nodeActions = new StandardNodeActions(statementSupplier, transactionSupplier, assertTransactionOpen, relActions, this);
this.indexManager = Suppliers.lazySingleton(() -> {
IndexProviderImpl idxProvider = new IndexProviderImpl(this, statementSupplier);
AutoIndexerFacade<Node> nodeAutoIndexer = new AutoIndexerFacade<>(() -> new ReadOnlyIndexFacade<>(idxProvider.getOrCreateNodeIndex(NODE_AUTO_INDEX, null)), spi.autoIndexing().nodes());
RelationshipAutoIndexerFacade relAutoIndexer = new RelationshipAutoIndexerFacade(() -> new ReadOnlyRelationshipIndexFacade(idxProvider.getOrCreateRelationshipIndex(RELATIONSHIP_AUTO_INDEX, null)), spi.autoIndexing().relationships());
return new IndexManagerImpl(statementSupplier, idxProvider, nodeAutoIndexer, relAutoIndexer);
});
this.contextFactory = Neo4jTransactionalContextFactory.create(spi, guard, txBridge, locker);
}
Aggregations