Search in sources :

Example 56 with NodeRecord

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

the class PhysicalLogCommandReaderV3_0 method readNodeRecord.

private NodeRecord readNodeRecord(long id, ReadableChannel channel) throws IOException {
    byte flags = channel.get();
    boolean inUse = bitFlag(flags, Record.IN_USE.byteValue());
    boolean requiresSecondaryUnit = bitFlag(flags, Record.REQUIRE_SECONDARY_UNIT);
    boolean hasSecondaryUnit = bitFlag(flags, Record.HAS_SECONDARY_UNIT);
    NodeRecord record;
    Collection<DynamicRecord> dynamicLabelRecords = new ArrayList<>();
    long labelField = Record.NO_LABELS_FIELD.intValue();
    if (inUse) {
        boolean dense = channel.get() == 1;
        record = new NodeRecord(id, dense, channel.getLong(), channel.getLong());
        // labels
        labelField = channel.getLong();
        record.setRequiresSecondaryUnit(requiresSecondaryUnit);
        if (hasSecondaryUnit) {
            record.setSecondaryUnitId(channel.getLong());
        }
    } else {
        record = new NodeRecord(id);
    }
    readDynamicRecords(channel, dynamicLabelRecords, COLLECTION_DYNAMIC_RECORD_ADDER);
    record.setLabelField(labelField, dynamicLabelRecords);
    record.setInUse(inUse);
    return record;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) ArrayList(java.util.ArrayList)

Example 57 with NodeRecord

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

the class NodeStoreTest method shouldTellNodeInUse.

@Test
public void shouldTellNodeInUse() throws Exception {
    // Given
    EphemeralFileSystemAbstraction fs = efs.get();
    NodeStore store = newNodeStore(fs);
    long exists = store.nextId();
    store.updateRecord(new NodeRecord(exists, false, 10, 20, true));
    long deleted = store.nextId();
    store.updateRecord(new NodeRecord(deleted, false, 10, 20, true));
    store.updateRecord(new NodeRecord(deleted, false, 10, 20, false));
    // When & then
    assertTrue(store.isInUse(exists));
    assertFalse(store.isInUse(deleted));
    assertFalse(store.isInUse(nodeStore.recordFormat.getMaxId()));
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) Test(org.junit.Test)

Example 58 with NodeRecord

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

the class CommonAbstractStoreTest method insertNodeRecordAndObservePinEvent.

private long insertNodeRecordAndObservePinEvent(RecordingPageCursorTracer tracer, NodeStore store) {
    long nodeId = store.nextId();
    NodeRecord record = store.newRecord();
    record.setId(nodeId);
    record.initialize(true, NO_NEXT_PROPERTY.intValue(), false, NO_NEXT_RELATIONSHIP.intValue(), 42);
    store.prepareForCommit(record);
    store.updateRecord(record);
    assertNotNull(tracer.tryObserve(Pin.class));
    assertNull(tracer.tryObserve(Event.class));
    return nodeId;
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Pin(org.neo4j.io.pagecache.tracing.recording.RecordingPageCursorTracer.Pin) Event(org.neo4j.io.pagecache.tracing.recording.Event)

Example 59 with NodeRecord

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

the class FreeIdsAfterRecoveryTest method node.

private NodeRecord node(long nextId) {
    NodeRecord node = new NodeRecord(nextId);
    node.setInUse(true);
    return node;
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord)

Example 60 with NodeRecord

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

the class PropertyAndNode2LabelIndexProcessor method process.

@Override
public void process(NodeRecord nodeRecord) {
    reporter.forNode(nodeRecord, nodeIndexCheck);
    CacheAccess.Client client = cacheAccess.client();
    try (MandatoryProperties.Check<NodeRecord, ConsistencyReport.NodeConsistencyReport> mandatoryCheck = mandatoryProperties.apply(nodeRecord)) {
        Iterable<PropertyRecord> properties = client.getPropertiesFromCache();
        // go by unnoticed.
        if (properties != null) {
            for (PropertyRecord property : properties) {
                reporter.forProperty(property, propertyCheck);
                mandatoryCheck.receive(ChainCheck.keys(property));
            }
        }
    }
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) CacheAccess(org.neo4j.consistency.checking.cache.CacheAccess) NodeConsistencyReport(org.neo4j.consistency.report.ConsistencyReport.NodeConsistencyReport)

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