use of org.neo4j.kernel.impl.store.NodeStore in project neo4j by neo4j.
the class PropertyDeleterTest method shouldHandlePropertyChainDeletionOnDynamicRecordCycle.
@ValueSource(booleans = { true, false })
@ParameterizedTest
void shouldHandlePropertyChainDeletionOnDynamicRecordCycle(boolean log) {
// given
startStore(log);
NodeStore nodeStore = neoStores.getNodeStore();
NodeRecord node = nodeStore.newRecord();
node.setId(nodeStore.nextId(NULL));
List<PropertyBlock> properties = Collections.singletonList(encodedValue(0, random.randomValues().nextAsciiTextValue(1000, 1000)));
DirectRecordAccessSet initialChanges = new DirectRecordAccessSet(neoStores, idGeneratorFactory, NULL);
long firstPropId = propertyCreator.createPropertyChain(node, properties.iterator(), initialChanges.getPropertyRecords());
node.setNextProp(firstPropId);
// should update all the changed records directly into the store
initialChanges.commit();
// create a cycle in the dynamic record chain cycle
PropertyRecord firstPropRecord = propertyStore.getRecord(firstPropId, propertyStore.newRecord(), RecordLoad.NORMAL, NULL);
PropertyBlock dynamicBlock = firstPropRecord.iterator().next();
createCycleIn(dynamicBlock);
// when
DirectRecordAccessSet changes = new DirectRecordAccessSet(neoStores, idGeneratorFactory, NULL);
deleter.deletePropertyChain(node, changes.getPropertyRecords());
changes.commit();
// then
assertEquals(Record.NO_NEXT_PROPERTY.longValue(), node.getNextProp());
assertLogContains("Deleted inconsistent property chain", log);
}
use of org.neo4j.kernel.impl.store.NodeStore in project neo4j by neo4j.
the class StoreMigrator method legacyNodesAsInput.
private InputIterable<InputNode> legacyNodesAsInput(NeoStores legacyStore, boolean requiresPropertyMigration, RecordCursors cursors) {
NodeStore store = legacyStore.getNodeStore();
final BiConsumer<InputNode, NodeRecord> propertyDecorator = propertyDecorator(requiresPropertyMigration, cursors);
return new StoreScanAsInputIterable<InputNode, NodeRecord>(store) {
@Override
protected InputNode inputEntityOf(NodeRecord record) {
InputNode node = new InputNode("legacy store", record.getId(), record.getId() * NodeRecordFormat.RECORD_SIZE, record.getId(), InputEntity.NO_PROPERTIES, record.getNextProp(), InputNode.NO_LABELS, record.getLabelField());
propertyDecorator.accept(node, record);
return node;
}
};
}
use of org.neo4j.kernel.impl.store.NodeStore in project neo4j by neo4j.
the class PropertyDeduplicator method deduplicateProperties.
public void deduplicateProperties() throws IOException {
StoreFactory factory = new StoreFactory(workingDir, pageCache, fileSystem, NullLogProvider.getInstance());
try (NeoStores neoStores = factory.openNeoStores(StoreType.PROPERTY, StoreType.NODE, StoreType.SCHEMA)) {
PropertyStore propertyStore = neoStores.getPropertyStore();
NodeStore nodeStore = neoStores.getNodeStore();
SchemaStore schemaStore = neoStores.getSchemaStore();
PrimitiveLongObjectMap<List<DuplicateCluster>> duplicateClusters = collectConflictingProperties(propertyStore);
resolveConflicts(duplicateClusters, propertyStore, nodeStore, schemaStore, neoStores.getStoreDir());
}
}
use of org.neo4j.kernel.impl.store.NodeStore in project neo4j by neo4j.
the class NodeRecordCheckTest method shouldProperlyReportOutOfOrderLabelsThatAreFarAway.
@Test
public void shouldProperlyReportOutOfOrderLabelsThatAreFarAway() throws Exception {
// given
final NodeRecord node = inUse(new NodeRecord(42, false, NONE, NONE));
// We need to do this override so we can put the labels unsorted, since InlineNodeLabels always sorts on insert
new InlineNodeLabels(node) {
@Override
public Collection<DynamicRecord> put(long[] labelIds, NodeStore nodeStore, DynamicRecordAllocator allocator) {
return putSorted(node, labelIds, nodeStore, allocator);
}
}.put(new long[] { 1, 18, 13, 14, 15, 16, 12 }, null, null);
LabelTokenRecord label1 = inUse(new LabelTokenRecord(1));
LabelTokenRecord label12 = inUse(new LabelTokenRecord(12));
LabelTokenRecord label13 = inUse(new LabelTokenRecord(13));
LabelTokenRecord label14 = inUse(new LabelTokenRecord(14));
LabelTokenRecord label15 = inUse(new LabelTokenRecord(15));
LabelTokenRecord label16 = inUse(new LabelTokenRecord(16));
LabelTokenRecord label18 = inUse(new LabelTokenRecord(18));
add(label1);
add(label12);
add(label13);
add(label14);
add(label15);
add(label16);
add(label18);
add(node);
// when
ConsistencyReport.NodeConsistencyReport report = check(node);
// then
verify(report).labelsOutOfOrder(18, 13);
verify(report).labelsOutOfOrder(16, 12);
}
use of org.neo4j.kernel.impl.store.NodeStore in project neo4j by neo4j.
the class TransactionRecordStateTest method assertRelationshipGroupsInOrder.
private void assertRelationshipGroupsInOrder(NeoStores neoStores, long nodeId, int... types) {
NodeStore nodeStore = neoStores.getNodeStore();
NodeRecord node = nodeStore.getRecord(nodeId, nodeStore.newRecord(), NORMAL);
assertTrue("Node should be dense, is " + node, node.isDense());
long groupId = node.getNextRel();
int cursor = 0;
List<RelationshipGroupRecord> seen = new ArrayList<>();
while (groupId != Record.NO_NEXT_RELATIONSHIP.intValue()) {
RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore();
RelationshipGroupRecord group = relationshipGroupStore.getRecord(groupId, relationshipGroupStore.newRecord(), NORMAL);
seen.add(group);
assertEquals("Invalid type, seen groups so far " + seen, types[cursor++], group.getType());
groupId = group.getNext();
}
assertEquals("Not enough relationship group records found in chain for " + node, types.length, cursor);
}
Aggregations