Search in sources :

Example 71 with DynamicRecord

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

the class TestArrayStore method stringArrayGetsStoredAsUtf8.

@Test
public void stringArrayGetsStoredAsUtf8() throws Exception {
    String[] array = new String[] { "first", "second" };
    Collection<DynamicRecord> records = new ArrayList<>();
    arrayStore.allocateRecords(records, array);
    Pair<byte[], byte[]> loaded = loadArray(records);
    assertStringHeader(loaded.first(), array.length);
    ByteBuffer buffer = ByteBuffer.wrap(loaded.other());
    for (String item : array) {
        byte[] expectedData = UTF8.encode(item);
        assertEquals(expectedData.length, buffer.getInt());
        byte[] loadedItem = new byte[expectedData.length];
        buffer.get(loadedItem);
        assertTrue(Arrays.equals(expectedData, loadedItem));
    }
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 72 with DynamicRecord

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

the class NodeRecordTest method newDeletedDynamicRecord.

private DynamicRecord newDeletedDynamicRecord(long id) {
    DynamicRecord record = new DynamicRecord(id);
    record.setInUse(false);
    return record;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord)

Example 73 with DynamicRecord

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

the class NodeRecordTest method shouldListLabelRecordsInUse.

@Test
public void shouldListLabelRecordsInUse() throws Exception {
    // Given
    NodeRecord node = new NodeRecord(1, false, -1, -1);
    long inlinedLabels = 12L;
    DynamicRecord dynamic1 = dynamicRecord(1L, true);
    DynamicRecord dynamic2 = dynamicRecord(2L, true);
    DynamicRecord dynamic3 = dynamicRecord(3L, true);
    node.setLabelField(inlinedLabels, asList(dynamic1, dynamic2, dynamic3));
    dynamic3.setInUse(false);
    // When
    Iterable<DynamicRecord> usedRecords = node.getUsedDynamicLabelRecords();
    // Then
    assertThat(asList(usedRecords), equalTo(asList(dynamic1, dynamic2)));
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Test(org.junit.Test)

Example 74 with DynamicRecord

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

the class NodeRecordTest method cloneShouldProduceExactCopy.

@Test
public void cloneShouldProduceExactCopy() throws Exception {
    // Given
    long relId = 1337L;
    long propId = 1338L;
    long inlinedLabels = 12L;
    NodeRecord node = new NodeRecord(1L, false, relId, propId);
    node.setLabelField(inlinedLabels, asList(new DynamicRecord(1L), new DynamicRecord(2L)));
    node.setInUse(true);
    // When
    NodeRecord clone = node.clone();
    // Then
    assertEquals(node.inUse(), clone.inUse());
    assertEquals(node.getLabelField(), clone.getLabelField());
    assertEquals(node.getNextProp(), clone.getNextProp());
    assertEquals(node.getNextRel(), clone.getNextRel());
    assertThat(clone.getDynamicLabelRecords(), equalTo(node.getDynamicLabelRecords()));
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Test(org.junit.Test)

Example 75 with DynamicRecord

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

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