Search in sources :

Example 51 with NodeRecord

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

the class PhysicalLogCommandReaderV3_0_2 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 52 with NodeRecord

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

the class PropertyLoader method nodeLoadProperties.

public <RECEIVER extends PropertyReceiver> RECEIVER nodeLoadProperties(long nodeId, RECEIVER receiver) {
    NodeRecord nodeRecord = nodeStore.getRecord(nodeId, nodeStore.newRecord(), NORMAL);
    loadProperties(nodeRecord.getNextProp(), receiver);
    return receiver;
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord)

Example 53 with NodeRecord

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

the class RelationshipCreator method relationshipCreate.

/**
     * Creates a relationship with the given id, from the nodes identified by id
     * and of type typeId
     *
     * @param id The id of the relationship to create.
     * @param type The id of the relationship type this relationship will
     *            have.
     * @param firstNodeId The id of the start node.
     * @param secondNodeId The id of the end node.
     */
public void relationshipCreate(long id, int type, long firstNodeId, long secondNodeId, RecordAccessSet recordChangeSet, ResourceLocker locks) {
    // TODO could be unnecessary to mark as changed here already, dense nodes may not need to change
    NodeRecord firstNode = recordChangeSet.getNodeRecords().getOrLoad(firstNodeId, null).forChangingLinkage();
    NodeRecord secondNode = recordChangeSet.getNodeRecords().getOrLoad(secondNodeId, null).forChangingLinkage();
    convertNodeToDenseIfNecessary(firstNode, recordChangeSet.getRelRecords(), recordChangeSet.getRelGroupRecords(), locks);
    convertNodeToDenseIfNecessary(secondNode, recordChangeSet.getRelRecords(), recordChangeSet.getRelGroupRecords(), locks);
    RelationshipRecord record = recordChangeSet.getRelRecords().create(id, null).forChangingLinkage();
    record.setLinks(firstNodeId, secondNodeId, type);
    record.setInUse(true);
    record.setCreated();
    connectRelationship(firstNode, secondNode, record, recordChangeSet.getRelRecords(), recordChangeSet.getRelGroupRecords(), locks);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord)

Example 54 with NodeRecord

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

the class PhysicalLogCommandReaderV3_0 method visitNodeCommand.

private Command visitNodeCommand(ReadableChannel channel) throws IOException {
    long id = channel.getLong();
    NodeRecord before = readNodeRecord(id, channel);
    if (before == null) {
        return null;
    }
    NodeRecord after = readNodeRecord(id, channel);
    if (after == null) {
        return null;
    }
    if (!before.inUse() && after.inUse()) {
        after.setCreated();
    }
    return new Command.NodeCommand(before, after);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) AddNodeCommand(org.neo4j.kernel.impl.index.IndexCommand.AddNodeCommand)

Example 55 with NodeRecord

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

the class PhysicalLogCommandReaderV2_2_4 method readNodeRecord.

private NodeRecord readNodeRecord(long id, ReadableChannel channel) throws IOException {
    byte inUseFlag = channel.get();
    boolean inUse = false;
    if (inUseFlag == Record.IN_USE.byteValue()) {
        inUse = true;
    } else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
        throw new IOException("Illegal in use flag: " + inUseFlag);
    }
    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();
    } 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) IOException(java.io.IOException)

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