Search in sources :

Example 1 with StoreStatement

use of org.neo4j.kernel.impl.api.store.StoreStatement in project neo4j by neo4j.

the class LabelTransactionStateTest method before.

@Before
public void before() throws Exception {
    store = mock(StoreReadLayer.class);
    when(store.indexesGetForLabel(anyInt())).then(answerAsIteratorFrom(Collections.emptyList()));
    when(store.indexesGetAll()).then(answerAsIteratorFrom(Collections.emptyList()));
    txState = new TxState();
    state = StatementOperationsTestHelper.mockedState(txState);
    txContext = new StateHandlingStatementOperations(store, mock(InternalAutoIndexing.class), mock(ConstraintIndexCreator.class), mock(LegacyIndexStore.class));
    storeStatement = mock(StoreStatement.class);
    when(state.getStoreStatement()).thenReturn(storeStatement);
}
Also used : StoreReadLayer(org.neo4j.storageengine.api.StoreReadLayer) StoreStatement(org.neo4j.kernel.impl.api.store.StoreStatement) StateHandlingStatementOperations(org.neo4j.kernel.impl.api.StateHandlingStatementOperations) Before(org.junit.Before)

Example 2 with StoreStatement

use of org.neo4j.kernel.impl.api.store.StoreStatement in project neo4j by neo4j.

the class RecordStorageEngine method storeStatementSupplier.

private Supplier<StorageStatement> storeStatementSupplier(NeoStores neoStores) {
    Supplier<IndexReaderFactory> indexReaderFactory = () -> new IndexReaderFactory.Caching(indexingService);
    LockService lockService = takePropertyReadLocks ? this.lockService : NO_LOCK_SERVICE;
    return () -> new StoreStatement(neoStores, indexReaderFactory, labelScanStore::newReader, lockService);
}
Also used : LockService(org.neo4j.kernel.impl.locking.LockService) StoreStatement(org.neo4j.kernel.impl.api.store.StoreStatement) IndexReaderFactory(org.neo4j.kernel.impl.api.IndexReaderFactory)

Example 3 with StoreStatement

use of org.neo4j.kernel.impl.api.store.StoreStatement in project neo4j by neo4j.

the class SchemaTransactionStateTest method before.

@Before
public void before() throws Exception {
    txState = new TxState();
    state = StatementOperationsTestHelper.mockedState(txState);
    store = mock(StoreReadLayer.class);
    when(store.indexesGetForLabel(labelId1)).then(asAnswer(Collections.<NewIndexDescriptor>emptyList()));
    when(store.indexesGetForLabel(labelId2)).then(asAnswer(Collections.<NewIndexDescriptor>emptyList()));
    when(store.indexesGetAll()).then(asAnswer(Collections.<NewIndexDescriptor>emptyList()));
    txContext = new StateHandlingStatementOperations(store, mock(InternalAutoIndexing.class), mock(ConstraintIndexCreator.class), mock(LegacyIndexStore.class));
    storeStatement = mock(StoreStatement.class);
    when(state.getStoreStatement()).thenReturn(storeStatement);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) StoreReadLayer(org.neo4j.storageengine.api.StoreReadLayer) StoreStatement(org.neo4j.kernel.impl.api.store.StoreStatement) StateHandlingStatementOperations(org.neo4j.kernel.impl.api.StateHandlingStatementOperations) Before(org.junit.Before)

Example 4 with StoreStatement

use of org.neo4j.kernel.impl.api.store.StoreStatement in project neo4j by neo4j.

the class StateHandlingStatementOperationsTest method shouldNeverDelegateWrites.

@Test
public void shouldNeverDelegateWrites() throws Exception {
    KernelStatement state = mockedState();
    when(state.txState()).thenReturn(new TxState());
    StoreStatement storeStatement = mock(StoreStatement.class);
    when(state.getStoreStatement()).thenReturn(storeStatement);
    when(inner.indexesGetForLabel(0)).thenReturn(iterator(NewIndexDescriptorFactory.forLabel(0, 0)));
    when(storeStatement.acquireSingleNodeCursor(anyLong())).thenReturn(asNodeCursor(0));
    when(inner.nodeGetProperties(eq(storeStatement), any(NodeItem.class))).thenReturn(asPropertyCursor());
    StateHandlingStatementOperations ctx = newTxStateOps(inner);
    // When
    LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(0, 0);
    ctx.indexCreate(state, descriptor);
    ctx.nodeAddLabel(state, 0, 0);
    ctx.indexDrop(state, NewIndexDescriptorFactory.forSchema(descriptor));
    ctx.nodeRemoveLabel(state, 0, 0);
    // one for add and one for remove
    verify(storeStatement, times(2)).acquireSingleNodeCursor(0);
    verifyNoMoreInteractions(storeStatement);
}
Also used : NodeItem(org.neo4j.storageengine.api.NodeItem) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) StoreStatement(org.neo4j.kernel.impl.api.store.StoreStatement) StateHandlingStatementOperations(org.neo4j.kernel.impl.api.StateHandlingStatementOperations) LabelSchemaDescriptor(org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor) Test(org.junit.Test)

Example 5 with StoreStatement

use of org.neo4j.kernel.impl.api.store.StoreStatement in project neo4j by neo4j.

the class StateHandlingStatementOperationsTest method indexQueryClosesIndexReader.

@Test
public void indexQueryClosesIndexReader() throws Exception {
    KernelStatement kernelStatement = mock(KernelStatement.class);
    StoreStatement storeStatement = mock(StoreStatement.class);
    IndexReader indexReader = mock(IndexReader.class);
    when(indexReader.query(any())).thenReturn(PrimitiveLongCollections.emptyIterator());
    when(storeStatement.getFreshIndexReader(any())).thenReturn(indexReader);
    when(kernelStatement.getStoreStatement()).thenReturn(storeStatement);
    StateHandlingStatementOperations operations = newTxStateOps(mock(StoreReadLayer.class));
    operations.nodeGetFromUniqueIndexSeek(kernelStatement, NewIndexDescriptorFactory.uniqueForLabel(1, 1), IndexQuery.exact(1, "foo"));
    verify(indexReader).close();
}
Also used : KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) StoreReadLayer(org.neo4j.storageengine.api.StoreReadLayer) StoreStatement(org.neo4j.kernel.impl.api.store.StoreStatement) IndexReader(org.neo4j.storageengine.api.schema.IndexReader) StateHandlingStatementOperations(org.neo4j.kernel.impl.api.StateHandlingStatementOperations) Test(org.junit.Test)

Aggregations

StoreStatement (org.neo4j.kernel.impl.api.store.StoreStatement)5 StateHandlingStatementOperations (org.neo4j.kernel.impl.api.StateHandlingStatementOperations)4 StoreReadLayer (org.neo4j.storageengine.api.StoreReadLayer)3 Before (org.junit.Before)2 Test (org.junit.Test)2 KernelStatement (org.neo4j.kernel.impl.api.KernelStatement)2 LabelSchemaDescriptor (org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor)1 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)1 IndexReaderFactory (org.neo4j.kernel.impl.api.IndexReaderFactory)1 LockService (org.neo4j.kernel.impl.locking.LockService)1 NodeItem (org.neo4j.storageengine.api.NodeItem)1 IndexReader (org.neo4j.storageengine.api.schema.IndexReader)1