Search in sources :

Example 6 with PropertyStore

use of org.neo4j.kernel.impl.store.PropertyStore in project neo4j by neo4j.

the class IndexBatchTransactionApplierTest method shouldProvideLabelScanStoreUpdatesSortedByNodeId.

@Test
public void shouldProvideLabelScanStoreUpdatesSortedByNodeId() throws Exception {
    // GIVEN
    IndexingService indexing = mock(IndexingService.class);
    LabelScanWriter writer = new OrderVerifyingLabelScanWriter(10, 15, 20);
    WorkSync<Supplier<LabelScanWriter>, LabelUpdateWork> labelScanSync = spy(new WorkSync<>(singletonProvider(writer)));
    WorkSync<IndexingService, IndexUpdatesWork> indexUpdatesSync = new WorkSync<>(indexing);
    TransactionToApply tx = mock(TransactionToApply.class);
    PropertyStore propertyStore = mock(PropertyStore.class);
    try (IndexBatchTransactionApplier applier = new IndexBatchTransactionApplier(indexing, labelScanSync, indexUpdatesSync, mock(NodeStore.class), mock(PropertyLoader.class), new PropertyPhysicalToLogicalConverter(propertyStore), TransactionApplicationMode.INTERNAL)) {
        try (TransactionApplier txApplier = applier.startTx(tx)) {
            // WHEN
            txApplier.visitNodeCommand(node(15));
            txApplier.visitNodeCommand(node(20));
            txApplier.visitNodeCommand(node(10));
        }
    }
    // THEN all assertions happen inside the LabelScanWriter#write and #close
    verify(labelScanSync).apply(any());
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) WorkSync(org.neo4j.concurrent.WorkSync) PropertyPhysicalToLogicalConverter(org.neo4j.kernel.impl.api.index.PropertyPhysicalToLogicalConverter) TransactionApplier(org.neo4j.kernel.impl.api.TransactionApplier) PropertyLoader(org.neo4j.kernel.impl.transaction.state.PropertyLoader) NodeStore(org.neo4j.kernel.impl.store.NodeStore) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) Supplier(java.util.function.Supplier) LabelScanWriter(org.neo4j.kernel.api.labelscan.LabelScanWriter) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) Test(org.junit.Test)

Example 7 with PropertyStore

use of org.neo4j.kernel.impl.store.PropertyStore in project neo4j by neo4j.

the class MultipleIndexPopulatorUpdatesTest method updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan.

@Test
public void updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan() throws IndexPopulationFailedKernelException, IOException, IndexEntryConflictException {
    NeoStores neoStores = Mockito.mock(NeoStores.class);
    CountsTracker countsTracker = mock(CountsTracker.class);
    NodeStore nodeStore = mock(NodeStore.class);
    PropertyStore propertyStore = mock(PropertyStore.class);
    NodeRecord nodeRecord = getNodeRecord();
    PropertyRecord propertyRecord = getPropertyRecord();
    when(neoStores.getCounts()).thenReturn(countsTracker);
    when(neoStores.getNodeStore()).thenReturn(nodeStore);
    when(neoStores.getPropertyStore()).thenReturn(propertyStore);
    when(propertyStore.getPropertyRecordChain(anyInt())).thenReturn(Collections.singletonList(propertyRecord));
    when(countsTracker.nodeCount(anyInt(), any(Register.DoubleLongRegister.class))).thenReturn(Registers.newDoubleLongRegister(3, 3));
    when(nodeStore.getHighestPossibleIdInUse()).thenReturn(20L);
    when(nodeStore.newRecord()).thenReturn(nodeRecord);
    when(nodeStore.getRecord(anyInt(), eq(nodeRecord), any(RecordLoad.class))).thenAnswer(new SetNodeIdRecordAnswer(nodeRecord, 1));
    when(nodeStore.getRecord(eq(7L), eq(nodeRecord), any(RecordLoad.class))).thenAnswer(new SetNodeIdRecordAnswer(nodeRecord, 7));
    ProcessListenableNeoStoreIndexView storeView = new ProcessListenableNeoStoreIndexView(LockService.NO_LOCK_SERVICE, neoStores);
    MultipleIndexPopulator indexPopulator = new MultipleIndexPopulator(storeView, logProvider);
    storeView.setProcessListener(new NodeUpdateProcessListener(indexPopulator));
    IndexPopulator populator = createIndexPopulator();
    IndexUpdater indexUpdater = mock(IndexUpdater.class);
    when(populator.newPopulatingUpdater(storeView)).thenReturn(indexUpdater);
    addPopulator(indexPopulator, populator, 1, NewIndexDescriptorFactory.forLabel(1, 1));
    indexPopulator.create();
    StoreScan<IndexPopulationFailedKernelException> storeScan = indexPopulator.indexAllNodes();
    storeScan.run();
    Mockito.verify(indexUpdater, times(0)).process(any(IndexEntryUpdate.class));
}
Also used : IndexEntryUpdate(org.neo4j.kernel.api.index.IndexEntryUpdate) IndexPopulationFailedKernelException(org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) NodeStore(org.neo4j.kernel.impl.store.NodeStore) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) NeoStores(org.neo4j.kernel.impl.store.NeoStores) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) Test(org.junit.Test)

Aggregations

PropertyStore (org.neo4j.kernel.impl.store.PropertyStore)7 NeoStores (org.neo4j.kernel.impl.store.NeoStores)5 NodeStore (org.neo4j.kernel.impl.store.NodeStore)5 Test (org.junit.Test)2 DynamicArrayStore (org.neo4j.kernel.impl.store.DynamicArrayStore)2 DynamicStringStore (org.neo4j.kernel.impl.store.DynamicStringStore)2 RelationshipGroupStore (org.neo4j.kernel.impl.store.RelationshipGroupStore)2 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Supplier (java.util.function.Supplier)1 WorkSync (org.neo4j.concurrent.WorkSync)1 IndexPopulationFailedKernelException (org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException)1 IndexEntryUpdate (org.neo4j.kernel.api.index.IndexEntryUpdate)1 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)1 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)1 LabelScanWriter (org.neo4j.kernel.api.labelscan.LabelScanWriter)1 TransactionApplier (org.neo4j.kernel.impl.api.TransactionApplier)1 TransactionToApply (org.neo4j.kernel.impl.api.TransactionToApply)1 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)1