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());
}
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));
}
}
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));
}
}
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));
}
}
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));
}
}
Aggregations