use of org.neo4j.kernel.impl.store.NeoStores 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));
}
use of org.neo4j.kernel.impl.store.NeoStores in project neo4j by neo4j.
the class TestCrashWithRebuildSlow method getHighIds.
private static Map<IdType, Long> getHighIds(GraphDatabaseAPI db) {
final Map<IdType, Long> highIds = new HashMap<>();
NeoStores neoStores = db.getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
Visitor<CommonAbstractStore, RuntimeException> visitor = new Visitor<CommonAbstractStore, RuntimeException>() {
@Override
public boolean visit(CommonAbstractStore store) throws RuntimeException {
highIds.put(store.getIdType(), store.getHighId());
return true;
}
};
neoStores.visitStore(visitor);
return highIds;
}
use of org.neo4j.kernel.impl.store.NeoStores in project neo4j by neo4j.
the class CountsComputerTest method rebuildCounts.
private void rebuildCounts(long lastCommittedTransactionId) throws IOException {
cleanupCountsForRebuilding();
StoreFactory storeFactory = new StoreFactory(dir, pageCache, fs, NullLogProvider.getInstance());
try (Lifespan life = new Lifespan();
NeoStores neoStores = storeFactory.openAllNeoStores()) {
NodeStore nodeStore = neoStores.getNodeStore();
RelationshipStore relationshipStore = neoStores.getRelationshipStore();
int highLabelId = (int) neoStores.getLabelTokenStore().getHighId();
int highRelationshipTypeId = (int) neoStores.getRelationshipTypeTokenStore().getHighId();
CountsComputer countsComputer = new CountsComputer(lastCommittedTransactionId, nodeStore, relationshipStore, highLabelId, highRelationshipTypeId);
CountsTracker countsTracker = createCountsTracker();
life.add(countsTracker.setInitializer(countsComputer));
}
}
use of org.neo4j.kernel.impl.store.NeoStores in project neo4j by neo4j.
the class NonIndexedConflictResolverTest method setUp.
@Before
public void setUp() {
api = dbRule.getGraphDatabaseAPI();
String propKeyA = "keyA";
String propKeyB = "keyB";
String propKeyC = "keyC";
String propKeyD = "keyD";
String propKeyE = "keyE";
try (Transaction transaction = api.beginTx()) {
Node nodeA = api.createNode();
nodeA.setProperty(propKeyA, "value");
nodeA.setProperty(propKeyB, "value");
nodeIdA = nodeA.getId();
Node nodeB = api.createNode();
nodeB.setProperty(propKeyA, "value");
nodeB.setProperty(propKeyB, "value");
nodeIdB = nodeB.getId();
Node nodeC = api.createNode();
nodeC.setProperty(propKeyA, "longer val");
nodeC.setProperty(propKeyB, "longer val");
nodeC.setProperty(propKeyC, "longer val");
nodeC.setProperty(propKeyD, "longer val");
nodeC.setProperty(propKeyE, "longer val");
nodeIdC = nodeC.getId();
transaction.success();
}
DependencyResolver resolver = api.getDependencyResolver();
NeoStores neoStores = resolver.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
nodeStore = neoStores.getNodeStore();
propertyStore = neoStores.getPropertyStore();
propertyKeyTokenStore = neoStores.getPropertyKeyTokenStore();
tokenA = findTokenFor(propertyKeyTokenStore, propKeyA);
Token tokenB = findTokenFor(propertyKeyTokenStore, propKeyB);
Token tokenC = findTokenFor(propertyKeyTokenStore, propKeyC);
Token tokenD = findTokenFor(propertyKeyTokenStore, propKeyD);
Token tokenE = findTokenFor(propertyKeyTokenStore, propKeyE);
replacePropertyKey(propertyStore, nodeStore.getRecord(nodeIdA, nodeStore.newRecord(), FORCE), tokenB, tokenA);
replacePropertyKey(propertyStore, nodeStore.getRecord(nodeIdB, nodeStore.newRecord(), FORCE), tokenB, tokenA);
NodeRecord nodeRecordC = nodeStore.getRecord(nodeIdC, nodeStore.newRecord(), FORCE);
replacePropertyKey(propertyStore, nodeRecordC, tokenB, tokenA);
replacePropertyKey(propertyStore, nodeRecordC, tokenC, tokenA);
replacePropertyKey(propertyStore, nodeRecordC, tokenD, tokenA);
replacePropertyKey(propertyStore, nodeRecordC, tokenE, tokenA);
}
use of org.neo4j.kernel.impl.store.NeoStores in project neo4j by neo4j.
the class DeferredIndexedConflictResolutionTest method setUp.
@Before
public void setUp() {
GraphDatabaseFactory factory = new TestGraphDatabaseFactory();
db = factory.newEmbeddedDatabase(storePath.absolutePath());
GraphDatabaseAPI api = (GraphDatabaseAPI) db;
Label nodeLabel = Label.label("Label");
String propertyKey = "someProp";
long nodeId;
try (Transaction transaction = db.beginTx()) {
Node node = db.createNode(nodeLabel);
node.setProperty(propertyKey, "someVal");
nodeId = node.getId();
transaction.success();
}
DependencyResolver resolver = api.getDependencyResolver();
NeoStores neoStores = resolver.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
nodeStore = neoStores.getNodeStore();
propertyStore = neoStores.getPropertyStore();
Map<String, Integer> propertyKeys = PropertyDeduplicatorTestUtil.indexPropertyKeys(neoStores.getPropertyKeyTokenStore());
nodeRecord = RecordStore.getRecord(nodeStore, nodeId);
int propertyKeyId = propertyKeys.get(propertyKey);
clusterToRemove = createDuplicateCluster(propertyKeyId, nodeRecord.getNextProp());
clusters = new ArrayList<>();
clusters.add(createDuplicateCluster(propertyKeyId + 1, nodeRecord.getNextProp()));
// This is the one we want to remove
clusters.add(clusterToRemove);
clusters.add(createDuplicateCluster(propertyKeyId + 2, nodeRecord.getNextProp()));
}
Aggregations