Search in sources :

Example 6 with IdType

use of org.neo4j.internal.batchimport.input.IdType 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 7 with IdType

use of org.neo4j.internal.batchimport.input.IdType 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 8 with IdType

use of org.neo4j.internal.batchimport.input.IdType 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 9 with IdType

use of org.neo4j.internal.batchimport.input.IdType 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)

Example 10 with IdType

use of org.neo4j.internal.batchimport.input.IdType in project neo4j by neo4j.

the class DataFactoriesTest method shouldParseNodeArrayTypesHeaderCorrectly.

@Test
public void shouldParseNodeArrayTypesHeaderCorrectly() throws Exception {
    // GIVEN
    CharSeeker seeker = seeker("ID:ID,longArray:long[],pointArray:Point[]{crs:WGS-84},timeArray:time[]{timezone:+02:00}," + "dateTimeArray:datetime[]{timezone:+02:00}");
    IdType idType = IdType.STRING;
    Extractors extractors = new Extractors(',');
    // WHEN
    Header header = defaultFormatNodeFileHeader().create(seeker, COMMAS, idType, groups);
    // THEN
    assertArrayEquals(array(entry("ID", Type.ID, CsvInput.idExtractor(idType, extractors)), 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)

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