Search in sources :

Example 91 with PropertyBlock

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

the class TransactionRecordStateTest method shouldWriteProperPropertyRecordsWhenOnlyChangingLinkage.

@Test
public void shouldWriteProperPropertyRecordsWhenOnlyChangingLinkage() throws Exception {
    /* There was an issue where GIVEN:
         *
         *   Legend: () = node, [] = property record
         *
         *   ()-->[0:block{size:1}]
         *
         * WHEN adding a new property record in front of if, not changing any data in that record i.e:
         *
         *   ()-->[1:block{size:4}]-->[0:block{size:1}]
         *
         * The state of property record 0 would be that it had loaded value records for that block,
         * but those value records weren't heavy, so writing that record to the log would fail
         * w/ an assertion data != null.
         */
    // GIVEN
    NeoStores neoStores = neoStoresRule.open();
    TransactionRecordState recordState = newTransactionRecordState(neoStores);
    int nodeId = 0;
    recordState.nodeCreate(nodeId);
    int index = 0;
    // will require a block of size 1
    recordState.nodeAddProperty(nodeId, index, string(70));
    apply(neoStores, recordState);
    // WHEN
    recordState = newTransactionRecordState(neoStores);
    int index2 = 1;
    // will require a block of size 4
    recordState.nodeAddProperty(nodeId, index2, string(40));
    // THEN
    PhysicalTransactionRepresentation representation = transactionRepresentationOf(recordState);
    representation.accept(command -> ((Command) command).handle(new CommandVisitor.Adapter() {

        @Override
        public boolean visitPropertyCommand(PropertyCommand command) throws IOException {
            verifyPropertyRecord(command.getBefore());
            verifyPropertyRecord(command.getAfter());
            return false;
        }

        private void verifyPropertyRecord(PropertyRecord record) {
            if (record.getPrevProp() != Record.NO_NEXT_PROPERTY.intValue()) {
                for (PropertyBlock block : record) {
                    assertTrue(block.isLight());
                }
            }
        }
    }));
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) NeoStores(org.neo4j.kernel.impl.store.NeoStores) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) PropertyCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyCommand) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) Test(org.junit.Test)

Example 92 with PropertyBlock

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

the class MultipleIndexPopulatorUpdatesTest method getPropertyRecord.

private PropertyRecord getPropertyRecord() {
    PropertyRecord propertyRecord = new PropertyRecord(1);
    PropertyBlock propertyBlock = new PropertyBlock();
    propertyBlock.setValueBlocks(new long[] { 0 });
    propertyBlock.setKeyIndexId(1);
    propertyBlock.setSingleBlock((0x000000000F000009L << 24) + 1);
    propertyRecord.setPropertyBlock(propertyBlock);
    return propertyRecord;
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 93 with PropertyBlock

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

the class PropertyPhysicalToLogicalConverterTest method propertyRecord.

private PropertyRecord propertyRecord(PropertyBlock... propertyBlocks) {
    PropertyRecord record = new PropertyRecord(0);
    if (propertyBlocks != null) {
        record.setInUse(true);
        for (PropertyBlock propertyBlock : propertyBlocks) {
            record.addPropertyBlock(propertyBlock);
        }
    }
    record.setNodeId(0);
    return record;
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 94 with PropertyBlock

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

the class PropertyPhysicalToLogicalConverterTest method property.

private PropertyBlock property(long key, Object value) {
    PropertyBlock block = new PropertyBlock();
    store.encodeValue(block, (int) key, value);
    return block;
}
Also used : PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 95 with PropertyBlock

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

the class StorePropertyCursorTest method createTwoPropertyValues.

private static PropertyRecord createTwoPropertyValues(PropertyStore store, int keyId1, Object value1, int keyId2, Object value2) {
    DynamicRecordAllocator stringAllocator = store.getStringStore();
    DynamicRecordAllocator arrayAllocator = store.getArrayStore();
    PropertyBlock block1 = new PropertyBlock();
    PropertyStore.encodeValue(block1, keyId1, value1, stringAllocator, arrayAllocator);
    PropertyBlock block2 = new PropertyBlock();
    PropertyStore.encodeValue(block2, keyId2, value2, stringAllocator, arrayAllocator);
    PropertyRecord record = new PropertyRecord(store.nextId());
    record.addPropertyBlock(block1);
    if (block1.getSize() + block2.getSize() <= PropertyRecordFormat.DEFAULT_PAYLOAD_SIZE) {
        record.addPropertyBlock(block2);
    } else {
        PropertyRecord nextRecord = new PropertyRecord(store.nextId());
        record.setNextProp(nextRecord.getId());
        nextRecord.addPropertyBlock(block2);
        nextRecord.setPrevProp(record.getId());
        nextRecord.setInUse(true);
        updateRecord(store, nextRecord);
    }
    record.setInUse(true);
    updateRecord(store, record);
    return record;
}
Also used : DynamicRecordAllocator(org.neo4j.kernel.impl.store.DynamicRecordAllocator) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

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