@Override public RelationshipExplicitIndexCursor allocateRelationshipExplicitIndexCursor() { RelationshipExplicitIndexCursor n = cursors.allocateRelationshipExplicitIndexCursor(); allCursors.add( n ); return n; } }
@Override public IndexHits<Relationship> get( KernelTransaction ktx, String name, String key, Object value, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); ktx.indexRead().relationshipExplicitIndexLookup( cursor, name, key, value, -1, -1 ); return new CursorWrappingRelationshipIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Override public IndexHits<Relationship> query( KernelTransaction ktx, String name, String key, Object queryOrQueryObject, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); ktx.indexRead().relationshipExplicitIndexQuery( cursor, name, key, queryOrQueryObject,-1, -1 ); return new CursorWrappingRelationshipIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Override public IndexHits<Relationship> query( KernelTransaction ktx, String name, Object queryOrQueryObject, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); ktx.indexRead().relationshipExplicitIndexQuery( cursor, name, queryOrQueryObject, -1 , -1 ); return new CursorWrappingRelationshipIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Deprecated @Description( "Search relationship in explicit automatic index. Replaces `START r=relationship:relationship_auto_index" + "('key:foo*')`" ) @Procedure( name = "db.index.explicit.auto.searchRelationships", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<WeightedRelationshipResult> relationshipAutoIndexSearch( @Name( "query" ) Object query ) { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead().relationshipExplicitIndexQuery( cursor, "relationship_auto_index", query, -1, -1 ); return toWeightedRelationshipResultStream( cursor ); } catch ( KernelException e ) { // auto index will not exist if no relationships have been added that match the auto-index rules return Stream.empty(); } }
@Override public IndexHits<Relationship> get( String key, Object valueOrNull, Node startNodeOrNull, Node endNodeOrNull ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); long source = startNodeOrNull == null ? NO_SUCH_NODE : startNodeOrNull.getId(); long target = endNodeOrNull == null ? NO_SUCH_NODE : endNodeOrNull.getId(); ktx.indexRead().relationshipExplicitIndexLookup( cursor, name, key, valueOrNull, source, target ); return new CursorWrappingRelationshipIndexHits( cursor, getGraphDatabase(), ktx, name ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
@Deprecated @Description( "Get relationship from explicit automatic index. Replaces `START r=relationship:relationship_auto_index(key " + "= 'A')`" ) @Procedure( name = "db.index.explicit.auto.seekRelationships", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<RelationshipResult> relationshipAutoIndexSeek( @Name( "key" ) String key, @Name( "value" ) Object value ) { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead() .relationshipExplicitIndexLookup( cursor, "relationship_auto_index", key, value, -1, -1 ); return toStream( cursor, id -> new RelationshipResult( graphDatabaseAPI.getRelationshipById( id ) ) ); } catch ( KernelException e ) { // auto index will not exist if no relationships have been added that match the auto-index rules return Stream.empty(); } }
@Override public IndexHits<Relationship> query( String key, Object queryOrQueryObjectOrNull, Node startNodeOrNull, Node endNodeOrNull ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); long source = startNodeOrNull == null ? NO_SUCH_NODE : startNodeOrNull.getId(); long target = endNodeOrNull == null ? NO_SUCH_NODE : endNodeOrNull.getId(); ktx.indexRead().relationshipExplicitIndexQuery( cursor, name, key, queryOrQueryObjectOrNull, source, target ); return new CursorWrappingRelationshipIndexHits( cursor, getGraphDatabase(), ktx, name ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
@Override public IndexHits<Relationship> query( Object queryOrQueryObjectOrNull, Node startNodeOrNull, Node endNodeOrNull ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); long source = startNodeOrNull == null ? NO_SUCH_NODE : startNodeOrNull.getId(); long target = endNodeOrNull == null ? NO_SUCH_NODE : endNodeOrNull.getId(); ktx.indexRead().relationshipExplicitIndexQuery( cursor, name, queryOrQueryObjectOrNull, source, target ); return new CursorWrappingRelationshipIndexHits( cursor, getGraphDatabase(), ktx, name ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } } }
@Deprecated @Description( "Search relationship in explicit index. Replaces `START r=relationship:relIndex('key:foo*')`" ) @Procedure( name = "db.index.explicit.searchRelationships", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<WeightedRelationshipResult> relationshipManualIndexSearch( @Name( "indexName" ) String manualIndexName, @Name( "query" ) Object query ) throws ProcedureException { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead().relationshipExplicitIndexQuery( cursor, manualIndexName, query, -1, -1 ); return toWeightedRelationshipResultStream( cursor ); } catch ( KernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Relationship index %s not found", manualIndexName ); } }
@Deprecated @Description( "Search relationship in explicit index, ending at the node 'out'." ) @Procedure( name = "db.index.explicit.searchRelationshipsOut", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<WeightedRelationshipResult> relationshipManualIndexSearchWithBoundEndNode( @Name( "indexName" ) String indexName, @Name( "out" ) Node out, @Name( "query" ) Object query ) throws ProcedureException { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead().relationshipExplicitIndexQuery( cursor, indexName, query, -1, out.getId() ); return toWeightedRelationshipResultStream( cursor ); } catch ( KernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Relationship index %s not found", indexName ); } }
@Deprecated @Description( "Search relationship in explicit index, starting at the node 'in'." ) @Procedure( name = "db.index.explicit.searchRelationshipsIn", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<WeightedRelationshipResult> relationshipManualIndexSearchWithBoundStartNode( @Name( "indexName" ) String indexName, @Name( "in" ) Node in, @Name( "query" ) Object query ) throws ProcedureException { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead().relationshipExplicitIndexQuery( cursor, indexName, query, in.getId(), -1 ); return toWeightedRelationshipResultStream( cursor ); } catch ( KernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Relationship index %s not found", indexName ); } }
@Deprecated @Description( "Get relationship from explicit index. Replaces `START r=relationship:relIndex(key = 'A')`" ) @Procedure( name = "db.index.explicit.seekRelationships", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<RelationshipResult> relationshipManualIndexSeek( @Name( "indexName" ) String manualIndexName, @Name( "key" ) String key, @Name( "value" ) Object value ) throws ProcedureException { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead().relationshipExplicitIndexLookup( cursor, manualIndexName, key, value, -1, -1 ); return toStream( cursor, id -> new RelationshipResult( graphDatabaseAPI.getRelationshipById( id ) ) ); } catch ( KernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Relationship index %s not found", manualIndexName ); } }
@Deprecated @Description( "Search relationship in explicit index, starting at the node 'in' and ending at 'out'." ) @Procedure( name = "db.index.explicit.searchRelationshipsBetween", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<WeightedRelationshipResult> relationshipManualIndexSearchWithBoundNodes( @Name( "indexName" ) String indexName, @Name( "in" ) Node in, @Name( "out" ) Node out, @Name( "query" ) Object query ) throws ProcedureException { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead().relationshipExplicitIndexQuery( cursor, indexName, query, in.getId(), out.getId() ); return toWeightedRelationshipResultStream( cursor ); } catch ( KernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Relationship index %s not found", indexName ); } }
@Override public IndexHits<Relationship> get( KernelTransaction ktx, String name, String key, Object value, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); ktx.indexRead().relationshipExplicitIndexLookup( cursor, name, key, value, -1, -1 ); return new CursorWrappingRelationshipIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Override public IndexHits<Relationship> query( KernelTransaction ktx, String name, String key, Object queryOrQueryObject, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); ktx.indexRead().relationshipExplicitIndexQuery( cursor, name, key, queryOrQueryObject,-1, -1 ); return new CursorWrappingRelationshipIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Override public IndexHits<Relationship> query( KernelTransaction ktx, String name, Object queryOrQueryObject, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); ktx.indexRead().relationshipExplicitIndexQuery( cursor, name, queryOrQueryObject, -1 , -1 ); return new CursorWrappingRelationshipIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Deprecated @Description( "Get relationship from explicit automatic index. Replaces `START r=relationship:relationship_auto_index(key " + "= 'A')`" ) @Procedure( name = "db.index.explicit.auto.seekRelationships", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<RelationshipResult> relationshipAutoIndexSeek( @Name( "key" ) String key, @Name( "value" ) Object value ) { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead() .relationshipExplicitIndexLookup( cursor, "relationship_auto_index", key, value, -1, -1 ); return toStream( cursor, id -> new RelationshipResult( graphDatabaseAPI.getRelationshipById( id ) ) ); } catch ( KernelException e ) { // auto index will not exist if no relationships have been added that match the auto-index rules return Stream.empty(); } }
@Override public IndexHits<Relationship> query( String key, Object queryOrQueryObjectOrNull, Node startNodeOrNull, Node endNodeOrNull ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); long source = startNodeOrNull == null ? NO_SUCH_NODE : startNodeOrNull.getId(); long target = endNodeOrNull == null ? NO_SUCH_NODE : endNodeOrNull.getId(); ktx.indexRead().relationshipExplicitIndexQuery( cursor, name, key, queryOrQueryObjectOrNull, source, target ); return new CursorWrappingRelationshipIndexHits( cursor, getGraphDatabase(), ktx, name ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
@Override public IndexHits<Relationship> get( String key, Object valueOrNull, Node startNodeOrNull, Node endNodeOrNull ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); long source = startNodeOrNull == null ? NO_SUCH_NODE : startNodeOrNull.getId(); long target = endNodeOrNull == null ? NO_SUCH_NODE : endNodeOrNull.getId(); ktx.indexRead().relationshipExplicitIndexLookup( cursor, name, key, valueOrNull, source, target ); return new CursorWrappingRelationshipIndexHits( cursor, getGraphDatabase(), ktx, name ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }