Search in sources :

Example 1 with NodeProxy

use of org.neo4j.kernel.impl.core.NodeProxy 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);
}
Also used : InternalIndexState(org.neo4j.kernel.api.index.InternalIndexState) StoreId(org.neo4j.kernel.impl.store.StoreId) RELATIONSHIP_AUTO_INDEX(org.neo4j.kernel.impl.api.legacyindex.InternalAutoIndexing.RELATIONSHIP_AUTO_INDEX) ResourceIterator(org.neo4j.graphdb.ResourceIterator) Suppliers(org.neo4j.function.Suppliers) ResourceClosingIterator(org.neo4j.helpers.collection.ResourceClosingIterator) URL(java.net.URL) ResourceIterable(org.neo4j.graphdb.ResourceIterable) Status(org.neo4j.kernel.api.exceptions.Status) TransactionEventHandler(org.neo4j.graphdb.event.TransactionEventHandler) TopLevelTransaction(org.neo4j.kernel.impl.coreapi.TopLevelTransaction) Statement(org.neo4j.kernel.api.Statement) Property(org.neo4j.kernel.api.properties.Property) RelationshipProxy(org.neo4j.kernel.impl.core.RelationshipProxy) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) RelationshipAutoIndexerFacade(org.neo4j.kernel.impl.coreapi.RelationshipAutoIndexerFacade) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) NODE_AUTO_INDEX(org.neo4j.kernel.impl.api.legacyindex.InternalAutoIndexing.NODE_AUTO_INDEX) AutoIndexerFacade(org.neo4j.kernel.impl.coreapi.AutoIndexerFacade) Map(java.util.Map) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) Transaction(org.neo4j.graphdb.Transaction) TransactionalContextFactory(org.neo4j.kernel.impl.query.TransactionalContextFactory) QueryExecutionException(org.neo4j.graphdb.QueryExecutionException) PrefetchingResourceIterator(org.neo4j.helpers.collection.PrefetchingResourceIterator) KernelEventHandler(org.neo4j.graphdb.event.KernelEventHandler) BidirectionalTraversalDescriptionImpl(org.neo4j.kernel.impl.traversal.BidirectionalTraversalDescriptionImpl) Result(org.neo4j.graphdb.Result) URLAccessValidationError(org.neo4j.graphdb.security.URLAccessValidationError) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) IndexProviderImpl(org.neo4j.kernel.impl.coreapi.IndexProviderImpl) BidirectionalTraversalDescription(org.neo4j.graphdb.traversal.BidirectionalTraversalDescription) InvalidTransactionTypeKernelException(org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException) KernelException(org.neo4j.kernel.api.exceptions.KernelException) StandardRelationshipActions(org.neo4j.kernel.impl.coreapi.StandardRelationshipActions) String.format(java.lang.String.format) Schema(org.neo4j.graphdb.schema.Schema) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) NO_SUCH_LABEL(org.neo4j.kernel.impl.api.operations.KeyReadOperations.NO_SUCH_LABEL) TransactionTerminatedException(org.neo4j.graphdb.TransactionTerminatedException) IndexManager(org.neo4j.graphdb.index.IndexManager) Neo4jTransactionalContextFactory(org.neo4j.kernel.impl.query.Neo4jTransactionalContextFactory) Optional(java.util.Optional) DependencyResolver(org.neo4j.graphdb.DependencyResolver) RelationshipType(org.neo4j.graphdb.RelationshipType) GraphDatabaseSettings(org.neo4j.graphdb.factory.GraphDatabaseSettings) Guard(org.neo4j.kernel.guard.Guard) Label(org.neo4j.graphdb.Label) PlaceboTransaction(org.neo4j.kernel.impl.coreapi.PlaceboTransaction) TransactionalContext(org.neo4j.kernel.impl.query.TransactionalContext) SchemaImpl(org.neo4j.kernel.impl.coreapi.schema.SchemaImpl) EntityType(org.neo4j.storageengine.api.EntityType) StandardNodeActions(org.neo4j.kernel.impl.coreapi.StandardNodeActions) SchemaKernelException(org.neo4j.kernel.api.exceptions.schema.SchemaKernelException) MonoDirectionalTraversalDescription(org.neo4j.kernel.impl.traversal.MonoDirectionalTraversalDescription) NotFoundException(org.neo4j.graphdb.NotFoundException) Supplier(java.util.function.Supplier) SchemaRuleNotFoundException(org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException) Node(org.neo4j.graphdb.Node) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) IndexManagerImpl(org.neo4j.kernel.impl.coreapi.IndexManagerImpl) ConstraintViolationException(org.neo4j.graphdb.ConstraintViolationException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) SecurityContext(org.neo4j.kernel.api.security.SecurityContext) ReadOnlyRelationshipIndexFacade(org.neo4j.kernel.impl.coreapi.ReadOnlyRelationshipIndexFacade) ThrowingAction(org.neo4j.function.ThrowingAction) NO_SUCH_PROPERTY_KEY(org.neo4j.kernel.impl.api.operations.KeyReadOperations.NO_SUCH_PROPERTY_KEY) TokenAccess(org.neo4j.kernel.impl.api.TokenAccess) AutoIndexing(org.neo4j.kernel.api.legacyindex.AutoIndexing) Config(org.neo4j.kernel.configuration.Config) ReadOnlyIndexFacade(org.neo4j.kernel.impl.coreapi.ReadOnlyIndexFacade) PrimitiveLongCollections(org.neo4j.collection.primitive.PrimitiveLongCollections) ReadOperations(org.neo4j.kernel.api.ReadOperations) IndexQuery(org.neo4j.kernel.api.schema_new.IndexQuery) PrimitiveLongCollections.map(org.neo4j.collection.primitive.PrimitiveLongCollections.map) Iterators.emptyIterator(org.neo4j.helpers.collection.Iterators.emptyIterator) NodeProxy(org.neo4j.kernel.impl.core.NodeProxy) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) File(java.io.File) PropertyContainerLocker(org.neo4j.kernel.impl.coreapi.PropertyContainerLocker) TimeUnit(java.util.concurrent.TimeUnit) TraversalDescription(org.neo4j.graphdb.traversal.TraversalDescription) Relationship(org.neo4j.graphdb.Relationship) AUTH_DISABLED(org.neo4j.kernel.api.security.SecurityContext.AUTH_DISABLED) KeyReadOperations(org.neo4j.kernel.impl.api.operations.KeyReadOperations) MultipleFoundException(org.neo4j.graphdb.MultipleFoundException) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ClientConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.ClientConnectionInfo) ConstraintValidationException(org.neo4j.kernel.api.exceptions.schema.ConstraintValidationException) Collections(java.util.Collections) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) RelationshipAutoIndexerFacade(org.neo4j.kernel.impl.coreapi.RelationshipAutoIndexerFacade) Statement(org.neo4j.kernel.api.Statement) RelationshipAutoIndexerFacade(org.neo4j.kernel.impl.coreapi.RelationshipAutoIndexerFacade) AutoIndexerFacade(org.neo4j.kernel.impl.coreapi.AutoIndexerFacade) ReadOnlyRelationshipIndexFacade(org.neo4j.kernel.impl.coreapi.ReadOnlyRelationshipIndexFacade) IndexProviderImpl(org.neo4j.kernel.impl.coreapi.IndexProviderImpl) NodeProxy(org.neo4j.kernel.impl.core.NodeProxy) StandardNodeActions(org.neo4j.kernel.impl.coreapi.StandardNodeActions) IndexManagerImpl(org.neo4j.kernel.impl.coreapi.IndexManagerImpl) SchemaImpl(org.neo4j.kernel.impl.coreapi.schema.SchemaImpl) StandardRelationshipActions(org.neo4j.kernel.impl.coreapi.StandardRelationshipActions) ReadOnlyIndexFacade(org.neo4j.kernel.impl.coreapi.ReadOnlyIndexFacade)

Example 2 with NodeProxy

use of org.neo4j.kernel.impl.core.NodeProxy in project neo4j by neo4j.

the class GraphDatabaseFacade method allNodesWithLabel.

private ResourceIterator<Node> allNodesWithLabel(final Label myLabel) {
    Statement statement = spi.currentStatement();
    int labelId = statement.readOperations().labelGetForName(myLabel.name());
    if (labelId == KeyReadOperations.NO_SUCH_LABEL) {
        statement.close();
        return emptyIterator();
    }
    final PrimitiveLongIterator nodeIds = statement.readOperations().nodesGetForLabel(labelId);
    return ResourceClosingIterator.newResourceIterator(statement, map(nodeId -> new NodeProxy(nodeActions, nodeId), nodeIds));
}
Also used : PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) InternalIndexState(org.neo4j.kernel.api.index.InternalIndexState) StoreId(org.neo4j.kernel.impl.store.StoreId) RELATIONSHIP_AUTO_INDEX(org.neo4j.kernel.impl.api.legacyindex.InternalAutoIndexing.RELATIONSHIP_AUTO_INDEX) ResourceIterator(org.neo4j.graphdb.ResourceIterator) Suppliers(org.neo4j.function.Suppliers) ResourceClosingIterator(org.neo4j.helpers.collection.ResourceClosingIterator) URL(java.net.URL) ResourceIterable(org.neo4j.graphdb.ResourceIterable) Status(org.neo4j.kernel.api.exceptions.Status) TransactionEventHandler(org.neo4j.graphdb.event.TransactionEventHandler) TopLevelTransaction(org.neo4j.kernel.impl.coreapi.TopLevelTransaction) Statement(org.neo4j.kernel.api.Statement) Property(org.neo4j.kernel.api.properties.Property) RelationshipProxy(org.neo4j.kernel.impl.core.RelationshipProxy) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) RelationshipAutoIndexerFacade(org.neo4j.kernel.impl.coreapi.RelationshipAutoIndexerFacade) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) NODE_AUTO_INDEX(org.neo4j.kernel.impl.api.legacyindex.InternalAutoIndexing.NODE_AUTO_INDEX) AutoIndexerFacade(org.neo4j.kernel.impl.coreapi.AutoIndexerFacade) Map(java.util.Map) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) Transaction(org.neo4j.graphdb.Transaction) TransactionalContextFactory(org.neo4j.kernel.impl.query.TransactionalContextFactory) QueryExecutionException(org.neo4j.graphdb.QueryExecutionException) PrefetchingResourceIterator(org.neo4j.helpers.collection.PrefetchingResourceIterator) KernelEventHandler(org.neo4j.graphdb.event.KernelEventHandler) BidirectionalTraversalDescriptionImpl(org.neo4j.kernel.impl.traversal.BidirectionalTraversalDescriptionImpl) Result(org.neo4j.graphdb.Result) URLAccessValidationError(org.neo4j.graphdb.security.URLAccessValidationError) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) IndexProviderImpl(org.neo4j.kernel.impl.coreapi.IndexProviderImpl) BidirectionalTraversalDescription(org.neo4j.graphdb.traversal.BidirectionalTraversalDescription) InvalidTransactionTypeKernelException(org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException) KernelException(org.neo4j.kernel.api.exceptions.KernelException) StandardRelationshipActions(org.neo4j.kernel.impl.coreapi.StandardRelationshipActions) String.format(java.lang.String.format) Schema(org.neo4j.graphdb.schema.Schema) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) NO_SUCH_LABEL(org.neo4j.kernel.impl.api.operations.KeyReadOperations.NO_SUCH_LABEL) TransactionTerminatedException(org.neo4j.graphdb.TransactionTerminatedException) IndexManager(org.neo4j.graphdb.index.IndexManager) Neo4jTransactionalContextFactory(org.neo4j.kernel.impl.query.Neo4jTransactionalContextFactory) Optional(java.util.Optional) DependencyResolver(org.neo4j.graphdb.DependencyResolver) RelationshipType(org.neo4j.graphdb.RelationshipType) GraphDatabaseSettings(org.neo4j.graphdb.factory.GraphDatabaseSettings) Guard(org.neo4j.kernel.guard.Guard) Label(org.neo4j.graphdb.Label) PlaceboTransaction(org.neo4j.kernel.impl.coreapi.PlaceboTransaction) TransactionalContext(org.neo4j.kernel.impl.query.TransactionalContext) SchemaImpl(org.neo4j.kernel.impl.coreapi.schema.SchemaImpl) EntityType(org.neo4j.storageengine.api.EntityType) StandardNodeActions(org.neo4j.kernel.impl.coreapi.StandardNodeActions) SchemaKernelException(org.neo4j.kernel.api.exceptions.schema.SchemaKernelException) MonoDirectionalTraversalDescription(org.neo4j.kernel.impl.traversal.MonoDirectionalTraversalDescription) NotFoundException(org.neo4j.graphdb.NotFoundException) Supplier(java.util.function.Supplier) SchemaRuleNotFoundException(org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException) Node(org.neo4j.graphdb.Node) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) IndexManagerImpl(org.neo4j.kernel.impl.coreapi.IndexManagerImpl) ConstraintViolationException(org.neo4j.graphdb.ConstraintViolationException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) SecurityContext(org.neo4j.kernel.api.security.SecurityContext) ReadOnlyRelationshipIndexFacade(org.neo4j.kernel.impl.coreapi.ReadOnlyRelationshipIndexFacade) ThrowingAction(org.neo4j.function.ThrowingAction) NO_SUCH_PROPERTY_KEY(org.neo4j.kernel.impl.api.operations.KeyReadOperations.NO_SUCH_PROPERTY_KEY) TokenAccess(org.neo4j.kernel.impl.api.TokenAccess) AutoIndexing(org.neo4j.kernel.api.legacyindex.AutoIndexing) Config(org.neo4j.kernel.configuration.Config) ReadOnlyIndexFacade(org.neo4j.kernel.impl.coreapi.ReadOnlyIndexFacade) PrimitiveLongCollections(org.neo4j.collection.primitive.PrimitiveLongCollections) ReadOperations(org.neo4j.kernel.api.ReadOperations) IndexQuery(org.neo4j.kernel.api.schema_new.IndexQuery) PrimitiveLongCollections.map(org.neo4j.collection.primitive.PrimitiveLongCollections.map) Iterators.emptyIterator(org.neo4j.helpers.collection.Iterators.emptyIterator) NodeProxy(org.neo4j.kernel.impl.core.NodeProxy) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) File(java.io.File) PropertyContainerLocker(org.neo4j.kernel.impl.coreapi.PropertyContainerLocker) TimeUnit(java.util.concurrent.TimeUnit) TraversalDescription(org.neo4j.graphdb.traversal.TraversalDescription) Relationship(org.neo4j.graphdb.Relationship) AUTH_DISABLED(org.neo4j.kernel.api.security.SecurityContext.AUTH_DISABLED) KeyReadOperations(org.neo4j.kernel.impl.api.operations.KeyReadOperations) MultipleFoundException(org.neo4j.graphdb.MultipleFoundException) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ClientConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.ClientConnectionInfo) ConstraintValidationException(org.neo4j.kernel.api.exceptions.schema.ConstraintValidationException) Collections(java.util.Collections) Statement(org.neo4j.kernel.api.Statement) NodeProxy(org.neo4j.kernel.impl.core.NodeProxy)

Aggregations

File (java.io.File)2 String.format (java.lang.String.format)2 URL (java.net.URL)2 Collections (java.util.Collections)2 Map (java.util.Map)2 Optional (java.util.Optional)2 TimeUnit (java.util.concurrent.TimeUnit)2 Supplier (java.util.function.Supplier)2 PrimitiveLongCollections (org.neo4j.collection.primitive.PrimitiveLongCollections)2 PrimitiveLongCollections.map (org.neo4j.collection.primitive.PrimitiveLongCollections.map)2 PrimitiveLongIterator (org.neo4j.collection.primitive.PrimitiveLongIterator)2 Suppliers (org.neo4j.function.Suppliers)2 ThrowingAction (org.neo4j.function.ThrowingAction)2 ConstraintViolationException (org.neo4j.graphdb.ConstraintViolationException)2 DependencyResolver (org.neo4j.graphdb.DependencyResolver)2 Label (org.neo4j.graphdb.Label)2 MultipleFoundException (org.neo4j.graphdb.MultipleFoundException)2 Node (org.neo4j.graphdb.Node)2 NotFoundException (org.neo4j.graphdb.NotFoundException)2 QueryExecutionException (org.neo4j.graphdb.QueryExecutionException)2