Search in sources :

Example 1 with IdType

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();
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) ParallelBatchImporter(org.neo4j.internal.batchimport.ParallelBatchImporter) DataGeneratorInput(org.neo4j.internal.batchimport.input.DataGeneratorInput) Input(org.neo4j.internal.batchimport.input.Input) Extractors(org.neo4j.csv.reader.Extractors) Configuration(org.neo4j.internal.batchimport.Configuration) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) DataGeneratorInput(org.neo4j.internal.batchimport.input.DataGeneratorInput) IdType(org.neo4j.internal.batchimport.input.IdType) Test(org.junit.jupiter.api.Test)

Example 2 with IdType

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));
    }
}
Also used : InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) IdType(org.neo4j.internal.batchimport.input.IdType) Test(org.junit.Test)

Example 3 with IdType

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);
}
Also used : Path(java.nio.file.Path) Input(org.neo4j.internal.batchimport.input.Input) IdType(org.neo4j.internal.batchimport.input.IdType) Test(org.junit.Test)

Example 4 with IdType

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));
    }
}
Also used : Group(org.neo4j.internal.batchimport.input.Group) InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) Groups(org.neo4j.internal.batchimport.input.Groups) IdType(org.neo4j.internal.batchimport.input.IdType) Test(org.junit.Test)

Example 5 with IdType

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));
    }
}
Also used : InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) IdType(org.neo4j.internal.batchimport.input.IdType) Test(org.junit.Test)

Aggregations

IdType (org.neo4j.internal.batchimport.input.IdType)19 Test (org.junit.jupiter.api.Test)11 CharSeeker (org.neo4j.csv.reader.CharSeeker)10 Extractors (org.neo4j.csv.reader.Extractors)10 Input (org.neo4j.internal.batchimport.input.Input)9 Test (org.junit.Test)7 DataFactories.defaultFormatNodeFileHeader (org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader)6 DataFactories.defaultFormatRelationshipFileHeader (org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatRelationshipFileHeader)6 InputIterator (org.neo4j.internal.batchimport.InputIterator)5 Path (java.nio.file.Path)3 Groups (org.neo4j.internal.batchimport.input.Groups)3 ParallelBatchImporter (org.neo4j.internal.batchimport.ParallelBatchImporter)2 DataGeneratorInput (org.neo4j.internal.batchimport.input.DataGeneratorInput)2 Group (org.neo4j.internal.batchimport.input.Group)2 JobScheduler (org.neo4j.scheduler.JobScheduler)2 Config (org.neo4j.configuration.Config)1 Configuration (org.neo4j.csv.reader.Configuration)1 BatchImporter (org.neo4j.internal.batchimport.BatchImporter)1 Configuration (org.neo4j.internal.batchimport.Configuration)1 Configuration.defaultConfiguration (org.neo4j.internal.batchimport.Configuration.defaultConfiguration)1