use of org.neo4j.consistency.checking.GraphStoreFixture.Applier in project neo4j by neo4j.
the class FullCheckIntegrationTest method chainOfDynamicRecordsWithLabelsForANode.
private Pair<List<DynamicRecord>, List<Integer>> chainOfDynamicRecordsWithLabelsForANode(int labelCount) throws TransactionFailureException {
// allocate enough labels to need three records
final long[] labels = new long[labelCount + 1];
final List<Integer> createdLabels = new ArrayList<>();
try (Applier applier = fixture.createApplier()) {
for (int i = 1; /*leave space for the node id*/
i < labels.length; i++) {
final int offset = i;
applier.apply(new GraphStoreFixture.Transaction() {
// Neo4j can create no more than one label per transaction...
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
Integer label = next.label();
tx.nodeLabel((int) (labels[offset] = label), "label:" + offset);
createdLabels.add(label);
}
});
}
}
final List<DynamicRecord> chain = new ArrayList<>();
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
NodeRecord nodeRecord = new NodeRecord(next.node(), false, -1, -1);
DynamicRecord record1 = inUse(new DynamicRecord(next.nodeLabel()));
DynamicRecord record2 = inUse(new DynamicRecord(next.nodeLabel()));
DynamicRecord record3 = inUse(new DynamicRecord(next.nodeLabel()));
// the first id should not be a label id, but the id of the node
labels[0] = nodeRecord.getId();
ReusableRecordsAllocator allocator = new ReusableRecordsAllocator(60, record1, record2, record3);
allocateFromNumbers(chain, labels, allocator);
nodeRecord.setLabelField(dynamicPointer(chain), chain);
tx.create(nodeRecord);
}
});
return Pair.of(chain, createdLabels);
}
Aggregations