Search in sources :

Example 66 with DynamicRecord

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);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ReusableRecordsAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator) Test(org.junit.Test)

Example 67 with DynamicRecord

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);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ReusableRecordsAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator) Test(org.junit.Test)

Example 68 with DynamicRecord

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);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ReusableRecordsAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator) Test(org.junit.Test)

Example 69 with DynamicRecord

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;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ArrayList(java.util.ArrayList)

Example 70 with DynamicRecord

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));
    }
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) Bits(org.neo4j.kernel.impl.util.Bits)

Aggregations

DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)225 Test (org.junit.Test)117 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)51 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)38 ArrayList (java.util.ArrayList)32 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)28 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)23 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)21 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)21 IOException (java.io.IOException)20 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)16 ReusableRecordsAllocator (org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator)16 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)16 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)16 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)15 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)15 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)15 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)15 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)14 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)14