use of org.neo4j.unsafe.impl.batchimport.input.InputNode in project neo4j by neo4j.
the class NodeEncoderStepTest method shouldAssignLabelsForNodesWithLabels.
@Test
public void shouldAssignLabelsForNodesWithLabels() throws Exception {
// GIVEN
NodeEncoderStep step = new NodeEncoderStep(control, DEFAULT, actual(), fromInput(), tokenRepository, nodeStore, mock(StatsProvider.class));
// WHEN
InputNode node = new InputNode("source", 0, 0, 0L, NO_PROPERTIES, null, new String[] { "one", "two" }, null);
Batch<InputNode, NodeRecord> batchBefore = new Batch<>(new InputNode[] { node });
step.process(batchBefore, sender);
// THEN
@SuppressWarnings("unchecked") Batch<InputNode, NodeRecord> batchAfter = (Batch<InputNode, NodeRecord>) single(sender);
assertNotNull(batchAfter.labels[0]);
assertEquals(2, batchAfter.labels[0].length);
}
use of org.neo4j.unsafe.impl.batchimport.input.InputNode in project neo4j by neo4j.
the class NodeEncoderStepTest method shouldNotAssignLabelsForNodesWithNoLabels.
@Test
public void shouldNotAssignLabelsForNodesWithNoLabels() throws Exception {
// GIVEN
NodeEncoderStep step = new NodeEncoderStep(control, DEFAULT, actual(), fromInput(), tokenRepository, nodeStore, mock(StatsProvider.class));
// WHEN
InputNode node = new InputNode("source", 0, 0, 0L, NO_PROPERTIES, null, NO_LABELS, null);
Batch<InputNode, NodeRecord> batchBefore = new Batch<>(new InputNode[] { node });
step.process(batchBefore, sender);
// THEN
@SuppressWarnings("unchecked") Batch<InputNode, NodeRecord> batchAfter = (Batch<InputNode, NodeRecord>) single(sender);
assertNull(batchAfter.labels[0]);
}
use of org.neo4j.unsafe.impl.batchimport.input.InputNode in project neo4j by neo4j.
the class NodeEncoderStepTest method shouldNotAssignLabelsForNodesWithJustLabelField.
@Test
public void shouldNotAssignLabelsForNodesWithJustLabelField() throws Exception {
// GIVEN
NodeEncoderStep step = new NodeEncoderStep(control, DEFAULT, actual(), fromInput(), tokenRepository, nodeStore, mock(StatsProvider.class));
// WHEN
InputNode node = new InputNode("source", 0, 0, 0L, NO_PROPERTIES, null, null, 1L);
Batch<InputNode, NodeRecord> batchBefore = new Batch<>(new InputNode[] { node });
step.process(batchBefore, sender);
// THEN
@SuppressWarnings("unchecked") Batch<InputNode, NodeRecord> batchAfter = (Batch<InputNode, NodeRecord>) single(sender);
assertNull(batchAfter.labels[0]);
}
use of org.neo4j.unsafe.impl.batchimport.input.InputNode in project neo4j by neo4j.
the class UtilsTest method shouldContinueIdIteratorThroughNulls.
@Test
public void shouldContinueIdIteratorThroughNulls() throws Exception {
// GIVEN
Collection<InputNode> inputs = Arrays.asList(new InputNode("Source", 1, 1, "1", NO_PROPERTIES, null, NO_LABELS, null), new InputNode("Source", 2, 2, null, NO_PROPERTIES, null, NO_LABELS, null), new InputNode("Source", 3, 3, "3", NO_PROPERTIES, null, NO_LABELS, null));
InputIterable<InputNode> input = SimpleInputIteratorWrapper.wrap("Source", inputs);
// WHEN
Iterator<Object> ids = Utils.idsOf(input).iterator();
// THEN
assertEquals("1", ids.next());
assertNull(ids.next());
assertEquals("3", ids.next());
assertFalse(ids.hasNext());
}
use of org.neo4j.unsafe.impl.batchimport.input.InputNode in project neo4j by neo4j.
the class CsvInputBatchImportIT method nodeDataAsFile.
private File nodeDataAsFile(List<InputNode> nodeData) throws IOException {
File file = directory.file("nodes.csv");
try (Writer writer = fileSystemRule.get().openAsWriter(file, StandardCharsets.UTF_8, false)) {
// Header
println(writer, "id:ID,name,some-labels:LABEL");
// Data
for (InputNode node : nodeData) {
String csvLabels = csvLabels(node.labels());
println(writer, node.id() + "," + node.properties()[1] + (csvLabels != null && csvLabels.length() > 0 ? "," + csvLabels : ""));
}
}
return file;
}
Aggregations