use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeInUseWithCorrectLabelsCheck method checkReference.
@Override
public void checkReference(RECORD record, NodeRecord nodeRecord, CheckerEngine<RECORD, REPORT> engine, RecordAccess records) {
if (nodeRecord.inUse()) {
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(nodeRecord);
if (nodeLabels instanceof DynamicNodeLabels) {
DynamicNodeLabels dynamicNodeLabels = (DynamicNodeLabels) nodeLabels;
long firstRecordId = dynamicNodeLabels.getFirstDynamicRecordId();
RecordReference<DynamicRecord> firstRecordReference = records.nodeLabels(firstRecordId);
ExpectedNodeLabelsChecker expectedNodeLabelsChecker = new ExpectedNodeLabelsChecker(nodeRecord);
LabelChainWalker<RECORD, REPORT> checker = new LabelChainWalker<>(expectedNodeLabelsChecker);
engine.comparativeCheck(firstRecordReference, checker);
// I think this is empty in production
nodeRecord.getDynamicLabelRecords();
} else {
long[] storeLabels = nodeLabels.get(null);
REPORT report = engine.report();
validateLabelIds(nodeRecord, storeLabels, report);
}
} else {
engine.report().nodeNotInUse(nodeRecord);
}
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class BatchInserterImpl method setNodeLabels.
private void setNodeLabels(NodeRecord nodeRecord, Label... labels) {
NodeLabels nodeLabels = parseLabelsField(nodeRecord);
nodeLabels.put(getOrCreateLabelIds(labels), nodeStore, nodeStore.getDynamicLabelStore());
labelsTouched = true;
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeCommandTest method shouldSerializeDynamicRecordLabels.
@Test
public void shouldSerializeDynamicRecordLabels() throws Exception {
// Given
NodeRecord before = new NodeRecord(12, false, 1, 2);
before.setInUse(true);
NodeRecord after = new NodeRecord(12, false, 2, 1);
after.setInUse(true);
NodeLabels nodeLabels = parseLabelsField(after);
for (int i = 10; i < 100; i++) {
nodeLabels.add(i, nodeStore, nodeStore.getDynamicLabelStore());
}
// When
assertSerializationWorksFor(new Command.NodeCommand(before, after));
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method shouldReallocateSomeOfPreviousDynamicRecords.
@Test
public void shouldReallocateSomeOfPreviousDynamicRecords() throws Exception {
// GIVEN
NodeRecord node = nodeRecordWithDynamicLabels(nodeStore, oneByteLongs(5));
Set<DynamicRecord> initialRecords = Iterables.asUniqueSet(node.getDynamicLabelRecords());
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
// WHEN
Set<DynamicRecord> reallocatedRecords = Iterables.asUniqueSet(nodeLabels.put(fourByteLongs(100), nodeStore, nodeStore.getDynamicLabelStore()));
// THEN
assertTrue(reallocatedRecords.containsAll(initialRecords));
assertTrue(reallocatedRecords.size() > initialRecords.size());
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method shouldInlineTwoSmallLabels.
@Test
public void shouldInlineTwoSmallLabels() throws Exception {
// GIVEN
long labelId1 = 10, labelId2 = 30;
NodeRecord node = nodeRecordWithInlinedLabels(labelId1);
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
// WHEN
nodeLabels.add(labelId2, null, null);
// THEN
assertEquals(inlinedLabelsLongRepresentation(labelId1, labelId2), node.getLabelField());
}
Aggregations