use of org.neo4j.kernel.impl.store.DynamicRecordAllocator in project neo4j by neo4j.
the class NodeRecordCheckTest method shouldReportOutOfOrderLabels.
@Test
public void shouldReportOutOfOrderLabels() 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[] { 3, 1, 2 }, null, null);
LabelTokenRecord label1 = inUse(new LabelTokenRecord(1));
LabelTokenRecord label2 = inUse(new LabelTokenRecord(2));
LabelTokenRecord label3 = inUse(new LabelTokenRecord(3));
add(label1);
add(label2);
add(label3);
add(node);
// when
ConsistencyReport.NodeConsistencyReport report = check(node);
// then
verify(report).labelsOutOfOrder(3, 1);
}
use of org.neo4j.kernel.impl.store.DynamicRecordAllocator in project neo4j by neo4j.
the class StorePropertyCursorTest method createSinglePropertyValue.
private static PropertyRecord createSinglePropertyValue(PropertyStore store, int keyId, Object value) {
DynamicRecordAllocator stringAllocator = store.getStringStore();
DynamicRecordAllocator arrayAllocator = store.getArrayStore();
PropertyBlock block = new PropertyBlock();
PropertyStore.encodeValue(block, keyId, value, stringAllocator, arrayAllocator);
PropertyRecord record = new PropertyRecord(store.nextId());
record.addPropertyBlock(block);
record.setInUse(true);
updateRecord(store, record);
return record;
}
use of org.neo4j.kernel.impl.store.DynamicRecordAllocator in project neo4j by neo4j.
the class SchemaStore35Test method allocateFrom.
public List<DynamicRecord> allocateFrom(SchemaRule rule, CursorContext cursorContext) {
List<DynamicRecord> records = new ArrayList<>();
DynamicRecord record = store.getRecord(rule.getId(), store.newRecord(), CHECK, cursorContext);
DynamicRecordAllocator recordAllocator = new ReusableRecordsCompositeAllocator(singleton(record), store);
allocateRecordsFromBytes(records, SchemaRuleSerialization35.serialize(rule, INSTANCE), recordAllocator, cursorContext, INSTANCE);
return records;
}
use of org.neo4j.kernel.impl.store.DynamicRecordAllocator in project neo4j by neo4j.
the class ReusableRecordsCompositeAllocatorTest method allocateReusableRecordsAndSwitchToDefaultWhenExhausted.
@Test
void allocateReusableRecordsAndSwitchToDefaultWhenExhausted() {
DynamicRecord dynamicRecord1 = new DynamicRecord(1);
DynamicRecord dynamicRecord2 = new DynamicRecord(2);
DynamicRecordAllocator recordAllocator = mock(DynamicRecordAllocator.class);
Mockito.when(recordAllocator.nextRecord(NULL)).thenReturn(dynamicRecord2);
ReusableRecordsCompositeAllocator compositeAllocator = new ReusableRecordsCompositeAllocator(singletonList(dynamicRecord1), recordAllocator);
assertSame(dynamicRecord1, compositeAllocator.nextRecord(NULL), "Same as pre allocated record.");
assertSame(dynamicRecord2, compositeAllocator.nextRecord(NULL), "Same as expected allocated record.");
}
use of org.neo4j.kernel.impl.store.DynamicRecordAllocator in project neo4j by neo4j.
the class FullCheckIntegrationTest method serializeRule.
private void serializeRule(SchemaRule rule, SchemaRecord schemaRecord, TransactionDataBuilder tx, IdGenerator next) throws KernelException {
IntObjectMap<Value> protoProperties = SchemaStore.convertSchemaRuleToMap(rule, tx.tokenHolders());
Collection<PropertyBlock> blocks = new ArrayList<>();
DynamicRecordAllocator stringAllocator = null;
DynamicRecordAllocator arrayAllocator = null;
protoProperties.forEachKeyValue((keyId, value) -> {
PropertyBlock block = new PropertyBlock();
PropertyStore.encodeValue(block, keyId, value, stringAllocator, arrayAllocator, true, NULL, INSTANCE);
blocks.add(block);
});
long nextPropId = Record.NO_NEXT_PROPERTY.longValue();
PropertyRecord currRecord = newInitialisedPropertyRecord(next, rule);
for (PropertyBlock block : blocks) {
if (!currRecord.hasSpaceFor(block)) {
PropertyRecord nextRecord = newInitialisedPropertyRecord(next, rule);
linkAndWritePropertyRecord(currRecord, nextRecord.getId(), nextPropId, tx);
nextPropId = currRecord.getId();
currRecord = nextRecord;
}
currRecord.addPropertyBlock(block);
}
linkAndWritePropertyRecord(currRecord, Record.NO_PREVIOUS_PROPERTY.longValue(), nextPropId, tx);
nextPropId = currRecord.getId();
schemaRecord.initialize(true, nextPropId);
schemaRecord.setId(rule.getId());
}
Aggregations