private int getLabelId( String labelName ) throws ProcedureException { int labelId = ktx.tokenRead().nodeLabel( labelName ); if ( labelId == TokenRead.NO_TOKEN ) { throw new ProcedureException( Status.Schema.LabelAccessFailed, "No such label %s", labelName ); } return labelId; }
@Override public String getUserMessage( KernelException e ) { KernelTransaction transaction = safeAcquireTransaction( transactionSupplier ); try ( Statement ignore = transaction.acquireStatement() ) { return e.getUserMessage( new SilentTokenNameLookup( transaction.tokenRead() ) ); } }
private void showSchema( DbStructureVisitor visitor, KernelTransaction ktx ) throws IndexNotFoundKernelException { TokenNameLookup nameLookup = new SilentTokenNameLookup( ktx.tokenRead() ); showIndices( visitor, ktx, nameLookup ); showUniqueConstraints( visitor, ktx, nameLookup ); }
@Override public boolean hasRelationship( Direction direction, RelationshipType... types ) { KernelTransaction transaction = safeAcquireTransaction(); int[] typeIds = relTypeIds( types, transaction.tokenRead() ); return innerHasRelationships( transaction, direction, typeIds ); }
private void showPropertyKeys( KernelTransaction ktx, DbStructureVisitor visitor ) { for ( String propertyKeyName : db.getAllPropertyKeys() ) { int propertyKeyId = ktx.tokenRead().propertyKey( propertyKeyName ); visitor.visitPropertyKey( propertyKeyId, propertyKeyName ); } }
@Override public ResourceIterable<Relationship> getRelationships( final Direction direction, RelationshipType... types ) { KernelTransaction transaction = safeAcquireTransaction(); int[] typeIds = relTypeIds( types, transaction.tokenRead() ); return innerGetRelationships( transaction, direction, typeIds ); }
private void showRelTypes( KernelTransaction ktx, DbStructureVisitor visitor ) { for ( RelationshipType relType : db.getAllRelationshipTypes() ) { int relTypeId = ktx.tokenRead().relationshipType( relType.name() ); visitor.visitRelationshipType( relTypeId, relType.name() ); } }
private void showLabels( KernelTransaction ktx, DbStructureVisitor visitor ) { for ( Label label : db.getAllLabels() ) { int labelId = ktx.tokenRead().nodeLabel( label.name() ); visitor.visitLabel( labelId, label.name() ); } }
private int propId( String propName ) { try ( Transaction ignore = db.beginTx() ) { return getTransaction().tokenRead().propertyKey( propName ); } }
private static int labelId( String labelName ) { try ( Transaction ignore = db.beginTx() ) { return getTransaction().tokenRead().nodeLabel( labelName ); } }
private int pkId( String propertyName ) { try ( Transaction ignore = db.beginTx() ) { return ktx().tokenRead().propertyKey( propertyName ); } }
@Override public ResourceIterator<Node> findNodes( final Label myLabel, final String key, final Object value ) { KernelTransaction transaction = statementContext.getKernelTransactionBoundToThisThread( true ); TokenRead tokenRead = transaction.tokenRead(); int labelId = tokenRead.nodeLabel( myLabel.name() ); int propertyId = tokenRead.propertyKey( key ); return nodesByLabelAndProperty( transaction, labelId, IndexQuery.exact( propertyId, Values.of( value ) ) ); }
protected String relationshipType( int id ) throws KernelException { try ( Transaction tx = db.beginTx() ) { String name = ktx().tokenRead().relationshipTypeName( id ); tx.success(); return name; } }
protected int propertyKeyId( String propertyKey ) { try ( Transaction tx = db.beginTx() ) { int id = ktx().tokenRead().propertyKey( propertyKey ); tx.success(); return id; } }
private int labelId( Label alien ) { try ( Transaction ignore = db.beginTx() ) { return ktx().tokenRead().nodeLabel( alien.name() ); } }
@Override public ResourceIterator<Node> findNodes( Label label, String key1, Object value1, String key2, Object value2 ) { KernelTransaction transaction = statementContext.getKernelTransactionBoundToThisThread( true ); TokenRead tokenRead = transaction.tokenRead(); int labelId = tokenRead.nodeLabel( label.name() ); return nodesByLabelAndProperties( transaction, labelId, IndexQuery.exact( tokenRead.propertyKey( key1 ), Values.of( value1 ) ), IndexQuery.exact( tokenRead.propertyKey( key2 ), Values.of( value2 ) ) ); }
private int getPropertyKeyId( String name ) { try ( Transaction tx = database.beginTx() ) { KernelTransaction transaction = ((GraphDatabaseAPI) database).getDependencyResolver().resolveDependency( ThreadToStatementContextBridge.class ).getKernelTransactionBoundToThisThread( true ); return transaction.tokenRead().propertyKey( name ); } }
private int getLabelId( String name ) { try ( Transaction tx = database.beginTx() ) { KernelTransaction transaction = ((GraphDatabaseAPI) database).getDependencyResolver().resolveDependency( ThreadToStatementContextBridge.class ).getKernelTransactionBoundToThisThread( true ); return transaction.tokenRead().nodeLabel( name ); } } }
protected int relationshipTypeId( RelationshipType type ) { try ( Transaction tx = db.beginTx() ) { int id = ktx().tokenRead().relationshipType( type.name() ); tx.success(); return id; } }
private static int propertyKeyCount( GraphDatabaseAPI db ) throws TransactionFailureException { InwardKernel kernelAPI = db.getDependencyResolver().resolveDependency( InwardKernel.class ); try ( KernelTransaction tx = kernelAPI.beginTransaction( KernelTransaction.Type.implicit, AnonymousContext.read() ) ) { return tx.tokenRead().propertyKeyCount(); } }