use of org.neo4j.kernel.impl.store.record.DynamicRecord 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.record.DynamicRecord 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.record.DynamicRecord 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.record.DynamicRecord in project neo4j by neo4j.
the class TestArrayStore method storeArray.
private Collection<DynamicRecord> storeArray(Object array) {
Collection<DynamicRecord> records = new ArrayList<>();
arrayStore.allocateRecords(records, array);
for (DynamicRecord record : records) {
arrayStore.updateRecord(record);
}
return records;
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class TestArrayStore method assertBitPackedArrayGetsCorrectlySerializedAndDeserialized.
private void assertBitPackedArrayGetsCorrectlySerializedAndDeserialized(Object array, PropertyType type, int expectedBitsUsedPerItem) {
Collection<DynamicRecord> records = storeArray(array);
Pair<byte[], byte[]> asBytes = loadArray(records);
assertArrayHeader(asBytes.first(), type, expectedBitsUsedPerItem);
Bits bits = Bits.bitsFromBytes(asBytes.other());
int length = Array.getLength(array);
for (int i = 0; i < length; i++) {
assertEquals(((Number) Array.get(array, i)).longValue(), bits.getLong(expectedBitsUsedPerItem));
}
}
Aggregations