@Override public Read dataRead() { return internal.dataRead(); }
private void noSide( KernelTransaction ktx, DbStructureVisitor visitor, RelationshipType relType, int relTypeId ) { String userDescription = format("MATCH ()-[%s]->() RETURN count(*)", colon( relType.name() )); long amount = ktx.dataRead().countsForRelationship( ANY_LABEL, relTypeId, ANY_LABEL ); visitor.visitRelCount( ANY_LABEL, relTypeId, ANY_LABEL, userDescription, amount ); }
private long countsForNode() { return kernelTransactionSupplier.get().dataRead().countsForNode( StatementConstants.ANY_LABEL ); } }
@Override boolean inUse( KernelTransaction transaction, int tokenId ) { SchemaRead schemaRead = transaction.schemaRead(); return hasAny( schemaRead.indexesGetForLabel( tokenId ) ) || // used by index hasAny( schemaRead.constraintsGetForLabel( tokenId ) ) || // used by constraint transaction.dataRead().countsForNode( tokenId ) > 0; // used by data } };
private void rightSide( KernelTransaction ktx, DbStructureVisitor visitor, Label label, int labelId, RelationshipType relType, int relTypeId ) { String userDescription = format( "MATCH ()-[%s]->(%s) RETURN count(*)", colon( relType.name() ), colon( label.name() ) ); long amount = ktx.dataRead().countsForRelationship( ANY_LABEL, relTypeId, labelId ); visitor.visitRelCount( ANY_LABEL, relTypeId, labelId, userDescription, amount ); }
private void leftSide( KernelTransaction ktx, DbStructureVisitor visitor, Label label, int labelId, RelationshipType relType, int relTypeId ) { String userDescription = format( "MATCH (%s)-[%s]->() RETURN count(*)", colon( label.name() ), colon( relType.name() ) ); long amount = ktx.dataRead().countsForRelationship( labelId, relTypeId, ANY_LABEL ); visitor.visitRelCount( labelId, relTypeId, ANY_LABEL, userDescription, amount ); }
private void singleNode( KernelTransaction transaction, NodeCursor nodes ) { transaction.dataRead().singleNode( nodeId, nodes ); if ( !nodes.next() ) { throw new NotFoundException( new EntityNotFoundException( EntityType.NODE, nodeId ) ); } }
@Override public RawIterator<Object[],ProcedureException> apply( Context ctx, Object[] input, ResourceTracker resourceTracker ) throws ProcedureException { return RawIterator.<Object[],ProcedureException>of( new Object[]{ctx.get( Context.KERNEL_TRANSACTION ).dataRead()} ); } } );
NodeValueIndexCursor indexQuery( KernelTransaction ktx, IndexDescriptor indexDescriptor, IndexQuery... indexQueries ) throws KernelException { NodeValueIndexCursor cursor = ktx.cursors().allocateNodeValueIndexCursor(); ktx.dataRead().nodeIndexSeek( indexDescriptor, cursor, IndexOrder.NONE, false, indexQueries ); return cursor; } }
@Test public void shouldAllowSchemaStatementAfterReadStatement() throws Exception { // given KernelTransaction tx = kernelTransaction( AUTH_DISABLED ); tx.dataRead(); // when / then tx.schemaWrite(); }
@Test public void shouldAllowReadStatementAfterSchemaStatement() throws Exception { // given KernelTransaction tx = kernelTransaction( AUTH_DISABLED ); tx.schemaWrite(); // when / then tx.dataRead(); } }
@Test public void shouldAllowReadStatementAfterDataStatement() throws Exception { // given KernelTransaction tx = kernelTransaction( AnonymousContext.write() ); tx.dataWrite(); // when / then tx.dataRead(); }
private NodeValueIndexCursor seek( KernelTransaction transaction ) throws KernelException { NodeValueIndexCursor cursor = transaction.cursors().allocateNodeValueIndexCursor(); transaction.dataRead().nodeIndexSeek( index, cursor, IndexOrder.NONE, false, exactQuery() ); return cursor; }
@Test public void shouldAllowDataStatementAfterReadStatement() throws Exception { // given KernelTransaction tx = kernelTransaction( AnonymousContext.write() ); tx.dataRead(); // when / then tx.dataWrite(); }
private void showNodeCounts( KernelTransaction ktx, DbStructureVisitor visitor ) { Read read = ktx.dataRead(); visitor.visitAllNodesCount( read.countsForNode( ANY_LABEL ) ); for ( Label label : db.getAllLabels() ) { int labelId = ktx.tokenRead().nodeLabel( label.name() ); visitor.visitNodeCount( labelId, label.name(), read.countsForNode( labelId ) ); } } private void showRelCounts( KernelTransaction ktx, DbStructureVisitor visitor )
public long countNodes() { long result; try ( Transaction tx = graph.beginTransaction( KernelTransaction.Type.explicit, AnonymousContext.read() ) ) { KernelTransaction kernelTransaction = this.txBridge.getKernelTransactionBoundToThisThread(true ); result = kernelTransaction.dataRead().countsForNode( -1 ); tx.success(); } return result; } }
@Test( expected = TransactionTerminatedException.class ) public void shouldThrowTerminateExceptionWhenTransactionTerminated() throws KernelException { KernelTransaction transaction = newTransaction( AnonymousContext.write() ); transaction.success(); transaction.markForTermination( Status.General.UnknownError ); transactionOperation.operate( transaction.dataRead(), transaction.dataWrite(), transaction.schemaRead() ); }
@Test( expected = NotInTransactionException.class ) public void shouldThrowNotInTransactionWhenTransactionClosedAndAttemptingOperations() throws KernelException { KernelTransaction transaction = newTransaction( AnonymousContext.write() ); Read read = transaction.dataRead(); Write write = transaction.dataWrite(); SchemaRead schemaRead = transaction.schemaRead(); transaction.success(); transaction.close(); transactionOperation.operate( read, write, schemaRead ); }
@Test( expected = NotInTransactionException.class ) public void shouldThrowNotInTransactionWhenTransactionClosedAndAccessingOperations() throws KernelException { KernelTransaction transaction = newTransaction( AnonymousContext.write() ); transaction.success(); transaction.close(); transactionOperation.operate( transaction.dataRead(), transaction.dataWrite(), transaction.schemaRead() ); }