@Override protected StorageNodeCursor allocateCursor( StorageReader storageReader ) { return storageReader.allocateNodeCursor(); }
public void dispose() { storageReader.close(); }
@Test public void shouldAcquireSchemaReadLockBeforeGettingConstraintsByLabel() { // WHEN allStoreHolder.constraintsGetForLabel( 42 ); // THEN order.verify( locks ).acquireShared( LockTracer.NONE, ResourceTypes.LABEL, 42 ); order.verify( storageReader ).constraintsGetForLabel( 42 ); }
public TransactionCountingStateVisitor( TxStateVisitor next, StorageReader storageReader, ReadableTransactionState txState, CountsRecordState counts ) { super( next ); this.storageReader = storageReader; this.txState = txState; this.counts = counts; this.nodeCursor = storageReader.allocateNodeCursor(); this.groupCursor = storageReader.allocateRelationshipGroupCursor(); }
StorageEngine engine = mock( StorageEngine.class ); storageReader = mock( StorageReader.class ); when( storageReader.nodeExists( anyLong() ) ).thenReturn( true ); when( storageReader.constraintsGetForLabel( anyInt() )).thenReturn( Collections.emptyIterator() ); when( storageReader.constraintsGetAll() ).thenReturn( Collections.emptyIterator() ); when( engine.newReader() ).thenReturn( storageReader ); allStoreHolder = new AllStoreHolder( storageReader, transaction, cursors, mock(
private void takeSnapshot() try ( StorageNodeCursor node = store.allocateNodeCursor(); StoragePropertyCursor properties = store.allocatePropertyCursor(); StorageRelationshipScanCursor relationship = store.allocateRelationshipScanCursor() )
@Override public Iterator<ConstraintDescriptor> constraintsGetAll() { ktx.assertOpen(); Iterator<ConstraintDescriptor> constraints = storageReader.constraintsGetAll(); if ( ktx.hasTxStateWithChanges() ) { constraints = ktx.txState().constraintsChanges().apply( constraints ); } return Iterators.map( this::lockConstraint, constraints ); }
@Test public void shouldAcquireSchemaReadLockBeforeGettingConstraintsByLabelAndProperty() { // WHEN allStoreHolder.constraintsGetForSchema( descriptor ); // THEN order.verify( locks ).acquireShared( LockTracer.NONE, ResourceTypes.LABEL, descriptor.getLabelId() ); order.verify( storageReader ).constraintsGetForSchema( descriptor ); }
@Override protected StorageRelationshipScanCursor allocateCursor( StorageReader storageReader ) { return storageReader.allocateRelationshipScanCursor(); }
@Test public void shouldReleaseStoreStatementOnlyWhenReferenceCountDownToZero() { // given KernelTransactionImplementation transaction = mock( KernelTransactionImplementation.class ); StorageReader storageReader = mock( StorageReader.class ); KernelStatement statement = getKernelStatement( transaction, storageReader ); statement.acquire(); verify( storageReader ).acquire(); statement.acquire(); // when statement.close(); verifyNoMoreInteractions( storageReader ); // then statement.close(); verify( storageReader ).release(); }
try ( StorageNodeCursor node = storageReader.allocateNodeCursor() ) try ( StoragePropertyCursor props = storageReader.allocatePropertyCursor() )
protected PropertyAwareEntityStoreScan( StorageReader storageReader, long totalEntityCount, IntPredicate propertyKeyIdFilter, LongFunction<Lock> lockFunction ) { this.storageReader = storageReader; this.entityCursor = allocateCursor( storageReader ); this.propertyCursor = storageReader.allocatePropertyCursor(); this.propertyKeyIdFilter = propertyKeyIdFilter; this.lockFunction = lockFunction; this.totalCount = totalEntityCount; }
@Override public DefaultRelationshipGroupCursor allocateRelationshipGroupCursor() { if ( relationshipGroupCursor == null ) { return trace( new DefaultRelationshipGroupCursor( this, storageReader.allocateRelationshipGroupCursor() ) ); } try { return relationshipGroupCursor; } finally { relationshipGroupCursor = null; } }
@Override public DefaultRelationshipTraversalCursor allocateRelationshipTraversalCursor() { if ( relationshipTraversalCursor == null ) { return trace( new DefaultRelationshipTraversalCursor( this, storageReader.allocateRelationshipTraversalCursor() ) ); } try { return relationshipTraversalCursor; } finally { relationshipTraversalCursor = null; } }
public final void acquire() { if ( referenceCount++ == 0 ) { storageReader.acquire(); clockContext.initializeStatement(); } recordOpenCloseMethods(); }
private void takeSnapshot() try ( StorageNodeCursor node = store.allocateNodeCursor(); StoragePropertyCursor properties = store.allocatePropertyCursor(); StorageRelationshipScanCursor relationship = store.allocateRelationshipScanCursor() )
@Test public void shouldAcquireSchemaReadLockLazilyBeforeGettingAllConstraints() { // given int labelId = 1; int relTypeId = 2; UniquenessConstraintDescriptor uniquenessConstraint = uniqueForLabel( labelId, 2, 3, 3 ); RelExistenceConstraintDescriptor existenceConstraint = existsForRelType( relTypeId, 3, 4, 5 ); when( storageReader.constraintsGetAll() ) .thenReturn( Iterators.iterator( uniquenessConstraint, existenceConstraint ) ); // when Iterator<ConstraintDescriptor> result = allStoreHolder.constraintsGetAll( ); Iterators.count( result ); // then assertThat( asList( result ), empty() ); order.verify( storageReader ).constraintsGetAll(); order.verify( locks ).acquireShared( LockTracer.NONE, ResourceTypes.LABEL, labelId ); order.verify( locks ).acquireShared( LockTracer.NONE, ResourceTypes.RELATIONSHIP_TYPE, relTypeId ); }
public TransactionCountingStateVisitor( TxStateVisitor next, StorageReader storageReader, ReadableTransactionState txState, CountsRecordState counts ) { super( next ); this.storageReader = storageReader; this.txState = txState; this.counts = counts; this.nodeCursor = storageReader.allocateNodeCursor(); this.groupCursor = storageReader.allocateRelationshipGroupCursor(); }
@Override public Iterator<ConstraintDescriptor> constraintsGetForSchema( SchemaDescriptor descriptor ) { acquireSharedSchemaLock( descriptor ); ktx.assertOpen(); Iterator<ConstraintDescriptor> constraints = storageReader.constraintsGetForSchema( descriptor ); if ( ktx.hasTxStateWithChanges() ) { return ktx.txState().constraintsChangesForSchema( descriptor ).apply( constraints ); } return constraints; }
@Override public DefaultRelationshipScanCursor allocateRelationshipScanCursor() { if ( relationshipScanCursor == null ) { return trace( new DefaultRelationshipScanCursor( this, storageReader.allocateRelationshipScanCursor() ) ); } try { return relationshipScanCursor; } finally { relationshipScanCursor = null; } }