Search in sources :

Example 71 with PropertyRecord

use of org.neo4j.kernel.impl.store.record.PropertyRecord 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 72 with PropertyRecord

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

the class LogCommandSerializationV3_0_10Test method readPropertyCommandWithSecondaryUnit.

@Test
void readPropertyCommandWithSecondaryUnit() throws IOException {
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    PropertyRecord before = new PropertyRecord(1);
    PropertyRecord after = new PropertyRecord(2);
    after.setSecondaryUnitIdOnCreate(78);
    new Command.PropertyCommand(writer(), before, after).serialize(channel);
    Command command = INSTANCE.read(channel);
    assertTrue(command instanceof Command.PropertyCommand);
    Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command;
    // Then
    assertEquals(before.getNextProp(), neoStoreCommand.getBefore().getNextProp());
    assertEquals(after.getNextProp(), neoStoreCommand.getAfter().getNextProp());
    verifySecondaryUnit(after, neoStoreCommand.getAfter());
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.jupiter.api.Test)

Example 73 with PropertyRecord

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

the class LogCommandSerializationV3_0_10Test method readPropertyCommandWithFixedReferenceFormat.

@Test
void readPropertyCommandWithFixedReferenceFormat() throws IOException {
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    PropertyRecord before = new PropertyRecord(1);
    PropertyRecord after = new PropertyRecord(2);
    before.setUseFixedReferences(true);
    after.setUseFixedReferences(true);
    new Command.PropertyCommand(writer(), before, after).serialize(channel);
    Command command = INSTANCE.read(channel);
    assertTrue(command instanceof Command.PropertyCommand);
    Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command;
    // Then
    assertEquals(before.getNextProp(), neoStoreCommand.getBefore().getNextProp());
    assertEquals(after.getNextProp(), neoStoreCommand.getAfter().getNextProp());
    assertTrue(neoStoreCommand.getBefore().isUseFixedReferences());
    assertTrue(neoStoreCommand.getAfter().isUseFixedReferences());
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.jupiter.api.Test)

Example 74 with PropertyRecord

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

the class LogCommandSerializationV3_0_10Test method readPropertyCommandWithNonRequiredSecondaryUnit.

@Test
void readPropertyCommandWithNonRequiredSecondaryUnit() throws IOException {
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    PropertyRecord before = new PropertyRecord(1);
    PropertyRecord after = new PropertyRecord(2);
    after.setSecondaryUnitIdOnCreate(78);
    new Command.PropertyCommand(writer(), before, after).serialize(channel);
    Command command = INSTANCE.read(channel);
    assertTrue(command instanceof Command.PropertyCommand);
    Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command;
    // Then
    assertEquals(before.getNextProp(), neoStoreCommand.getBefore().getNextProp());
    assertEquals(after.getNextProp(), neoStoreCommand.getAfter().getNextProp());
    verifySecondaryUnit(after, neoStoreCommand.getAfter());
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.jupiter.api.Test)

Example 75 with PropertyRecord

use of org.neo4j.kernel.impl.store.record.PropertyRecord 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)

Aggregations

PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)230 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)86 Test (org.junit.Test)75 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)37 Test (org.junit.jupiter.api.Test)36 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)35 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)28 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)19 ArrayList (java.util.ArrayList)17 Value (org.neo4j.values.storable.Value)17 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)14 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)14 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 PropertyStore (org.neo4j.kernel.impl.store.PropertyStore)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 NodeStore (org.neo4j.kernel.impl.store.NodeStore)8