Search in sources :

Example 26 with PropertyBlock

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

the class PhysicalLogCommandReaderV2_1Test method propertyBlockWithSomeDynamicRecords.

private PropertyBlock propertyBlockWithSomeDynamicRecords(int keyId, PropertyType type, long value, byte[]... dynamicRecordData) {
    PropertyBlock block = new PropertyBlock();
    block.setSingleBlock(PropertyStore.singleBlockLongValue(keyId, type, value));
    for (byte[] bytes : dynamicRecordData) {
        block.addValueRecord(dynamicRecord(true, bytes, type.intValue()));
    }
    return block;
}
Also used : PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 27 with PropertyBlock

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

the class PhysicalLogCommandReaderV2_1Test method shouldReadPropertyCommandWithDeletedDynamicRecords.

@Test
public void shouldReadPropertyCommandWithDeletedDynamicRecords() throws Exception {
    // GIVEN
    PhysicalLogCommandReaderV2_1 reader = new PhysicalLogCommandReaderV2_1();
    InMemoryClosableChannel data = new InMemoryClosableChannel();
    long id = 5;
    int keyId = 6;
    byte[] data1 = new byte[] { 1, 2, 3, 4, 5 };
    byte[] data2 = new byte[] { 6, 7, 8, 9, 10 };
    long value = 1234;
    PropertyRecord property = new PropertyRecord(id);
    property.setInUse(true);
    property.addPropertyBlock(propertyBlockWithSomeDynamicRecords(keyId, STRING, value, data1, data2));
    property.addDeletedRecord(dynamicRecord(false, null, STRING.intValue()));
    property.addDeletedRecord(dynamicRecord(false, null, STRING.intValue()));
    // WHEN
    new PropertyCommand(new PropertyRecord(id), property).serialize(data);
    // THEN
    PropertyCommand readCommand = (PropertyCommand) reader.read(data);
    PropertyRecord readRecord = readCommand.getAfter();
    assertEquals(id, readRecord.getId());
    PropertyBlock readBlock = Iterables.single((Iterable<PropertyBlock>) readRecord);
    assertArrayEquals(data1, readBlock.getValueRecords().get(0).getData());
    assertArrayEquals(data2, readBlock.getValueRecords().get(1).getData());
    assertEquals(2, readRecord.getDeletedRecords().size());
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) PropertyCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyCommand) Test(org.junit.Test)

Example 28 with PropertyBlock

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

the class StorePropertyCursorTest method createSinglePropertyValue.

private static PropertyRecord createSinglePropertyValue(PropertyStore store, int keyId, Object value) {
    DynamicRecordAllocator stringAllocator = store.getStringStore();
    DynamicRecordAllocator arrayAllocator = store.getArrayStore();
    PropertyBlock block = new PropertyBlock();
    PropertyStore.encodeValue(block, keyId, value, stringAllocator, arrayAllocator);
    PropertyRecord record = new PropertyRecord(store.nextId());
    record.addPropertyBlock(block);
    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)

Example 29 with PropertyBlock

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

the class StorePropertyCursorTest method markDynamicRecordsNotInUse.

private static void markDynamicRecordsNotInUse(int keyId, PropertyRecord record, PropertyStore store, int... dynamicRecordIndexes) {
    PropertyBlock propertyBlock = record.getPropertyBlock(keyId);
    store.ensureHeavy(propertyBlock);
    List<DynamicRecord> valueRecords = propertyBlock.getValueRecords();
    for (int index : dynamicRecordIndexes) {
        DynamicRecord dynamicRecord = valueRecords.get(index);
        dynamicRecord.setInUse(false);
    }
    updateRecord(store, record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 30 with PropertyBlock

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

the class PropertyCreatorTest method existingRecord.

private void existingRecord(PropertyRecord record, ExpectedRecord initialRecord) {
    for (ExpectedProperty initialProperty : initialRecord.properties) {
        PropertyBlock block = new PropertyBlock();
        PropertyStore.encodeValue(block, initialProperty.key, initialProperty.value, null, null);
        record.addPropertyBlock(block);
    }
    assertTrue(record.size() <= PropertyType.getPayloadSize());
}
Also used : 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