Search in sources :

Example 66 with PropertyBlock

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

the class FullCheckIntegrationTest method shouldReportStringPropertyInconsistencies.

@Test
public void shouldReportStringPropertyInconsistencies() throws Exception {
    // given
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            DynamicRecord string = new DynamicRecord(next.stringProperty());
            string.setInUse(true);
            string.setCreated();
            string.setType(PropertyType.STRING.intValue());
            string.setNextBlock(next.stringProperty());
            string.setData(UTF8.encode("hello world"));
            PropertyBlock block = new PropertyBlock();
            block.setSingleBlock((((long) PropertyType.STRING.intValue()) << 24) | (string.getId() << 28));
            block.addValueRecord(string);
            PropertyRecord property = new PropertyRecord(next.property());
            property.addPropertyBlock(block);
            tx.create(property);
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.STRING_PROPERTY, 1).andThatsAllFolks();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 67 with PropertyBlock

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

the class PropertyRecordFormatV3_0_0 method write.

@Override
public void write(PropertyRecord record, PageCursor cursor, int recordSize) throws IOException {
    if (record.inUse()) {
        cursor.putByte((byte) ((record.inUse() ? IN_USE_BIT : 0) | numberOfBlocks(record) << 4));
        long recordId = record.getId();
        Reference.encode(toRelative(record.getPrevProp(), recordId), cursor);
        Reference.encode(toRelative(record.getNextProp(), recordId), cursor);
        for (PropertyBlock block : record) {
            for (long propertyBlock : block.getValueBlocks()) {
                cursor.putLong(propertyBlock);
            }
        }
    } else {
        markAsUnused(cursor);
    }
}
Also used : PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 68 with PropertyBlock

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

the class PropertyRecordFormatV3_0_6 method write.

@Override
public void write(PropertyRecord record, PageCursor cursor, int recordSize) throws IOException {
    if (record.inUse()) {
        byte headerByte = (byte) ((record.inUse() ? IN_USE_BIT : 0) | numberOfBlocks(record) << 4);
        boolean canUseFixedReferences = canUseFixedReferences(record, recordSize);
        record.setUseFixedReferences(canUseFixedReferences);
        headerByte = set(headerByte, HEADER_BIT_FIXED_REFERENCE, canUseFixedReferences);
        cursor.putByte(headerByte);
        long recordId = record.getId();
        if (canUseFixedReferences) {
            // write record in fixed reference format
            writeFixedReferencesRecord(record, cursor);
        } else {
            Reference.encode(toRelative(record.getPrevProp(), recordId), cursor);
            Reference.encode(toRelative(record.getNextProp(), recordId), cursor);
        }
        for (PropertyBlock block : record) {
            for (long propertyBlock : block.getValueBlocks()) {
                cursor.putLong(propertyBlock);
            }
        }
    } else {
        markAsUnused(cursor);
    }
}
Also used : PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 69 with PropertyBlock

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

the class PropertyRecordFormat method write.

@Override
public void write(PropertyRecord record, PageCursor cursor, int recordSize) throws IOException {
    if (record.inUse()) {
        byte headerByte = (byte) ((record.inUse() ? IN_USE_BIT : 0) | numberOfBlocks(record) << 4);
        boolean canUseFixedReferences = canUseFixedReferences(record, recordSize);
        record.setUseFixedReferences(canUseFixedReferences);
        headerByte = set(headerByte, HEADER_BIT_FIXED_REFERENCE, canUseFixedReferences);
        cursor.putByte(headerByte);
        long recordId = record.getId();
        if (canUseFixedReferences) {
            // write record in fixed reference format
            writeFixedReferencesRecord(record, cursor);
        } else {
            Reference.encode(toRelative(record.getPrevProp(), recordId), cursor);
            Reference.encode(toRelative(record.getNextProp(), recordId), cursor);
        }
        for (PropertyBlock block : record) {
            for (long propertyBlock : block.getValueBlocks()) {
                cursor.putLong(propertyBlock);
            }
        }
    } else {
        markAsUnused(cursor);
    }
}
Also used : PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 70 with PropertyBlock

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

the class Commands method createProperty.

public static PropertyCommand createProperty(long id, PropertyType type, int key, long... valueRecordIds) {
    PropertyRecord record = new PropertyRecord(id);
    record.setInUse(true);
    record.setCreated();
    PropertyBlock block = new PropertyBlock();
    if (valueRecordIds.length == 0) {
        PropertyStore.encodeValue(block, key, 123, /*value*/
        null, null);
    } else {
        PropertyStore.setSingleBlockValue(block, key, type, valueRecordIds[0]);
        block.setValueRecords(dynamicRecords(valueRecordIds));
    }
    record.addPropertyBlock(block);
    return new PropertyCommand(new PropertyRecord(id), record);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) PropertyCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyCommand)

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