use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportStringPropertyInconsistencies.
@Test
public void shouldReportStringPropertyInconsistencies() throws Exception {
// given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
DynamicRecord string = new DynamicRecord(next.stringProperty());
string.setInUse(true);
string.setCreated();
string.setType(PropertyType.STRING.intValue());
string.setNextBlock(next.stringProperty());
string.setData(UTF8.encode("hello world"));
PropertyBlock block = new PropertyBlock();
block.setSingleBlock((((long) PropertyType.STRING.intValue()) << 24) | (string.getId() << 28));
block.addValueRecord(string);
PropertyRecord property = new PropertyRecord(next.property());
property.addPropertyBlock(block);
tx.create(property);
}
});
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.STRING_PROPERTY, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class PropertyRecordFormatV3_0_0 method write.
@Override
public void write(PropertyRecord record, PageCursor cursor, int recordSize) throws IOException {
if (record.inUse()) {
cursor.putByte((byte) ((record.inUse() ? IN_USE_BIT : 0) | numberOfBlocks(record) << 4));
long recordId = record.getId();
Reference.encode(toRelative(record.getPrevProp(), recordId), cursor);
Reference.encode(toRelative(record.getNextProp(), recordId), cursor);
for (PropertyBlock block : record) {
for (long propertyBlock : block.getValueBlocks()) {
cursor.putLong(propertyBlock);
}
}
} else {
markAsUnused(cursor);
}
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class PropertyRecordFormatV3_0_6 method write.
@Override
public void write(PropertyRecord record, PageCursor cursor, int recordSize) throws IOException {
if (record.inUse()) {
byte headerByte = (byte) ((record.inUse() ? IN_USE_BIT : 0) | numberOfBlocks(record) << 4);
boolean canUseFixedReferences = canUseFixedReferences(record, recordSize);
record.setUseFixedReferences(canUseFixedReferences);
headerByte = set(headerByte, HEADER_BIT_FIXED_REFERENCE, canUseFixedReferences);
cursor.putByte(headerByte);
long recordId = record.getId();
if (canUseFixedReferences) {
// write record in fixed reference format
writeFixedReferencesRecord(record, cursor);
} else {
Reference.encode(toRelative(record.getPrevProp(), recordId), cursor);
Reference.encode(toRelative(record.getNextProp(), recordId), cursor);
}
for (PropertyBlock block : record) {
for (long propertyBlock : block.getValueBlocks()) {
cursor.putLong(propertyBlock);
}
}
} else {
markAsUnused(cursor);
}
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class PropertyRecordFormat method write.
@Override
public void write(PropertyRecord record, PageCursor cursor, int recordSize) throws IOException {
if (record.inUse()) {
byte headerByte = (byte) ((record.inUse() ? IN_USE_BIT : 0) | numberOfBlocks(record) << 4);
boolean canUseFixedReferences = canUseFixedReferences(record, recordSize);
record.setUseFixedReferences(canUseFixedReferences);
headerByte = set(headerByte, HEADER_BIT_FIXED_REFERENCE, canUseFixedReferences);
cursor.putByte(headerByte);
long recordId = record.getId();
if (canUseFixedReferences) {
// write record in fixed reference format
writeFixedReferencesRecord(record, cursor);
} else {
Reference.encode(toRelative(record.getPrevProp(), recordId), cursor);
Reference.encode(toRelative(record.getNextProp(), recordId), cursor);
}
for (PropertyBlock block : record) {
for (long propertyBlock : block.getValueBlocks()) {
cursor.putLong(propertyBlock);
}
}
} else {
markAsUnused(cursor);
}
}
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, 123, /*value*/
null, null);
} else {
PropertyStore.setSingleBlockValue(block, key, type, valueRecordIds[0]);
block.setValueRecords(dynamicRecords(valueRecordIds));
}
record.addPropertyBlock(block);
return new PropertyCommand(new PropertyRecord(id), record);
}
Aggregations