Search in sources :

Example 91 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord 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 92 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord 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 93 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.

the class NodeLabelsFieldTest method shouldReadIdOfDynamicRecordFromDynamicLabelsField.

@Test
public void shouldReadIdOfDynamicRecordFromDynamicLabelsField() throws Exception {
    // GIVEN
    NodeRecord node = nodeRecordWithDynamicLabels(nodeStore, oneByteLongs(5));
    DynamicRecord dynamicRecord = node.getDynamicLabelRecords().iterator().next();
    // WHEN
    long dynRecordId = NodeLabelsField.firstDynamicLabelRecordId(node.getLabelField());
    // THEN
    assertEquals(dynamicRecord.getId(), dynRecordId);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Test(org.junit.Test)

Example 94 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord 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 95 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.

the class NodeLabelsFieldTest method nodeRecordWithDynamicLabels.

private NodeRecord nodeRecordWithDynamicLabels(long nodeId, NodeStore nodeStore, long... labels) {
    NodeRecord node = new NodeRecord(nodeId, false, 0, 0);
    Collection<DynamicRecord> initialRecords = allocateAndApply(nodeStore, node.getId(), labels);
    node.setLabelField(dynamicLabelsLongRepresentation(initialRecords), initialRecords);
    return node;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord)

Aggregations

NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)391 Test (org.junit.Test)154 Test (org.junit.jupiter.api.Test)108 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)73 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)63 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)58 NodeLabels (org.neo4j.kernel.impl.store.NodeLabels)46 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)42 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)40 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)40 DynamicNodeLabels (org.neo4j.kernel.impl.store.DynamicNodeLabels)38 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)32 ArrayList (java.util.ArrayList)30 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)30 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)30 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)30 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)30 NodeStore (org.neo4j.kernel.impl.store.NodeStore)28 Command (org.neo4j.kernel.impl.transaction.command.Command)27 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)17