use of org.neo4j.internal.batchimport.input.IdType in project neo4j by neo4j.
the class HumanUnderstandableExecutionMonitorIT method shouldReportProgressOfNodeImport.
@Test
void shouldReportProgressOfNodeImport() throws Exception {
// given
CapturingMonitor progress = new CapturingMonitor();
HumanUnderstandableExecutionMonitor monitor = new HumanUnderstandableExecutionMonitor(progress);
IdType idType = IdType.INTEGER;
Input input = new DataGeneratorInput(NODE_COUNT, RELATIONSHIP_COUNT, idType, random.seed(), 0, bareboneNodeHeader(idType, new Extractors(';')), bareboneRelationshipHeader(idType, new Extractors(';')), 1, 1, 0, 0);
Configuration configuration = new Configuration.Overridden(Configuration.DEFAULT) {
@Override
public long pageCacheMemory() {
return mebiBytes(8);
}
};
// when
try (JobScheduler jobScheduler = new ThreadPoolJobScheduler()) {
new ParallelBatchImporter(databaseLayout, fileSystem, NULL, configuration, NullLogService.getInstance(), monitor, EMPTY, defaults(), LATEST_RECORD_FORMATS, ImportLogic.NO_MONITOR, jobScheduler, Collector.EMPTY, LogFilesInitializer.NULL, IndexImporterFactory.EMPTY, EmptyMemoryTracker.INSTANCE).doImport(input);
// then
progress.assertAllProgressReachedEnd();
}
}
use of org.neo4j.internal.batchimport.input.IdType in project neo4j by neo4j.
the class CsvInputTest method shouldProvideNodesFromCsvInput.
@Test
public void shouldProvideNodesFromCsvInput() throws Exception {
// GIVEN
IdType idType = ACTUAL;
Iterable<DataFactory> data = dataIterable(data("123,Mattias Persson,HACKER"));
Input input = new CsvInput(data, header(entry(null, Type.ID, CsvInput.idExtractor(idType, extractors)), entry("name", Type.PROPERTY, extractors.string()), entry("labels", Type.LABEL, extractors.string())), datas(), defaultFormatRelationshipFileHeader(), idType, config(), NO_MONITOR, INSTANCE);
// WHEN/THEN
try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
assertNextNode(nodes, 123L, properties("name", "Mattias Persson"), labels("HACKER"));
assertFalse(chunk.next(visitor));
}
}
use of org.neo4j.internal.batchimport.input.IdType in project neo4j by neo4j.
the class CsvInputTest method shouldCalculateCorrectEstimatesForZippedInputFile.
@Test
public void shouldCalculateCorrectEstimatesForZippedInputFile() throws IOException {
// GIVEN
IdType idType = STRING;
Path uncompressedFile = createNodeInputDataFile(mebiBytes(10));
Path compressedFile = compressWithZip(uncompressedFile);
Assertions.assertThat(Files.size(compressedFile)).isLessThan(Files.size(uncompressedFile));
// WHEN
Input.Estimates uncompressedEstimates = calculateEstimatesOnSingleFileNodeData(idType, uncompressedFile);
Input.Estimates compressedEstimates = calculateEstimatesOnSingleFileNodeData(idType, compressedFile);
// then
assertEstimatesEquals(uncompressedEstimates, compressedEstimates, 0);
}
use of org.neo4j.internal.batchimport.input.IdType in project neo4j by neo4j.
the class CsvInputTest method shouldHaveRelationshipsSpecifyStartEndNodeIdGroupsInHeader.
@Test
public void shouldHaveRelationshipsSpecifyStartEndNodeIdGroupsInHeader() throws Exception {
// GIVEN
IdType idType = IdType.INTEGER;
Iterable<DataFactory> data = dataIterable(data("123,TYPE,234\n" + "345,TYPE,456"));
Groups groups = new Groups();
Group startNodeGroup = groups.getOrCreate("StartGroup");
Group endNodeGroup = groups.getOrCreate("EndGroup");
Iterable<DataFactory> nodeHeader = dataIterable(data(":ID(" + startNodeGroup.name() + ")"), data(":ID(" + endNodeGroup.name() + ")"));
Input input = new CsvInput(nodeHeader, defaultFormatNodeFileHeader(), data, header(entry(null, Type.START_ID, startNodeGroup.name(), CsvInput.idExtractor(idType, extractors)), entry(null, Type.TYPE, extractors.string()), entry(null, Type.END_ID, endNodeGroup.name(), CsvInput.idExtractor(idType, extractors))), idType, config(), NO_MONITOR, INSTANCE);
// WHEN/THEN
try (InputIterator relationships = input.relationships(EMPTY).iterator()) {
assertRelationship(relationships, startNodeGroup, 123L, endNodeGroup, 234L, "TYPE", properties());
assertRelationship(relationships, startNodeGroup, 345L, endNodeGroup, 456L, "TYPE", properties());
assertFalse(readNext(relationships));
}
}
use of org.neo4j.internal.batchimport.input.IdType in project neo4j by neo4j.
the class CsvInputTest method shouldProvideRelationshipsFromCsvInput.
@Test
public void shouldProvideRelationshipsFromCsvInput() throws Exception {
// GIVEN
IdType idType = IdType.STRING;
Iterable<DataFactory> data = dataIterable(data("node1,node2,KNOWS,1234567\n" + "node2,node10,HACKS,987654"));
Input input = new CsvInput(datas(), defaultFormatNodeFileHeader(), data, header(entry("from", Type.START_ID, CsvInput.idExtractor(idType, extractors)), entry("to", Type.END_ID, CsvInput.idExtractor(idType, extractors)), entry("type", Type.TYPE, extractors.string()), entry("since", Type.PROPERTY, extractors.long_())), idType, config(), NO_MONITOR, INSTANCE);
// WHEN/THEN
try (InputIterator relationships = input.relationships(EMPTY).iterator()) {
assertNextRelationship(relationships, "node1", "node2", "KNOWS", properties("since", 1234567L));
assertNextRelationship(relationships, "node2", "node10", "HACKS", properties("since", 987654L));
}
}
Aggregations