use of org.neo4j.storageengine.api.StoreReadLayer in project neo4j by neo4j.
the class IndexSamplingManagerBeanTest method setup.
@Before
public void setup() {
dataSource = mock(NeoStoreDataSource.class);
storeReadLayer = mock(StoreReadLayer.class);
indexingService = mock(IndexingService.class);
when(dataSource.getStoreLayer()).thenReturn(storeReadLayer);
when(storeReadLayer.labelGetForName(EXISTING_LABEL)).thenReturn(LABEL_ID);
when(storeReadLayer.propertyKeyGetForName(EXISTING_PROPERTY)).thenReturn(PROPERTY_ID);
when(storeReadLayer.propertyKeyGetForName(NON_EXISTING_PROPERTY)).thenReturn(-1);
when(storeReadLayer.labelGetForName(NON_EXISTING_LABEL)).thenReturn(-1);
DependencyResolver resolver = mock(DependencyResolver.class);
when(resolver.resolveDependency(IndexingService.class)).thenReturn(indexingService);
when(dataSource.getDependencyResolver()).thenReturn(resolver);
}
use of org.neo4j.storageengine.api.StoreReadLayer 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.StoreReadLayer 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);
}
use of org.neo4j.storageengine.api.StoreReadLayer in project neo4j by neo4j.
the class StateHandlingStatementOperationsTest method shouldConsiderTransactionStateDuringIndexRangeSeekBySuffixWithIndexQuery.
@Test
public void shouldConsiderTransactionStateDuringIndexRangeSeekBySuffixWithIndexQuery() throws Exception {
// Given
TransactionState txState = mock(TransactionState.class);
KernelStatement statement = mock(KernelStatement.class);
when(statement.hasTxStateWithChanges()).thenReturn(true);
when(statement.txState()).thenReturn(txState);
when(txState.indexUpdatesForScan(index)).thenReturn(new DiffSets<>(Collections.singleton(42L), Collections.singleton(44L)));
when(txState.addedAndRemovedNodes()).thenReturn(new DiffSets<>(Collections.singleton(45L), Collections.singleton(46L)));
StoreReadLayer storeReadLayer = mock(StoreReadLayer.class);
IndexReader indexReader = addMockedIndexReader(statement);
IndexQuery.StringSuffixPredicate indexQuery = IndexQuery.stringSuffix(index.schema().getPropertyId(), "suffix");
when(indexReader.query(indexQuery)).thenReturn(PrimitiveLongCollections.resourceIterator(PrimitiveLongCollections.iterator(43L, 44L, 46L), null));
StateHandlingStatementOperations context = newTxStateOps(storeReadLayer);
// When
PrimitiveLongIterator results = context.indexQuery(statement, index, indexQuery);
// Then
assertEquals(asSet(42L, 43L), PrimitiveLongCollections.toSet(results));
}
use of org.neo4j.storageengine.api.StoreReadLayer in project neo4j by neo4j.
the class StateHandlingStatementOperationsTest method shouldConsiderTransactionStateDuringIndexSeekWithIndexQuery.
@Test
public void shouldConsiderTransactionStateDuringIndexSeekWithIndexQuery() throws Exception {
// Given
TransactionState txState = mock(TransactionState.class);
KernelStatement statement = mock(KernelStatement.class);
when(statement.hasTxStateWithChanges()).thenReturn(true);
when(statement.txState()).thenReturn(txState);
when(txState.indexUpdatesForSeek(index, OrderedPropertyValues.ofUndefined("value"))).thenReturn(new DiffSets<>(Collections.singleton(42L), Collections.singleton(44L)));
when(txState.addedAndRemovedNodes()).thenReturn(new DiffSets<>(Collections.singleton(45L), Collections.singleton(46L)));
StoreReadLayer storeReadLayer = mock(StoreReadLayer.class);
IndexReader indexReader = addMockedIndexReader(statement);
IndexQuery.ExactPredicate query = IndexQuery.exact(index.schema().getPropertyId(), "value");
when(indexReader.query(query)).thenReturn(PrimitiveLongCollections.resourceIterator(PrimitiveLongCollections.iterator(43L, 44L, 46L), null));
StateHandlingStatementOperations context = newTxStateOps(storeReadLayer);
// When
PrimitiveLongIterator results = context.indexQuery(statement, index, query);
// Then
assertEquals(asSet(42L, 43L), PrimitiveLongCollections.toSet(results));
}
Aggregations