Search in sources :

Example 41 with PropertyRecord

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

the class PhysicalLogCommandReaderV2_1 method readPropertyRecord.

private PropertyRecord readPropertyRecord(long id, ReadableChannel channel) throws IOException {
    // in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+
    // prev_prop_id(long)+next_prop_id(long)
    PropertyRecord record = new PropertyRecord(id);
    // 1
    byte inUseFlag = channel.get();
    // 8
    long nextProp = channel.getLong();
    // 8
    long prevProp = channel.getLong();
    record.setNextProp(nextProp);
    record.setPrevProp(prevProp);
    boolean inUse = false;
    if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
        inUse = true;
    }
    boolean nodeProperty = true;
    if ((inUseFlag & Record.REL_PROPERTY.byteValue()) == Record.REL_PROPERTY.byteValue()) {
        nodeProperty = false;
    }
    // 8
    long primitiveId = channel.getLong();
    if (primitiveId != -1 && nodeProperty) {
        record.setNodeId(primitiveId);
    } else if (primitiveId != -1) {
        record.setRelId(primitiveId);
    }
    int nrPropBlocks = channel.get();
    assert nrPropBlocks >= 0;
    if (nrPropBlocks > 0) {
        record.setInUse(true);
    }
    while (nrPropBlocks-- > 0) {
        PropertyBlock block = readPropertyBlock(channel);
        if (block == null) {
            return null;
        }
        record.addPropertyBlock(block);
    }
    int deletedRecords = readDynamicRecords(channel, record, PROPERTY_DELETED_DYNAMIC_RECORD_ADDER);
    if (deletedRecords == -1) {
        return null;
    }
    if ((inUse && !record.inUse()) || (!inUse && record.inUse())) {
        throw new IllegalStateException("Weird, inUse was read in as " + inUse + " but the record is " + record);
    }
    return record;
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 42 with PropertyRecord

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

the class PropertyPhysicalToLogicalConverterTest method shouldConvertDynamicChangedProperty.

@Test
public void shouldConvertDynamicChangedProperty() throws Exception {
    // GIVEN
    int key = 10;
    PropertyRecord before = propertyRecord(property(key, longString));
    PropertyRecord after = propertyRecord(property(key, longerString));
    // WHEN
    NodeUpdates update = convert(none, none, change(before, after));
    // THEN
    NodeUpdates expected = NodeUpdates.forNode(0).changed(key, longString, longerString).build();
    assertEquals(expected, update);
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Test(org.junit.Test)

Example 43 with PropertyRecord

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

the class PropertyPhysicalToLogicalConverterTest method shouldConvertInlinedChangedProperty.

@Test
public void shouldConvertInlinedChangedProperty() throws Exception {
    // GIVEN
    int key = 10;
    int valueBefore = 12341, valueAfter = 738;
    PropertyRecord before = propertyRecord(property(key, valueBefore));
    PropertyRecord after = propertyRecord(property(key, valueAfter));
    // WHEN
    NodeUpdates update = convert(none, none, change(before, after));
    // THEN
    NodeUpdates expected = NodeUpdates.forNode(0).changed(key, valueBefore, valueAfter).build();
    assertEquals(expected, update);
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Test(org.junit.Test)

Example 44 with PropertyRecord

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

the class PropertyPhysicalToLogicalConverterTest method shouldNotConvertDynamicAddedProperty.

@Test
public void shouldNotConvertDynamicAddedProperty() throws Exception {
    // GIVEN
    int key = 10;
    PropertyRecord before = propertyRecord();
    PropertyRecord after = propertyRecord(property(key, longString));
    // WHEN
    NodeUpdates update = convert(none, none, change(before, after));
    // THEN
    assertFalse(update.hasIndexingAppropriateUpdates());
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Test(org.junit.Test)

Example 45 with PropertyRecord

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

the class PropertyRecordFormatTest method useFixedReferenceFormatWhenNextPropertyIsMissing.

@Test
public void useFixedReferenceFormatWhenNextPropertyIsMissing() throws IOException {
    PropertyRecord source = new PropertyRecord(1);
    PropertyRecord target = new PropertyRecord(1);
    source.initialize(true, randomFixedReference(), Record.NULL_REFERENCE.byteValue());
    writeReadRecord(source, target);
    assertTrue("Record should use fixed reference format.", target.isUseFixedReferences());
    verifySameReferences(source, target);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Test(org.junit.Test)

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