Search in sources :

Example 1 with NodeLabels

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);
    }
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) LabelChainWalker(org.neo4j.consistency.checking.LabelChainWalker) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels)

Example 2 with NodeLabels

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;
}
Also used : NodeLabels(org.neo4j.kernel.impl.store.NodeLabels)

Example 3 with NodeLabels

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));
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Command(org.neo4j.kernel.impl.transaction.command.Command) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) Test(org.junit.Test)

Example 4 with NodeLabels

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());
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) Test(org.junit.Test)

Example 5 with NodeLabels

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());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) Test(org.junit.Test)

Aggregations

NodeLabels (org.neo4j.kernel.impl.store.NodeLabels)49 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)46 DynamicNodeLabels (org.neo4j.kernel.impl.store.DynamicNodeLabels)40 Test (org.junit.Test)23 Test (org.junit.jupiter.api.Test)21 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)18 NodeStore (org.neo4j.kernel.impl.store.NodeStore)4 HashSet (java.util.HashSet)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 Command (org.neo4j.kernel.impl.transaction.command.Command)2 BatchInserter (org.neo4j.unsafe.batchinsert.BatchInserter)2 CheckerEngine (org.neo4j.consistency.checking.CheckerEngine)1 LabelChainWalker (org.neo4j.consistency.checking.LabelChainWalker)1 RecordAccess (org.neo4j.consistency.store.RecordAccess)1 InlineNodeLabels (org.neo4j.kernel.impl.store.InlineNodeLabels)1