Search in sources :

Example 6 with Extractors

use of org.neo4j.csv.reader.Extractors 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 7 with Extractors

use of org.neo4j.csv.reader.Extractors in project neo4j by neo4j.

the class DataFactoriesTest method shouldParseDefaultRelationshipFileHeaderCorrectly.

@Test
public void shouldParseDefaultRelationshipFileHeaderCorrectly() throws Exception {
    // GIVEN
    CharSeeker seeker = seeker(":START_ID\t:END_ID\ttype:TYPE\tdate:long\tmore:long[]");
    IdType idType = IdType.ACTUAL;
    Extractors extractors = new Extractors('\t');
    // WHEN
    Header header = defaultFormatRelationshipFileHeader().create(seeker, TABS, idType, groups);
    // THEN
    assertArrayEquals(array(entry(null, Type.START_ID, CsvInput.idExtractor(idType, extractors)), entry(null, Type.END_ID, CsvInput.idExtractor(idType, extractors)), entry("type", Type.TYPE, extractors.string()), entry("date", Type.PROPERTY, extractors.long_()), entry("more", Type.PROPERTY, extractors.longArray())), header.entries());
    seeker.close();
}
Also used : Extractors(org.neo4j.csv.reader.Extractors) CharSeeker(org.neo4j.csv.reader.CharSeeker) DataFactories.defaultFormatNodeFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader) DataFactories.defaultFormatRelationshipFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatRelationshipFileHeader) IdType(org.neo4j.internal.batchimport.input.IdType) Test(org.junit.jupiter.api.Test)

Example 8 with Extractors

use of org.neo4j.csv.reader.Extractors in project neo4j by neo4j.

the class DataFactoriesTest method shouldParseGroupName.

@Test
public void shouldParseGroupName() throws Exception {
    // GIVEN
    String groupOneName = "GroupOne";
    String groupTwoName = "GroupTwo";
    CharSeeker seeker = seeker(":START_ID(" + groupOneName + ")\t:END_ID(" + groupTwoName + ")\ttype:TYPE\tdate:long\tmore:long[]");
    IdType idType = IdType.ACTUAL;
    Extractors extractors = new Extractors('\t');
    groups.getOrCreate(groupOneName);
    groups.getOrCreate(groupTwoName);
    // WHEN
    Header header = defaultFormatRelationshipFileHeader().create(seeker, TABS, idType, groups);
    // THEN
    assertArrayEquals(array(entry(null, Type.START_ID, "GroupOne", CsvInput.idExtractor(idType, extractors)), entry(null, Type.END_ID, "GroupTwo", CsvInput.idExtractor(idType, extractors)), entry("type", Type.TYPE, extractors.string()), entry("date", Type.PROPERTY, extractors.long_()), entry("more", Type.PROPERTY, extractors.longArray())), header.entries());
    seeker.close();
}
Also used : Extractors(org.neo4j.csv.reader.Extractors) CharSeeker(org.neo4j.csv.reader.CharSeeker) DataFactories.defaultFormatNodeFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader) DataFactories.defaultFormatRelationshipFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatRelationshipFileHeader) IdType(org.neo4j.internal.batchimport.input.IdType) Test(org.junit.jupiter.api.Test)

Example 9 with Extractors

use of org.neo4j.csv.reader.Extractors in project neo4j by neo4j.

the class DataFactoriesTest method shouldParsetRelationshipArrayTypesFileHeaderCorrectly.

@Test
public void shouldParsetRelationshipArrayTypesFileHeaderCorrectly() throws Exception {
    // GIVEN
    CharSeeker seeker = seeker(":START_ID\t:END_ID\ttype:TYPE\tlongArray:long[]\tpointArray:Point[]{crs:WGS-84}" + "\ttimeArray:time[]{timezone:+02:00}\tdateTimeArray:datetime[]{timezone:+02:00}");
    IdType idType = IdType.ACTUAL;
    Extractors extractors = new Extractors('\t');
    // WHEN
    Header header = defaultFormatRelationshipFileHeader().create(seeker, TABS, idType, groups);
    // THEN
    assertArrayEquals(array(entry(null, Type.START_ID, CsvInput.idExtractor(idType, extractors)), entry(null, Type.END_ID, CsvInput.idExtractor(idType, extractors)), entry("type", Type.TYPE, extractors.string()), entry("longArray", Type.PROPERTY, extractors.longArray()), entry("pointArray", Type.PROPERTY, extractors.pointArray(), PointValue.parseHeaderInformation("{crs:WGS-84}")), entry("timeArray", Type.PROPERTY, extractors.timeArray(), TimeValue.parseHeaderInformation("{timezone:+02:00}")), entry("dateTimeArray", Type.PROPERTY, extractors.dateTimeArray(), DateTimeValue.parseHeaderInformation("{timezone:+02:00}"))), header.entries());
    seeker.close();
}
Also used : Extractors(org.neo4j.csv.reader.Extractors) CharSeeker(org.neo4j.csv.reader.CharSeeker) DataFactories.defaultFormatNodeFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader) DataFactories.defaultFormatRelationshipFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatRelationshipFileHeader) IdType(org.neo4j.internal.batchimport.input.IdType) Test(org.junit.jupiter.api.Test)

Example 10 with Extractors

use of org.neo4j.csv.reader.Extractors in project neo4j by neo4j.

the class DataFactoriesTest method shouldHaveEmptyHeadersBeInterpretedAsIgnored.

@Test
public void shouldHaveEmptyHeadersBeInterpretedAsIgnored() throws Exception {
    // GIVEN
    CharSeeker seeker = seeker("one:id\ttwo\t\tdate:long");
    IdType idType = IdType.ACTUAL;
    Extractors extractors = new Extractors('\t');
    // WHEN
    Header header = defaultFormatNodeFileHeader().create(seeker, TABS, idType, groups);
    // THEN
    assertArrayEquals(array(entry("one", Type.ID, extractors.long_()), entry("two", Type.PROPERTY, extractors.string()), entry(null, Type.IGNORE, null), entry("date", Type.PROPERTY, extractors.long_())), header.entries());
    seeker.close();
}
Also used : Extractors(org.neo4j.csv.reader.Extractors) CharSeeker(org.neo4j.csv.reader.CharSeeker) DataFactories.defaultFormatNodeFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader) DataFactories.defaultFormatRelationshipFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatRelationshipFileHeader) IdType(org.neo4j.internal.batchimport.input.IdType) Test(org.junit.jupiter.api.Test)

Aggregations

Extractors (org.neo4j.csv.reader.Extractors)22 CharSeeker (org.neo4j.csv.reader.CharSeeker)18 Test (org.junit.jupiter.api.Test)11 IdType (org.neo4j.internal.batchimport.input.IdType)10 Test (org.junit.Test)8 DataFactories.defaultFormatNodeFileHeader (org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader)8 DataFactories.defaultFormatRelationshipFileHeader (org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatRelationshipFileHeader)8 DataFactories.defaultFormatNodeFileHeader (org.neo4j.unsafe.impl.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader)6 IOException (java.io.IOException)3 ParallelBatchImporter (org.neo4j.internal.batchimport.ParallelBatchImporter)2 DataGeneratorInput (org.neo4j.internal.batchimport.input.DataGeneratorInput)2 Input (org.neo4j.internal.batchimport.input.Input)2 JobScheduler (org.neo4j.scheduler.JobScheduler)2 DuplicateHeaderException (org.neo4j.unsafe.impl.batchimport.input.DuplicateHeaderException)2 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 Path (java.nio.file.Path)1 Config (org.neo4j.configuration.Config)1 CharReadable (org.neo4j.csv.reader.CharReadable)1 Configuration (org.neo4j.csv.reader.Configuration)1