use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator in project neo4j by neo4j.
the class NodeStoreTest method shouldReadFirstFromTwoRecordDynamicLongArray.
@Test
public void shouldReadFirstFromTwoRecordDynamicLongArray() throws Exception {
// GIVEN
Long expectedId = 12L;
long[] ids = new long[] { expectedId, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L };
DynamicRecord firstRecord = new DynamicRecord(0L);
allocateFromNumbers(new ArrayList<>(), ids, new ReusableRecordsAllocator(8, firstRecord, new DynamicRecord(1L)));
// WHEN
Long firstId = readOwnerFromDynamicLabelsRecord(firstRecord);
// THEN
assertEquals(expectedId, firstId);
}
use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator in project neo4j by neo4j.
the class NodeStoreTest method shouldReadFirstFromSingleRecordDynamicLongArray.
@Test
public void shouldReadFirstFromSingleRecordDynamicLongArray() throws Exception {
// GIVEN
Long expectedId = 12L;
long[] ids = new long[] { expectedId, 23L, 42L };
DynamicRecord firstRecord = new DynamicRecord(0L);
allocateFromNumbers(new ArrayList<>(), ids, new ReusableRecordsAllocator(60, firstRecord));
// WHEN
Long firstId = readOwnerFromDynamicLabelsRecord(firstRecord);
// THEN
assertEquals(expectedId, firstId);
}
use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator in project neo4j by neo4j.
the class NodeStoreTest method shouldReadFirstAsNullFromEmptyDynamicLongArray.
@Test
public void shouldReadFirstAsNullFromEmptyDynamicLongArray() throws Exception {
// GIVEN
Long expectedId = null;
long[] ids = new long[] {};
DynamicRecord firstRecord = new DynamicRecord(0L);
allocateFromNumbers(new ArrayList<>(), ids, new ReusableRecordsAllocator(60, firstRecord));
// WHEN
Long firstId = readOwnerFromDynamicLabelsRecord(firstRecord);
// THEN
assertEquals(expectedId, firstId);
}
use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator in project neo4j by neo4j.
the class NodeDynamicLabelOrphanChainStartCheckTest method shouldReportOwningNodeRecordNotPointingBack.
@Test
public void shouldReportOwningNodeRecordNotPointingBack() throws Exception {
// given
long nodeId = 12L;
Collection<DynamicRecord> validLabelRecords = new ArrayList<>();
DynamicRecord dynamicRecord = inUse(new DynamicRecord(0));
allocateFromNumbers(validLabelRecords, new long[] { nodeId }, new ReusableRecordsAllocator(66, dynamicRecord));
Collection<DynamicRecord> fakePointedToRecords = new ArrayList<>();
DynamicRecord dynamicRecord1 = inUse(new DynamicRecord(1));
allocateFromNumbers(fakePointedToRecords, new long[] { nodeId }, new ReusableRecordsAllocator(66, dynamicRecord1));
NodeRecord nodeRecord = inUse(new NodeRecord(nodeId, false, -1, -1));
nodeRecord.setLabelField(dynamicPointer(fakePointedToRecords), fakePointedToRecords);
add(nodeRecord);
// when
DynamicLabelConsistencyReport report = check(Iterators.single(validLabelRecords.iterator()));
// then
verify(report).orphanDynamicLabelRecordDueToInvalidOwner(nodeRecord);
}
use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator in project neo4j by neo4j.
the class NodeRecordCheckTest method shouldReportOutOfOrderDynamicLabels.
@Test
public void shouldReportOutOfOrderDynamicLabels() throws Exception {
// given
long[] labelIds = createLabels(100);
NodeRecord node = inUse(new NodeRecord(42, false, NONE, NONE));
add(node);
DynamicRecord labelsRecord1 = inUse(array(new DynamicRecord(1)));
DynamicRecord labelsRecord2 = inUse(array(new DynamicRecord(2)));
Collection<DynamicRecord> labelRecords = asList(labelsRecord1, labelsRecord2);
long temp = labelIds[12];
labelIds[12] = labelIds[11];
labelIds[11] = temp;
DynamicArrayStore.allocateFromNumbers(new ArrayList<>(), labelIds, new ReusableRecordsAllocator(52, labelRecords));
assertDynamicRecordChain(labelsRecord1, labelsRecord2);
node.setLabelField(DynamicNodeLabels.dynamicPointer(labelRecords), labelRecords);
addNodeDynamicLabels(labelsRecord1);
addNodeDynamicLabels(labelsRecord2);
// when
ConsistencyReport.NodeConsistencyReport report = check(node);
// then
verify(report).labelsOutOfOrder(labelIds[11], labelIds[12]);
}
Aggregations