Search in sources :

Example 21 with Input

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

the class CsvInputEstimateCalculationIT method shouldCalculateCorrectEstimatesOnEmptyData.

@Test
void shouldCalculateCorrectEstimatesOnEmptyData() throws Exception {
    // given
    Groups groups = new Groups();
    Collection<DataFactory> nodeData = singletonList(generateData(defaultFormatNodeFileHeader(), new MutableLong(), 0, 0, ":ID", "nodes-1.csv", groups));
    Collection<DataFactory> relationshipData = singletonList(generateData(defaultFormatRelationshipFileHeader(), new MutableLong(), 0, 0, ":START_ID,:TYPE,:END_ID", "rels-1.csv", groups));
    Input input = new CsvInput(nodeData, defaultFormatNodeFileHeader(), relationshipData, defaultFormatRelationshipFileHeader(), IdType.INTEGER, COMMAS, CsvInput.NO_MONITOR, groups, INSTANCE);
    // when
    Input.Estimates estimates = input.calculateEstimates(new PropertyValueRecordSizeCalculator(LATEST_RECORD_FORMATS.property().getRecordSize(NO_STORE_HEADER), GraphDatabaseInternalSettings.string_block_size.defaultValue(), 0, GraphDatabaseInternalSettings.array_block_size.defaultValue(), 0));
    // then
    assertEquals(0, estimates.numberOfNodes());
    assertEquals(0, estimates.numberOfRelationships());
    assertEquals(0, estimates.numberOfRelationshipProperties());
    assertEquals(0, estimates.numberOfNodeProperties());
    assertEquals(0, estimates.numberOfNodeLabels());
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) Input(org.neo4j.internal.batchimport.input.Input) Groups(org.neo4j.internal.batchimport.input.Groups) PropertyValueRecordSizeCalculator(org.neo4j.kernel.impl.store.PropertyValueRecordSizeCalculator) Test(org.junit.jupiter.api.Test)

Example 22 with Input

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

the class CsvInputTest method shouldIgnoreRelationshipEntriesMarkedIgnoreUsingHeader.

@Test
public void shouldIgnoreRelationshipEntriesMarkedIgnoreUsingHeader() throws Exception {
    // GIVEN
    Iterable<DataFactory> data = datas(CsvInputTest.data(":START_ID,:TYPE,:END_ID,prop:IGNORE,other:int\n" + "1,KNOWS,2,Mattias,10\n" + "2,KNOWS,3,Johan,111\n" + "3,KNOWS,4,Emil,12"));
    Input input = new CsvInput(datas(), defaultFormatNodeFileHeader(), data, defaultFormatRelationshipFileHeader(), IdType.INTEGER, config(), NO_MONITOR, INSTANCE);
    // WHEN
    try (InputIterator relationships = input.relationships(EMPTY).iterator()) {
        assertNextRelationship(relationships, 1L, 2L, "KNOWS", new Object[] { "other", 10 });
        assertNextRelationship(relationships, 2L, 3L, "KNOWS", new Object[] { "other", 111 });
        assertNextRelationship(relationships, 3L, 4L, "KNOWS", new Object[] { "other", 12 });
        assertFalse(readNext(relationships));
    }
}
Also used : InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) Test(org.junit.Test)

Example 23 with Input

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

the class CsvInputTest method shouldUseHeaderInformationToParsePoint.

@Test
public void shouldUseHeaderInformationToParsePoint() throws Exception {
    // GIVEN
    DataFactory data = data(":ID,name,point:Point{crs:WGS-84}\n" + "0,Johan,\" { x :1 ,y:2 } \"\n");
    Iterable<DataFactory> dataIterable = dataIterable(data);
    Input input = new CsvInput(dataIterable, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), ACTUAL, config(), NO_MONITOR, INSTANCE);
    // WHEN
    try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
        // THEN
        assertNextNode(nodes, 0L, new Object[] { "name", "Johan", "point", Values.pointValue(CoordinateReferenceSystem.WGS84, 1, 2) }, labels());
        assertFalse(readNext(nodes));
    }
}
Also used : InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) Test(org.junit.Test)

Example 24 with Input

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

the class CsvInputTest method shouldParseTimePropertyValues.

@Test
public void shouldParseTimePropertyValues() throws Exception {
    // GIVEN
    DataFactory data = data(":ID,name,time:Time\n" + "0,Mattias,13:37\n" + "1,Johan,\"16:20:01\"\n" + "2,Bob,07:30-05:00\n");
    Iterable<DataFactory> dataIterable = dataIterable(data);
    Input input = new CsvInput(dataIterable, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), ACTUAL, config(), NO_MONITOR, INSTANCE);
    // WHEN
    try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
        // THEN
        assertNextNode(nodes, 0L, new Object[] { "name", "Mattias", "time", TimeValue.time(13, 37, 0, 0, "+00:00") }, labels());
        assertNextNode(nodes, 1L, new Object[] { "name", "Johan", "time", TimeValue.time(16, 20, 1, 0, "+00:00") }, labels());
        assertNextNode(nodes, 2L, new Object[] { "name", "Bob", "time", TimeValue.time(7, 30, 0, 0, "-05:00") }, labels());
        assertFalse(readNext(nodes));
    }
}
Also used : InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) Test(org.junit.Test)

Example 25 with Input

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

the class CsvInputTest method shouldIgnoreNodeEntriesMarkedIgnoreUsingHeader.

@Test
public void shouldIgnoreNodeEntriesMarkedIgnoreUsingHeader() throws Exception {
    // GIVEN
    Iterable<DataFactory> data = datas(CsvInputTest.data(":ID,name:IGNORE,other:int,:LABEL\n" + "1,Mattias,10,Person\n" + "2,Johan,111,Person\n" + "3,Emil,12,Person"));
    Input input = new CsvInput(data, defaultFormatNodeFileHeader(), datas(), defaultFormatNodeFileHeader(), IdType.INTEGER, config(), NO_MONITOR, INSTANCE);
    // WHEN
    try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
        assertNextNode(nodes, 1L, new Object[] { "other", 10 }, labels("Person"));
        assertNextNode(nodes, 2L, new Object[] { "other", 111 }, labels("Person"));
        assertNextNode(nodes, 3L, new Object[] { "other", 12 }, labels("Person"));
        assertFalse(readNext(nodes));
    }
}
Also used : InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) Test(org.junit.Test)

Aggregations

Input (org.neo4j.internal.batchimport.input.Input)43 Test (org.junit.Test)36 InputIterator (org.neo4j.internal.batchimport.InputIterator)36 IdType (org.neo4j.internal.batchimport.input.IdType)8 Groups (org.neo4j.internal.batchimport.input.Groups)5 JobScheduler (org.neo4j.scheduler.JobScheduler)5 Matchers.containsString (org.hamcrest.Matchers.containsString)4 Test (org.junit.jupiter.api.Test)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Config (org.neo4j.configuration.Config)3 Group (org.neo4j.internal.batchimport.input.Group)3 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)3 ThreadPoolJobScheduler (org.neo4j.test.scheduler.ThreadPoolJobScheduler)3 Path (java.nio.file.Path)2 ParallelBatchImporter (org.neo4j.internal.batchimport.ParallelBatchImporter)2 ExecutionMonitor (org.neo4j.internal.batchimport.staging.ExecutionMonitor)2 IndexImporterFactoryImpl (org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl)2 NullLogProvider (org.neo4j.logging.NullLogProvider)2 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1