Search in sources :

Example 11 with DynamicRecord

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

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

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

use of org.neo4j.kernel.impl.store.record.DynamicRecord 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)

Example 15 with DynamicRecord

use of org.neo4j.kernel.impl.store.record.DynamicRecord 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)

Aggregations

DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)225 Test (org.junit.Test)117 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)51 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)38 ArrayList (java.util.ArrayList)32 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)28 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)23 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)21 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)21 IOException (java.io.IOException)20 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)16 ReusableRecordsAllocator (org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator)16 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)16 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)16 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)15 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)15 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)15 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)15 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)14 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)14