Search in sources :

Example 26 with InputRelationship

use of org.neo4j.unsafe.impl.batchimport.input.InputRelationship in project neo4j by neo4j.

the class RelationshipTypeCheckerStepTest method shouldReturnRelationshipTypesInDescendingOrder.

@Test
public void shouldReturnRelationshipTypesInDescendingOrder() throws Throwable {
    // GIVEN
    BatchingRelationshipTypeTokenRepository repository = mock(BatchingRelationshipTypeTokenRepository.class);
    RelationshipTypeCheckerStep step = new RelationshipTypeCheckerStep(mock(StageControl.class), DEFAULT, repository);
    Batch<InputRelationship, RelationshipRecord> relationships = batchOfRelationshipsWithRandomTypes(10, true);
    step.process(relationships, mock(BatchSender.class));
    // WHEN
    step.done();
    // THEN
    TreeSet<Integer> expected = idsOf(relationships);
    Object[] processed = step.getRelationshipTypes(100);
    int i = 0;
    for (Object expectedType : loop(expected.descendingIterator())) {
        assertEquals(expectedType, processed[i++]);
    }
}
Also used : BatchSender(org.neo4j.unsafe.impl.batchimport.staging.BatchSender) StageControl(org.neo4j.unsafe.impl.batchimport.staging.StageControl) BatchingRelationshipTypeTokenRepository(org.neo4j.unsafe.impl.batchimport.store.BatchingTokenRepository.BatchingRelationshipTypeTokenRepository) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) InputRelationship(org.neo4j.unsafe.impl.batchimport.input.InputRelationship) Test(org.junit.Test)

Example 27 with InputRelationship

use of org.neo4j.unsafe.impl.batchimport.input.InputRelationship in project neo4j by neo4j.

the class RelationshipTypeCheckerStepTest method shouldReturnRelationshipTypeIdsInReverseOrderOfTokenCreation.

private void shouldReturnRelationshipTypeIdsInReverseOrderOfTokenCreation(boolean typeIds) throws Throwable {
    // GIVEN
    BatchingRelationshipTypeTokenRepository repository = mock(BatchingRelationshipTypeTokenRepository.class);
    RelationshipTypeCheckerStep step = new RelationshipTypeCheckerStep(mock(StageControl.class), DEFAULT, repository);
    // WHEN
    Batch<InputRelationship, RelationshipRecord> relationships = batchOfRelationshipsWithRandomTypes(10, typeIds);
    step.process(relationships, mock(BatchSender.class));
    step.done();
    // THEN
    Object[] processed = step.getRelationshipTypes(100);
    InOrder inOrder = inOrder(repository);
    for (Object type : reversed(processed)) {
        inOrder.verify(repository).getOrCreateId(type);
    }
    inOrder.verifyNoMoreInteractions();
}
Also used : BatchSender(org.neo4j.unsafe.impl.batchimport.staging.BatchSender) StageControl(org.neo4j.unsafe.impl.batchimport.staging.StageControl) InOrder(org.mockito.InOrder) BatchingRelationshipTypeTokenRepository(org.neo4j.unsafe.impl.batchimport.store.BatchingTokenRepository.BatchingRelationshipTypeTokenRepository) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) InputRelationship(org.neo4j.unsafe.impl.batchimport.input.InputRelationship)

Example 28 with InputRelationship

use of org.neo4j.unsafe.impl.batchimport.input.InputRelationship in project neo4j by neo4j.

the class CsvInputBatchImportIT method shouldImportDataComingFromCsvFiles.

@Test
public void shouldImportDataComingFromCsvFiles() throws Exception {
    // GIVEN
    BatchImporter importer = new ParallelBatchImporter(directory.graphDbDir(), fileSystemRule.get(), smallBatchSizeConfig(), NullLogService.getInstance(), invisible(), Config.empty());
    List<InputNode> nodeData = randomNodeData();
    List<InputRelationship> relationshipData = randomRelationshipData(nodeData);
    // WHEN
    boolean success = false;
    try {
        importer.doImport(csv(nodeDataAsFile(nodeData), relationshipDataAsFile(relationshipData), IdType.STRING, lowBufferSize(COMMAS), silentBadCollector(0), getRuntime().availableProcessors()));
        // THEN
        verifyImportedData(nodeData, relationshipData);
        success = true;
    } finally {
        if (!success) {
            System.err.println("Seed " + seed);
        }
    }
}
Also used : ParallelBatchImporter(org.neo4j.unsafe.impl.batchimport.ParallelBatchImporter) InputNode(org.neo4j.unsafe.impl.batchimport.input.InputNode) BatchImporter(org.neo4j.unsafe.impl.batchimport.BatchImporter) ParallelBatchImporter(org.neo4j.unsafe.impl.batchimport.ParallelBatchImporter) InputRelationship(org.neo4j.unsafe.impl.batchimport.input.InputRelationship) Test(org.junit.Test)

Example 29 with InputRelationship

use of org.neo4j.unsafe.impl.batchimport.input.InputRelationship in project neo4j by neo4j.

the class CalculateDenseNodesStepTest method batch.

private Batch<InputRelationship, RelationshipRecord> batch(Data... relationships) {
    Batch<InputRelationship, RelationshipRecord> batch = new Batch<>(new InputRelationship[relationships.length]);
    batch.ids = new long[relationships.length * 2];
    for (int i = 0; i < relationships.length; i++) {
        batch.input[i] = new InputRelationship("test", i, i, NO_PROPERTIES, null, relationships[i].startNode, relationships[i].endNode, "TYPE", null);
        batch.ids[i * 2] = relationships[i].startNodeId;
        batch.ids[i * 2 + 1] = relationships[i].endNodeId;
    }
    return batch;
}
Also used : RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) InputRelationship(org.neo4j.unsafe.impl.batchimport.input.InputRelationship)

Aggregations

InputRelationship (org.neo4j.unsafe.impl.batchimport.input.InputRelationship)29 Test (org.junit.Test)14 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)9 Input (org.neo4j.unsafe.impl.batchimport.input.Input)9 InputNode (org.neo4j.unsafe.impl.batchimport.input.InputNode)8 StageControl (org.neo4j.unsafe.impl.batchimport.staging.StageControl)4 HashMap (java.util.HashMap)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Matchers.anyString (org.mockito.Matchers.anyString)3 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)3 File (java.io.File)2 IOException (java.io.IOException)2 Map (java.util.Map)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)2 Transaction (org.neo4j.graphdb.Transaction)2 NeoStores (org.neo4j.kernel.impl.store.NeoStores)2 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)2 BatchImporter (org.neo4j.unsafe.impl.batchimport.BatchImporter)2 ParallelBatchImporter (org.neo4j.unsafe.impl.batchimport.ParallelBatchImporter)2