Search in sources :

Example 21 with PropertyBlock

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

the class IndexConsultedPropertyBlockSweeper method visited.

@Override
public boolean visited(long propRecordId) throws IOException {
    propertyStore.getRecord(propRecordId, propertyRecord, NORMAL);
    boolean changed = false;
    Iterator<PropertyBlock> it = propertyRecord.iterator();
    while (it.hasNext()) {
        PropertyBlock block = it.next();
        if (block.getKeyIndexId() == propertyKeyId) {
            Object propertyValue = propertyStore.getValue(block);
            if (!foundExact && index.contains(nodeRecord.getId(), propertyValue)) {
                foundExact = true;
            } else {
                it.remove();
                changed = true;
            }
        }
    }
    if (changed) {
        if (propertyRecord.numberOfProperties() == 0) {
            propertyRemover.fixUpPropertyLinksAroundUnusedRecord(nodeRecord, propertyRecord);
        }
        propertyStore.updateRecord(propertyRecord);
    }
    return false;
}
Also used : PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 22 with PropertyBlock

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

the class PropertyDeduplicator method scanForDuplicates.

private void scanForDuplicates(long propertyId, Iterable<PropertyBlock> propertyBlocks) {
    for (PropertyBlock block : propertyBlocks) {
        int propertyKeyId = block.getKeyIndexId();
        // duplicate for removal.
        if (seenPropertyKeys.containsKey(propertyKeyId)) {
            DuplicateCluster cluster = localDuplicateClusters.get(propertyKeyId);
            if (cluster == null) {
                cluster = new DuplicateCluster(propertyKeyId);
                localDuplicateClusters.put(propertyKeyId, cluster);
            }
            cluster.add(seenPropertyKeys.get(propertyKeyId));
            cluster.add(propertyId);
        } else {
            seenPropertyKeys.put(propertyKeyId, propertyId);
        }
    }
}
Also used : PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 23 with PropertyBlock

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

the class PhysicalLogCommandReaderV2_0 method readPropertyBlock.

private PropertyBlock readPropertyBlock(ReadableChannel channel) throws IOException {
    PropertyBlock toReturn = new PropertyBlock();
    // the size is stored in bytes // 1
    byte blockSize = channel.get();
    assert blockSize > 0 && blockSize % 8 == 0 : blockSize + " is not a valid block size value";
    // Read in blocks
    long[] blocks = readLongs(channel, blockSize / 8);
    assert blocks.length == blockSize / 8 : blocks.length + " longs were read in while i asked for what corresponds to " + blockSize;
    assert PropertyType.getPropertyTypeOrThrow(blocks[0]).calculateNumberOfBlocksUsed(blocks[0]) == blocks.length : blocks.length + " is not a valid number of blocks for type " + PropertyType.getPropertyTypeOrThrow(blocks[0]);
    /*
         *  Ok, now we may be ready to return, if there are no DynamicRecords. So
         *  we start building the Object
         */
    toReturn.setValueBlocks(blocks);
    /*
         * Read in existence of DynamicRecords. Remember, this has already been
         * read in the buffer with the blocks, above.
         */
    if (readDynamicRecords(channel, toReturn, PROPERTY_BLOCK_DYNAMIC_RECORD_ADDER) == -1) {
        return null;
    }
    return toReturn;
}
Also used : PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 24 with PropertyBlock

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

the class PhysicalLogCommandReaderV2_1 method readPropertyRecord.

private PropertyRecord readPropertyRecord(long id, ReadableChannel channel) throws IOException {
    // in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+
    // prev_prop_id(long)+next_prop_id(long)
    PropertyRecord record = new PropertyRecord(id);
    // 1
    byte inUseFlag = channel.get();
    // 8
    long nextProp = channel.getLong();
    // 8
    long prevProp = channel.getLong();
    record.setNextProp(nextProp);
    record.setPrevProp(prevProp);
    boolean inUse = false;
    if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
        inUse = true;
    }
    boolean nodeProperty = true;
    if ((inUseFlag & Record.REL_PROPERTY.byteValue()) == Record.REL_PROPERTY.byteValue()) {
        nodeProperty = false;
    }
    // 8
    long primitiveId = channel.getLong();
    if (primitiveId != -1 && nodeProperty) {
        record.setNodeId(primitiveId);
    } else if (primitiveId != -1) {
        record.setRelId(primitiveId);
    }
    int nrPropBlocks = channel.get();
    assert nrPropBlocks >= 0;
    if (nrPropBlocks > 0) {
        record.setInUse(true);
    }
    while (nrPropBlocks-- > 0) {
        PropertyBlock block = readPropertyBlock(channel);
        if (block == null) {
            return null;
        }
        record.addPropertyBlock(block);
    }
    int deletedRecords = readDynamicRecords(channel, record, PROPERTY_DELETED_DYNAMIC_RECORD_ADDER);
    if (deletedRecords == -1) {
        return null;
    }
    if ((inUse && !record.inUse()) || (!inUse && record.inUse())) {
        throw new IllegalStateException("Weird, inUse was read in as " + inUse + " but the record is " + record);
    }
    return record;
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 25 with PropertyBlock

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

the class HighIdTransactionApplier method visitPropertyCommand.

@Override
public boolean visitPropertyCommand(PropertyCommand command) throws IOException {
    PropertyStore propertyStore = neoStores.getPropertyStore();
    track(propertyStore, command);
    for (PropertyBlock block : command.getAfter()) {
        switch(block.getType()) {
            case STRING:
                track(propertyStore.getStringStore(), block.getValueRecords());
                break;
            case ARRAY:
                track(propertyStore.getArrayStore(), block.getValueRecords());
                break;
            default:
                // Not needed, no dynamic records then
                break;
        }
    }
    return false;
}
Also used : PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore)

Aggregations

PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)139 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)86 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)25 Test (org.junit.jupiter.api.Test)16 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)14 Value (org.neo4j.values.storable.Value)13 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)10 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 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)7 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)7 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)7 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)7 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)7