Search in sources :

Example 6 with NodeLabels

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

the class NodeLabelsFieldTest method addingAnAlreadyAddedLabelWhenLabelsAreInlinedShouldFail.

@Test
public void addingAnAlreadyAddedLabelWhenLabelsAreInlinedShouldFail() throws Exception {
    // GIVEN
    int labelId = 1;
    NodeRecord node = nodeRecordWithInlinedLabels(labelId);
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    // WHEN
    try {
        nodeLabels.add(labelId, nodeStore, nodeStore.getDynamicLabelStore());
        fail("Should have thrown exception");
    } catch (IllegalStateException e) {
    // THEN
    }
}
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)

Example 7 with NodeLabels

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

the class NodeLabelsFieldTest method twoDynamicRecordsShouldShrinkToOneWhenRemovingWithoutChangingItsOwner.

@Test
public void twoDynamicRecordsShouldShrinkToOneWhenRemovingWithoutChangingItsOwner() throws Exception {
    // 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 = Iterables.addToCollection(nodeLabels.remove(255, /*Initial labels go from 255 and down to 255-58*/
    nodeStore), new ArrayList<DynamicRecord>());
    // WHEN
    Pair<Long, long[]> changedPair = DynamicNodeLabels.getDynamicLabelsArrayAndOwner(changedDynamicRecords, nodeStore.getDynamicLabelStore());
    // THEN
    assertEquals(nodeId, changedPair.first());
}
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 8 with NodeLabels

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

the class NodeLabelsFieldTest method shouldInlineOneLabel.

@Test
public void shouldInlineOneLabel() throws Exception {
    // GIVEN
    long labelId = 10;
    NodeRecord node = nodeRecordWithInlinedLabels();
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    // WHEN
    nodeLabels.add(labelId, null, null);
    // THEN
    assertEquals(inlinedLabelsLongRepresentation(labelId), 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)

Example 9 with NodeLabels

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

the class NodeLabelsFieldTest method maximumOfSevenInlinedLabels.

@Test
public void maximumOfSevenInlinedLabels() throws Exception {
    // GIVEN
    long[] labels = new long[] { 0, 1, 2, 3, 4, 5, 6 };
    NodeRecord node = nodeRecordWithInlinedLabels(labels);
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    // WHEN
    Iterable<DynamicRecord> changedDynamicRecords = nodeLabels.add(23, nodeStore, nodeStore.getDynamicLabelStore());
    // THEN
    assertEquals(dynamicLabelsLongRepresentation(changedDynamicRecords), node.getLabelField());
    assertEquals(1, Iterables.count(changedDynamicRecords));
}
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 10 with NodeLabels

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

the class NodeLabelsFieldTest method shouldInlineOneLabelWithHighId.

@Test
public void shouldInlineOneLabelWithHighId() throws Exception {
    // GIVEN
    long labelId = 10000;
    NodeRecord node = nodeRecordWithInlinedLabels();
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    // WHEN
    nodeLabels.add(labelId, null, null);
    // THEN
    assertEquals(inlinedLabelsLongRepresentation(labelId), 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)26 Test (org.junit.Test)23 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)23 DynamicNodeLabels (org.neo4j.kernel.impl.store.DynamicNodeLabels)21 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)10 HashSet (java.util.HashSet)2 NodeStore (org.neo4j.kernel.impl.store.NodeStore)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