use of org.neo4j.kernel.impl.store.AbstractDynamicStore in project neo4j by neo4j.
the class DeleteDuplicateNodesStepTest method shouldDeleteEverythingAboutTheDuplicatedNodes.
@RepeatedTest(10)
void shouldDeleteEverythingAboutTheDuplicatedNodes() throws Exception {
// given
Ids[] ids = new Ids[9];
DataImporter.Monitor monitor = new DataImporter.Monitor();
// node with many properties and many labels
ids[0] = createNode(monitor, neoStores, 10, 10);
// node with many properties and few labels
ids[1] = createNode(monitor, neoStores, 10, 1);
// node with many properties and no labels
ids[2] = createNode(monitor, neoStores, 10, 0);
// node with few properties and many labels
ids[3] = createNode(monitor, neoStores, 1, 10);
// node with few properties and few labels
ids[4] = createNode(monitor, neoStores, 1, 1);
// node with few properties and no labels
ids[5] = createNode(monitor, neoStores, 1, 0);
// node with no properties and many labels
ids[6] = createNode(monitor, neoStores, 0, 10);
// node with no properties and few labels
ids[7] = createNode(monitor, neoStores, 0, 1);
// node with no properties and no labels
ids[8] = createNode(monitor, neoStores, 0, 0);
// when
long[] duplicateNodeIds = randomNodes(ids);
SimpleStageControl control = new SimpleStageControl();
try (DeleteDuplicateNodesStep step = new DeleteDuplicateNodesStep(control, Configuration.DEFAULT, iterator(duplicateNodeIds), neoStores.getNodeStore(), neoStores.getPropertyStore(), monitor, PageCacheTracer.NULL)) {
control.steps(step);
startAndAwaitCompletionOf(step);
}
control.assertHealthy();
// then
int expectedNodes = 0;
int expectedProperties = 0;
for (Ids entity : ids) {
boolean expectedToBeInUse = !ArrayUtils.contains(duplicateNodeIds, entity.node.getId());
int stride = expectedToBeInUse ? 1 : 0;
expectedNodes += stride;
// Verify node record
assertEquals(expectedToBeInUse, neoStores.getNodeStore().isInUse(entity.node.getId(), NULL));
// Verify label records
for (DynamicRecord labelRecord : entity.node.getDynamicLabelRecords()) {
assertEquals(expectedToBeInUse, neoStores.getNodeStore().getDynamicLabelStore().isInUse(labelRecord.getId(), NULL));
}
// Verify property records
for (PropertyRecord propertyRecord : entity.properties) {
assertEquals(expectedToBeInUse, neoStores.getPropertyStore().isInUse(propertyRecord.getId(), NULL));
for (PropertyBlock property : propertyRecord) {
// Verify property dynamic value records
for (DynamicRecord valueRecord : property.getValueRecords()) {
AbstractDynamicStore valueStore;
switch(property.getType()) {
case STRING:
valueStore = neoStores.getPropertyStore().getStringStore();
break;
case ARRAY:
valueStore = neoStores.getPropertyStore().getArrayStore();
break;
default:
throw new IllegalArgumentException(propertyRecord + " " + property);
}
assertEquals(expectedToBeInUse, valueStore.isInUse(valueRecord.getId(), NULL));
}
expectedProperties += stride;
}
}
}
assertEquals(expectedNodes, monitor.nodesImported());
assertEquals(expectedProperties, monitor.propertiesImported());
}
use of org.neo4j.kernel.impl.store.AbstractDynamicStore in project neo4j by neo4j.
the class PropertyDeleterTest method makeSomeUnusedIn.
private void makeSomeUnusedIn(PropertyBlock dynamicBlock) {
propertyStore.ensureHeavy(dynamicBlock, NULL);
DynamicRecord valueRecord = dynamicBlock.getValueRecords().get(random.nextInt(dynamicBlock.getValueRecords().size()));
PropertyType type = valueRecord.getType();
valueRecord.setInUse(false);
AbstractDynamicStore dynamicStore = type == PropertyType.STRING ? propertyStore.getStringStore() : propertyStore.getArrayStore();
dynamicStore.updateRecord(valueRecord, NULL);
}
use of org.neo4j.kernel.impl.store.AbstractDynamicStore in project neo4j by neo4j.
the class PropertyDeleterTest method createCycleIn.
private void createCycleIn(PropertyBlock dynamicBlock) {
propertyStore.ensureHeavy(dynamicBlock, NULL);
int cycleEndIndex = random.nextInt(1, dynamicBlock.getValueRecords().size() - 1);
int cycleStartIndex = random.nextInt(cycleEndIndex);
DynamicRecord cycleEndRecord = dynamicBlock.getValueRecords().get(cycleEndIndex);
PropertyType type = cycleEndRecord.getType();
cycleEndRecord.setNextBlock(dynamicBlock.getValueRecords().get(cycleStartIndex).getId());
AbstractDynamicStore dynamicStore = type == PropertyType.STRING ? propertyStore.getStringStore() : propertyStore.getArrayStore();
dynamicStore.updateRecord(cycleEndRecord, NULL);
}
Aggregations