Search in sources :

Example 81 with RelationshipGroupRecord

use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.

the class ReadGroupsFromCacheStepTest method groups.

protected static List<RelationshipGroupRecord> groups(Group... groups) {
    List<RelationshipGroupRecord> records = new ArrayList<>();
    for (Group group : groups) {
        for (int i = 0; i < group.count; i++) {
            RelationshipGroupRecord record = new RelationshipGroupRecord(NULL_REFERENCE.longValue());
            record.setOwningNode(group.owningNode);
            // count: how many come after it (importer does this)
            record.setNext(group.count - i - 1);
            records.add(record);
        }
    }
    return records;
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) ArrayList(java.util.ArrayList)

Example 82 with RelationshipGroupRecord

use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.

the class RelationshipGroupCacheTest method shouldSortOutOfOrderTypes.

@Test
public void shouldSortOutOfOrderTypes() throws Exception {
    // GIVEN
    int nodeCount = 100;
    RelationshipGroupCache cache = new RelationshipGroupCache(HEAP, ByteUnit.kibiBytes(40), nodeCount);
    int[] counts = new int[nodeCount];
    int groupCount = 0;
    for (int nodeId = 0; nodeId < counts.length; nodeId++) {
        counts[nodeId] = random.nextInt(10);
        setCount(cache, nodeId, counts[nodeId]);
        groupCount += counts[nodeId];
    }
    assertEquals(nodeCount, cache.prepare(0));
    boolean thereAreMoreGroups = true;
    int cachedCount = 0;
    int[] types = scrambledTypes(10);
    for (int i = 0; thereAreMoreGroups; i++) {
        int typeId = types[i];
        thereAreMoreGroups = false;
        for (int nodeId = 0; nodeId < nodeCount; nodeId++) {
            if (counts[nodeId] > 0) {
                thereAreMoreGroups = true;
                if (cache.put(new RelationshipGroupRecord(nodeId).initialize(true, typeId, -1, -1, -1, nodeId, -1))) {
                    cachedCount++;
                    counts[nodeId]--;
                }
            }
        }
    }
    assertEquals(groupCount, cachedCount);
    // WHEN/THEN
    long currentNodeId = -1;
    int currentTypeId = -1;
    int readCount = 0;
    for (RelationshipGroupRecord group : cache) {
        assertTrue(group.getOwningNode() >= currentNodeId);
        if (group.getOwningNode() > currentNodeId) {
            currentNodeId = group.getOwningNode();
            currentTypeId = -1;
        }
        assertTrue(group.getType() > currentTypeId);
        readCount++;
    }
    assertEquals(cachedCount, readCount);
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Test(org.junit.Test)

Example 83 with RelationshipGroupRecord

use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.

the class EncodeGroupsStepTest method assertBatch.

private void assertBatch(RelationshipGroupRecord[] batch, long lastOwningNodeLastBatch) {
    for (int i = 0; i < batch.length; i++) {
        RelationshipGroupRecord record = batch[i];
        assertTrue(record.getId() > Record.NULL_REFERENCE.longValue());
        assertTrue(record.getOwningNode() > lastOwningNodeLastBatch);
        // the mark our store mock sets when preparing
        assertEquals(1, record.getFirstOut());
        if (record.getNext() == Record.NULL_REFERENCE.longValue()) {
            // This is the last in the chain, verify that this is either:
            assertTrue(// - the last one in the batch, or
            i == batch.length - 1 || // - the last one for this node
            batch[i + 1].getOwningNode() > record.getOwningNode());
        }
    }
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)

Aggregations

RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)83 Test (org.junit.Test)42 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)24 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)11 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)11 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)11 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)11 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)10 Command (org.neo4j.kernel.impl.transaction.command.Command)5 IOException (java.io.IOException)4 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)4 File (java.io.File)3 Node (org.neo4j.graphdb.Node)3 Relationship (org.neo4j.graphdb.Relationship)3 Transaction (org.neo4j.graphdb.Transaction)3 RecordStorageEngine (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)3 NeoStores (org.neo4j.kernel.impl.store.NeoStores)3 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)3 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)3 RelationshipGroupCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipGroupCommand)3