use of org.neo4j.kernel.impl.store.DynamicRecordAllocator in project neo4j by neo4j.
the class NodeRecordCheckTest method shouldProperlyReportOutOfOrderLabelsThatAreFarAway.
@Test
public void shouldProperlyReportOutOfOrderLabelsThatAreFarAway() throws Exception {
// given
final NodeRecord node = inUse(new NodeRecord(42, false, NONE, NONE));
// We need to do this override so we can put the labels unsorted, since InlineNodeLabels always sorts on insert
new InlineNodeLabels(node) {
@Override
public Collection<DynamicRecord> put(long[] labelIds, NodeStore nodeStore, DynamicRecordAllocator allocator) {
return putSorted(node, labelIds, nodeStore, allocator);
}
}.put(new long[] { 1, 18, 13, 14, 15, 16, 12 }, null, null);
LabelTokenRecord label1 = inUse(new LabelTokenRecord(1));
LabelTokenRecord label12 = inUse(new LabelTokenRecord(12));
LabelTokenRecord label13 = inUse(new LabelTokenRecord(13));
LabelTokenRecord label14 = inUse(new LabelTokenRecord(14));
LabelTokenRecord label15 = inUse(new LabelTokenRecord(15));
LabelTokenRecord label16 = inUse(new LabelTokenRecord(16));
LabelTokenRecord label18 = inUse(new LabelTokenRecord(18));
add(label1);
add(label12);
add(label13);
add(label14);
add(label15);
add(label16);
add(label18);
add(node);
// when
ConsistencyReport.NodeConsistencyReport report = check(node);
// then
verify(report).labelsOutOfOrder(18, 13);
verify(report).labelsOutOfOrder(16, 12);
}
use of org.neo4j.kernel.impl.store.DynamicRecordAllocator in project neo4j by neo4j.
the class StorePropertyCursorTest method createTwoPropertyValues.
private static PropertyRecord createTwoPropertyValues(PropertyStore store, int keyId1, Object value1, int keyId2, Object value2) {
DynamicRecordAllocator stringAllocator = store.getStringStore();
DynamicRecordAllocator arrayAllocator = store.getArrayStore();
PropertyBlock block1 = new PropertyBlock();
PropertyStore.encodeValue(block1, keyId1, value1, stringAllocator, arrayAllocator);
PropertyBlock block2 = new PropertyBlock();
PropertyStore.encodeValue(block2, keyId2, value2, stringAllocator, arrayAllocator);
PropertyRecord record = new PropertyRecord(store.nextId());
record.addPropertyBlock(block1);
if (block1.getSize() + block2.getSize() <= PropertyRecordFormat.DEFAULT_PAYLOAD_SIZE) {
record.addPropertyBlock(block2);
} else {
PropertyRecord nextRecord = new PropertyRecord(store.nextId());
record.setNextProp(nextRecord.getId());
nextRecord.addPropertyBlock(block2);
nextRecord.setPrevProp(record.getId());
nextRecord.setInUse(true);
updateRecord(store, nextRecord);
}
record.setInUse(true);
updateRecord(store, record);
return record;
}
use of org.neo4j.kernel.impl.store.DynamicRecordAllocator in project neo4j by neo4j.
the class StorePropertyPayloadCursorTest method asBlocks.
private static long[] asBlocks(Object... values) {
DynamicRecordAllocator stringAllocator = new StandaloneDynamicRecordAllocator();
DynamicRecordAllocator arrayAllocator = new StandaloneDynamicRecordAllocator();
long[] blocks = new long[PropertyType.getPayloadSizeLongs()];
int cursor = 0;
for (int i = 0; i < values.length; i++) {
Object value = values[i];
PropertyBlock block = new PropertyBlock();
PropertyStore.encodeValue(block, i, value, stringAllocator, arrayAllocator);
long[] valueBlocks = block.getValueBlocks();
System.arraycopy(valueBlocks, 0, blocks, cursor, valueBlocks.length);
cursor += valueBlocks.length;
}
return blocks;
}
use of org.neo4j.kernel.impl.store.DynamicRecordAllocator in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportArrayPropertyInconsistencies.
@Test
void shouldReportArrayPropertyInconsistencies() throws Exception {
// given
int recordDataSize = GraphDatabaseSettings.DEFAULT_BLOCK_SIZE - 12;
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
// A dynamic array property with a broken chain, first dynamic record pointing to an unused second dynamic record
List<DynamicRecord> allocatedRecords = new ArrayList<>();
long[] arrayValue = new long[70];
for (int i = 0; i < arrayValue.length; i++) {
arrayValue[i] = i * 10_000;
}
DynamicArrayStore.allocateRecords(allocatedRecords, arrayValue, new DynamicRecordAllocator() {
@Override
public int getRecordDataSize() {
return recordDataSize;
}
@Override
public DynamicRecord nextRecord(CursorContext cursorContext) {
return StandardDynamicRecordAllocator.allocateRecord(next.arrayProperty());
}
}, true, NULL, INSTANCE);
assertThat(allocatedRecords.size()).isGreaterThan(1);
DynamicRecord array = allocatedRecords.get(0);
array.setType(ARRAY.intValue());
// A property block referencing this dynamic array property
PropertyBlock block = new PropertyBlock();
block.setSingleBlock((((long) ARRAY.intValue()) << 24) | (array.getId() << 28));
block.addValueRecord(array);
// Set the property key explicitly to one created in the setup (property key 0 can be an internal token)
block.setKeyIndexId(key1);
// A property record with this block in it
PropertyRecord property = new PropertyRecord(next.property());
property.addPropertyBlock(block);
// A node referencing this property record
NodeRecord node = new NodeRecord(next.node());
node.initialize(true, property.getId(), false, NO_NEXT_RELATIONSHIP.longValue(), NO_LABELS_FIELD.longValue());
property.setNodeId(node.getId());
tx.create(property);
tx.create(node);
}
});
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.ARRAY_PROPERTY, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.store.DynamicRecordAllocator in project neo4j by neo4j.
the class RecordStorageMigratorIT method allocateFrom.
public static List<DynamicRecord> allocateFrom(SchemaStore35 schemaStore35, SchemaRule rule, CursorContext cursorContext) {
List<DynamicRecord> records = new ArrayList<>();
DynamicRecord record = schemaStore35.getRecord(rule.getId(), schemaStore35.newRecord(), CHECK, cursorContext);
DynamicRecordAllocator recordAllocator = new ReusableRecordsCompositeAllocator(singleton(record), schemaStore35);
allocateRecordsFromBytes(records, SchemaRuleSerialization35.serialize(rule, INSTANCE), recordAllocator, cursorContext, INSTANCE);
return records;
}
Aggregations