Search in sources :

Example 51 with PropertyBlock

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

the class NeoStoreIndexStoreView method nodeAsUpdates.

@Override
public void nodeAsUpdates(long nodeId, Collection<NodeUpdates> target) {
    NodeRecord node = nodeStore.getRecord(nodeId, nodeStore.newRecord(), FORCE);
    if (!node.inUse()) {
        return;
    }
    long firstPropertyId = node.getNextProp();
    if (firstPropertyId == Record.NO_NEXT_PROPERTY.intValue()) {
        // no properties => no updates (it's not going to be in any index)
        return;
    }
    long[] labels = parseLabelsField(node).get(nodeStore);
    if (labels.length == 0) {
        // no labels => no updates (it's not going to be in any index)
        return;
    }
    NodeUpdates.Builder update = NodeUpdates.forNode(nodeId, labels);
    for (PropertyRecord propertyRecord : propertyStore.getPropertyRecordChain(firstPropertyId)) {
        for (PropertyBlock property : propertyRecord) {
            Object value = property.getType().getValue(property, propertyStore);
            update.added(property.getKeyIndexId(), value);
        }
    }
    target.add(update.build());
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 52 with PropertyBlock

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

the class NeoStoreIndexStoreView method getProperty.

@Override
public Property getProperty(long nodeId, int propertyKeyId) throws EntityNotFoundException {
    NodeRecord node = nodeStore.getRecord(nodeId, nodeStore.newRecord(), FORCE);
    if (!node.inUse()) {
        throw new EntityNotFoundException(EntityType.NODE, nodeId);
    }
    long firstPropertyId = node.getNextProp();
    if (firstPropertyId == Record.NO_NEXT_PROPERTY.intValue()) {
        return Property.noNodeProperty(nodeId, propertyKeyId);
    }
    for (PropertyRecord propertyRecord : propertyStore.getPropertyRecordChain(firstPropertyId)) {
        PropertyBlock propertyBlock = propertyRecord.getPropertyBlock(propertyKeyId);
        if (propertyBlock != null) {
            return propertyBlock.newPropertyData(propertyStore);
        }
    }
    return Property.noNodeProperty(nodeId, propertyKeyId);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException)

Example 53 with PropertyBlock

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

the class StoreViewNodeStoreScan method process.

@Override
public void process(NodeRecord node) throws FAILURE {
    long[] labels = parseLabelsField(node).get(this.nodeStore);
    if (labels.length == 0) {
        // This node has no labels at all
        return;
    }
    if (labelUpdateVisitor != null) {
        // Notify the label update visitor
        labelUpdateVisitor.visit(labelChanges(node.getId(), EMPTY_LONG_ARRAY, labels));
    }
    if (propertyUpdatesVisitor != null && containsAnyLabel(labelIds, labels)) {
        // TODO: reuse object instead? Better in terms of speed and GC?
        NodeUpdates.Builder updates = NodeUpdates.forNode(node.getId(), labels);
        // Notify the property update visitor
        for (PropertyBlock property : properties(node)) {
            int propertyKeyId = property.getKeyIndexId();
            if (propertyKeyIdFilter.test(propertyKeyId)) {
                // This node has a property of interest to us
                Object value = valueOf(property);
                Validators.INDEX_VALUE_VALIDATOR.validate(value);
                updates.added(propertyKeyId, value);
            }
        }
        if (updates.hasUpdates()) {
            propertyUpdatesVisitor.visit(updates.build());
        }
    }
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 54 with PropertyBlock

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

the class ChainCheck method keys.

public static int[] keys(PropertyRecord property) {
    int[] toStartWith = new int[MAX_BLOCK_PER_RECORD_COUNT];
    int index = 0;
    for (PropertyBlock propertyBlock : property) {
        toStartWith[index++] = propertyBlock.getKeyIndexId();
    }
    return Arrays.copyOf(toStartWith, index);
}
Also used : PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 55 with PropertyBlock

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

the class PropertyReader method propertyBlocks.

public List<PropertyBlock> propertyBlocks(NodeRecord nodeRecord) {
    Collection<PropertyRecord> records = propertyStore.getPropertyRecordChain(nodeRecord.getNextProp());
    List<PropertyBlock> propertyBlocks = new ArrayList<>();
    for (PropertyRecord record : records) {
        for (PropertyBlock block : record) {
            propertyBlocks.add(block);
        }
    }
    return propertyBlocks;
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) ArrayList(java.util.ArrayList) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Aggregations

PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)90 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)57 Test (org.junit.Test)21 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)16 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)9 IOException (java.io.IOException)8 InterruptedIOException (java.io.InterruptedIOException)8 Pair (org.neo4j.helpers.collection.Pair)8 DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)8 ArrayMap (org.neo4j.kernel.impl.util.ArrayMap)8 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)6 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)6 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)5 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)5 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)5 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)5 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)4 ChainCheck (org.neo4j.consistency.checking.ChainCheck)3 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)3 DynamicRecordAllocator (org.neo4j.kernel.impl.store.DynamicRecordAllocator)3