Search in sources :

Example 36 with PropertyBlock

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

the class BatchingNeoStoresTest method createRecordIn.

private static <RECORD extends AbstractBaseRecord> void createRecordIn(RecordStore<RECORD> store) {
    RECORD record = store.newRecord();
    record.setId(store.nextId(NULL));
    record.setInUse(true);
    if (record instanceof PropertyRecord) {
        // Special hack for property store, since it's not enough to simply set a record as in use there
        PropertyBlock block = new PropertyBlock();
        ((PropertyStore) store).encodeValue(block, 0, Values.of(10), NULL, INSTANCE);
        ((PropertyRecord) record).addPropertyBlock(block);
    }
    store.updateRecord(record, NULL);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore)

Example 37 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, Values.of(123), null, null, true, NULL, INSTANCE);
    } 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.internal.recordstorage.Command.PropertyCommand)

Example 38 with PropertyBlock

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

the class PropertyStoreConsistentReadTest method createExistingRecord.

@Override
protected PropertyRecord createExistingRecord(boolean light) {
    PropertyRecord record = new PropertyRecord(ID);
    record.setId(ID);
    record.setNextProp(2);
    record.setPrevProp(4);
    record.setInUse(true);
    PropertyBlock block = new PropertyBlock();
    DynamicRecordAllocator stringAllocator = new ReusableRecordsAllocator(64, new DynamicRecord(7));
    Value value = Values.of("a string too large to fit in the property block itself");
    PropertyStore.encodeValue(block, 6, value, stringAllocator, null, true, NULL, INSTANCE);
    if (light) {
        block.getValueRecords().clear();
    }
    record.setPropertyBlock(block);
    return record;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) Value(org.neo4j.values.storable.Value) ReusableRecordsAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator)

Example 39 with PropertyBlock

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

the class TestLongerShortString method assertCanEncodeAndDecodeToSame.

private static void assertCanEncodeAndDecodeToSame(String string, int payloadSize) {
    PropertyBlock target = new PropertyBlock();
    assertTrue(LongerShortString.encode(0, string, target, payloadSize));
    assertEquals(Values.stringValue(string), LongerShortString.decode(target));
}
Also used : PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 40 with PropertyBlock

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

the class TestShortArray method assertCanEncodeAndDecodeToSameValue.

private static void assertCanEncodeAndDecodeToSameValue(Object value, int payloadSize) {
    PropertyBlock target = new PropertyBlock();
    boolean encoded = ShortArray.encode(0, value, target, payloadSize);
    assertTrue(encoded);
    assertEquals(Values.of(value), ShortArray.decode(target));
}
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