use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class TestArrayStore method stringArrayGetsStoredAsUtf8.
@Test
public void stringArrayGetsStoredAsUtf8() throws Exception {
String[] array = new String[] { "first", "second" };
Collection<DynamicRecord> records = new ArrayList<>();
arrayStore.allocateRecords(records, array);
Pair<byte[], byte[]> loaded = loadArray(records);
assertStringHeader(loaded.first(), array.length);
ByteBuffer buffer = ByteBuffer.wrap(loaded.other());
for (String item : array) {
byte[] expectedData = UTF8.encode(item);
assertEquals(expectedData.length, buffer.getInt());
byte[] loadedItem = new byte[expectedData.length];
buffer.get(loadedItem);
assertTrue(Arrays.equals(expectedData, loadedItem));
}
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class NodeRecordTest method newDeletedDynamicRecord.
private DynamicRecord newDeletedDynamicRecord(long id) {
DynamicRecord record = new DynamicRecord(id);
record.setInUse(false);
return record;
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class NodeRecordTest method shouldListLabelRecordsInUse.
@Test
public void shouldListLabelRecordsInUse() throws Exception {
// Given
NodeRecord node = new NodeRecord(1, false, -1, -1);
long inlinedLabels = 12L;
DynamicRecord dynamic1 = dynamicRecord(1L, true);
DynamicRecord dynamic2 = dynamicRecord(2L, true);
DynamicRecord dynamic3 = dynamicRecord(3L, true);
node.setLabelField(inlinedLabels, asList(dynamic1, dynamic2, dynamic3));
dynamic3.setInUse(false);
// When
Iterable<DynamicRecord> usedRecords = node.getUsedDynamicLabelRecords();
// Then
assertThat(asList(usedRecords), equalTo(asList(dynamic1, dynamic2)));
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class NodeRecordTest method cloneShouldProduceExactCopy.
@Test
public void cloneShouldProduceExactCopy() throws Exception {
// Given
long relId = 1337L;
long propId = 1338L;
long inlinedLabels = 12L;
NodeRecord node = new NodeRecord(1L, false, relId, propId);
node.setLabelField(inlinedLabels, asList(new DynamicRecord(1L), new DynamicRecord(2L)));
node.setInUse(true);
// When
NodeRecord clone = node.clone();
// Then
assertEquals(node.inUse(), clone.inUse());
assertEquals(node.getLabelField(), clone.getLabelField());
assertEquals(node.getNextProp(), clone.getNextProp());
assertEquals(node.getNextRel(), clone.getNextRel());
assertThat(clone.getDynamicLabelRecords(), equalTo(node.getDynamicLabelRecords()));
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class NodeInUseWithCorrectLabelsCheck method checkReference.
@Override
public void checkReference(RECORD record, NodeRecord nodeRecord, CheckerEngine<RECORD, REPORT> engine, RecordAccess records) {
if (nodeRecord.inUse()) {
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(nodeRecord);
if (nodeLabels instanceof DynamicNodeLabels) {
DynamicNodeLabels dynamicNodeLabels = (DynamicNodeLabels) nodeLabels;
long firstRecordId = dynamicNodeLabels.getFirstDynamicRecordId();
RecordReference<DynamicRecord> firstRecordReference = records.nodeLabels(firstRecordId);
ExpectedNodeLabelsChecker expectedNodeLabelsChecker = new ExpectedNodeLabelsChecker(nodeRecord);
LabelChainWalker<RECORD, REPORT> checker = new LabelChainWalker<>(expectedNodeLabelsChecker);
engine.comparativeCheck(firstRecordReference, checker);
// I think this is empty in production
nodeRecord.getDynamicLabelRecords();
} else {
long[] storeLabels = nodeLabels.get(null);
REPORT report = engine.report();
validateLabelIds(nodeRecord, storeLabels, report);
}
} else {
engine.report().nodeNotInUse(nodeRecord);
}
}
Aggregations