use of org.neo4j.storageengine.api.StorageStatement in project neo4j by neo4j.
the class KernelStatementTest method assertStatementIsNotOpenWhileAcquireIsNotInvoked.
@Test(expected = NotInTransactionException.class)
public void assertStatementIsNotOpenWhileAcquireIsNotInvoked() {
KernelTransactionImplementation transaction = mock(KernelTransactionImplementation.class);
TxStateHolder txStateHolder = mock(TxStateHolder.class);
StorageStatement storeStatement = mock(StorageStatement.class);
AccessCapability accessCapability = mock(AccessCapability.class);
Procedures procedures = mock(Procedures.class);
KernelStatement statement = new KernelStatement(transaction, txStateHolder, storeStatement, procedures, accessCapability, LockTracer.NONE);
statement.assertOpen();
}
use of org.neo4j.storageengine.api.StorageStatement in project neo4j by neo4j.
the class KernelStatementTest method shouldReleaseStorageStatementWhenForceClosed.
@Test
public void shouldReleaseStorageStatementWhenForceClosed() throws Exception {
// given
StorageStatement storeStatement = mock(StorageStatement.class);
KernelStatement statement = new KernelStatement(mock(KernelTransactionImplementation.class), null, storeStatement, new Procedures(), new CanWrite(), LockTracer.NONE);
statement.acquire();
// when
statement.forceClose();
// then
verify(storeStatement).release();
}
use of org.neo4j.storageengine.api.StorageStatement in project neo4j by neo4j.
the class StateHandlingStatementOperations method indexQuery.
@Override
public PrimitiveLongIterator indexQuery(KernelStatement state, NewIndexDescriptor index, IndexQuery... predicates) throws IndexNotFoundKernelException, IndexNotApplicableKernelException {
StorageStatement storeStatement = state.getStoreStatement();
IndexReader reader = storeStatement.getIndexReader(index);
PrimitiveLongIterator committed = reader.query(predicates);
PrimitiveLongIterator exactMatches = LookupFilter.exactIndexMatches(this, state, committed, predicates);
IndexQuery firstPredicate = predicates[0];
switch(firstPredicate.type()) {
case exact:
IndexQuery.ExactPredicate[] exactPreds = assertOnlyExactPredicates(predicates);
return filterIndexStateChangesForSeek(state, exactMatches, index, OrderedPropertyValues.of(exactPreds));
case stringSuffix:
case stringContains:
case exists:
return filterIndexStateChangesForScan(state, exactMatches, index);
case rangeNumeric:
{
assertSinglePredicate(predicates);
IndexQuery.NumberRangePredicate numPred = (IndexQuery.NumberRangePredicate) firstPredicate;
return filterIndexStateChangesForRangeSeekByNumber(state, index, numPred.from(), numPred.fromInclusive(), numPred.to(), numPred.toInclusive(), exactMatches);
}
case rangeString:
{
assertSinglePredicate(predicates);
IndexQuery.StringRangePredicate strPred = (IndexQuery.StringRangePredicate) firstPredicate;
return filterIndexStateChangesForRangeSeekByString(state, index, strPred.from(), strPred.fromInclusive(), strPred.to(), strPred.toInclusive(), committed);
}
case stringPrefix:
{
assertSinglePredicate(predicates);
IndexQuery.StringPrefixPredicate strPred = (IndexQuery.StringPrefixPredicate) firstPredicate;
return filterIndexStateChangesForRangeSeekByPrefix(state, index, strPred.prefix(), committed);
}
default:
throw new UnsupportedOperationException("Query not supported: " + Arrays.toString(predicates));
}
}
use of org.neo4j.storageengine.api.StorageStatement in project neo4j by neo4j.
the class KernelTransactionFactory method kernelTransactionWithInternals.
static Instances kernelTransactionWithInternals(SecurityContext securityContext) {
TransactionHeaderInformation headerInformation = new TransactionHeaderInformation(-1, -1, new byte[0]);
TransactionHeaderInformationFactory headerInformationFactory = mock(TransactionHeaderInformationFactory.class);
when(headerInformationFactory.create()).thenReturn(headerInformation);
StorageEngine storageEngine = mock(StorageEngine.class);
StoreReadLayer storeReadLayer = mock(StoreReadLayer.class);
StorageStatement storageStatement = mock(StorageStatement.class);
when(storeReadLayer.newStatement()).thenReturn(storageStatement);
when(storageEngine.storeReadLayer()).thenReturn(storeReadLayer);
KernelTransactionImplementation transaction = new KernelTransactionImplementation(mock(StatementOperationContainer.class), mock(SchemaWriteGuard.class), new TransactionHooks(), mock(ConstraintIndexCreator.class), new Procedures(), headerInformationFactory, mock(TransactionRepresentationCommitProcess.class), mock(TransactionMonitor.class), mock(Supplier.class), mock(Pool.class), Clocks.systemClock(), NULL, LockTracer.NONE, PageCursorTracerSupplier.NULL, storageEngine, new CanWrite());
StatementLocks statementLocks = new SimpleStatementLocks(new NoOpClient());
transaction.initialize(0, 0, statementLocks, KernelTransaction.Type.implicit, securityContext, 0L);
return new Instances(transaction, storageEngine, storeReadLayer, storageStatement);
}
use of org.neo4j.storageengine.api.StorageStatement in project neo4j by neo4j.
the class KernelTransactionsTest method newKernelTransactions.
private static KernelTransactions newKernelTransactions(boolean testKernelTransactions, TransactionCommitProcess commitProcess, StorageStatement firstStoreStatements, StorageStatement... otherStorageStatements) throws Throwable {
Locks locks = mock(Locks.class);
when(locks.newClient()).thenReturn(mock(Locks.Client.class));
StoreReadLayer readLayer = mock(StoreReadLayer.class);
when(readLayer.newStatement()).thenReturn(firstStoreStatements, otherStorageStatements);
StorageEngine storageEngine = mock(StorageEngine.class);
when(storageEngine.storeReadLayer()).thenReturn(readLayer);
doAnswer(invocation -> {
invocation.getArgumentAt(0, Collection.class).add(mock(StorageCommand.class));
return null;
}).when(storageEngine).createCommands(anyCollection(), any(ReadableTransactionState.class), any(StorageStatement.class), any(ResourceLocker.class), anyLong());
return newKernelTransactions(locks, storageEngine, commitProcess, testKernelTransactions);
}
Aggregations