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;
}
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);
}
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);
}
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());
}
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);
}
Aggregations