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++]);
}
}
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();
}
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);
}
}
}
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;
}
Aggregations