Search in sources :

Example 36 with NodeLabels

use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.

the class NodeLabelsFieldTest method shouldInlineFiveSmallLabels.

@Test
void shouldInlineFiveSmallLabels() {
    // GIVEN
    long labelId1 = 10;
    long labelId2 = 30;
    long labelId3 = 45;
    long labelId4 = 60;
    long labelId5 = 61;
    NodeRecord node = nodeRecordWithInlinedLabels(labelId1, labelId2, labelId3, labelId4);
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    // WHEN
    nodeLabels.add(labelId5, null, null, NULL, INSTANCE);
    // THEN
    assertEquals(inlinedLabelsLongRepresentation(labelId1, labelId2, labelId3, labelId4, labelId5), node.getLabelField());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) Test(org.junit.jupiter.api.Test)

Example 37 with NodeLabels

use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.

the class NodeLabelsFieldTest method shouldInlineOneLabel.

@Test
void shouldInlineOneLabel() {
    // GIVEN
    long labelId = 10;
    NodeRecord node = nodeRecordWithInlinedLabels();
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    // WHEN
    nodeLabels.add(labelId, null, null, NULL, INSTANCE);
    // THEN
    assertEquals(inlinedLabelsLongRepresentation(labelId), node.getLabelField());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) Test(org.junit.jupiter.api.Test)

Example 38 with NodeLabels

use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.

the class NodeLabelsFieldTest method shouldInlineThreeSmallLabels.

@Test
void shouldInlineThreeSmallLabels() {
    // GIVEN
    long labelId1 = 10;
    long labelId2 = 30;
    long labelId3 = 4095;
    NodeRecord node = nodeRecordWithInlinedLabels(labelId1, labelId2);
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    // WHEN
    nodeLabels.add(labelId3, null, null, NULL, INSTANCE);
    // THEN
    assertEquals(inlinedLabelsLongRepresentation(labelId1, labelId2, labelId3), node.getLabelField());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) Test(org.junit.jupiter.api.Test)

Example 39 with NodeLabels

use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.

the class NodeLabelsFieldTest method removingNonExistentInlinedLabelShouldFail.

@Test
void removingNonExistentInlinedLabelShouldFail() {
    // GIVEN
    int labelId1 = 1;
    int labelId2 = 2;
    NodeRecord node = nodeRecordWithInlinedLabels(labelId1);
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    assertThrows(IllegalStateException.class, () -> nodeLabels.remove(labelId2, nodeStore, NULL, INSTANCE));
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) Test(org.junit.jupiter.api.Test)

Example 40 with NodeLabels

use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.

the class NodeLabelsFieldTest method twoDynamicRecordsShouldShrinkToOneWhenRemovingWithoutChangingItsOwner.

@Test
void twoDynamicRecordsShouldShrinkToOneWhenRemovingWithoutChangingItsOwner() {
    // GIVEN
    // will occupy 61B of data, i.e. just two dynamic records
    Long nodeId = 42L;
    NodeRecord node = nodeRecordWithDynamicLabels(nodeId, nodeStore, oneByteLongs(57));
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    List<DynamicRecord> changedDynamicRecords = addAll(new ArrayList<>(), nodeLabels.remove(255, /*Initial labels go from 255 and down to 255-58*/
    nodeStore, NULL, INSTANCE));
    // WHEN
    Pair<Long, long[]> changedPair = DynamicNodeLabels.getDynamicLabelsArrayAndOwner(changedDynamicRecords, nodeStore.getDynamicLabelStore(), NULL);
    // THEN
    assertEquals(nodeId, changedPair.first());
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) Test(org.junit.jupiter.api.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