Search in sources :

Example 16 with InputNode

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);
}
Also used : InputNode(org.neo4j.unsafe.impl.batchimport.input.InputNode) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) StatsProvider(org.neo4j.unsafe.impl.batchimport.stats.StatsProvider) Test(org.junit.Test)

Example 17 with InputNode

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]);
}
Also used : InputNode(org.neo4j.unsafe.impl.batchimport.input.InputNode) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) StatsProvider(org.neo4j.unsafe.impl.batchimport.stats.StatsProvider) Test(org.junit.Test)

Example 18 with InputNode

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]);
}
Also used : InputNode(org.neo4j.unsafe.impl.batchimport.input.InputNode) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) StatsProvider(org.neo4j.unsafe.impl.batchimport.stats.StatsProvider) Test(org.junit.Test)

Example 19 with InputNode

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());
}
Also used : InputNode(org.neo4j.unsafe.impl.batchimport.input.InputNode) Test(org.junit.Test)

Example 20 with InputNode

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;
}
Also used : InputNode(org.neo4j.unsafe.impl.batchimport.input.InputNode) File(java.io.File) Writer(java.io.Writer)

Aggregations

InputNode (org.neo4j.unsafe.impl.batchimport.input.InputNode)42 Test (org.junit.Test)32 Input (org.neo4j.unsafe.impl.batchimport.input.Input)21 InputRelationship (org.neo4j.unsafe.impl.batchimport.input.InputRelationship)8 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)6 Collector (org.neo4j.unsafe.impl.batchimport.input.Collector)6 Groups (org.neo4j.unsafe.impl.batchimport.input.Groups)4 File (java.io.File)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Matchers.anyString (org.mockito.Matchers.anyString)3 StatsProvider (org.neo4j.unsafe.impl.batchimport.stats.StatsProvider)3 StringReader (java.io.StringReader)2 Writer (java.io.Writer)2 CharReadable (org.neo4j.csv.reader.CharReadable)2 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)2 Transaction (org.neo4j.graphdb.Transaction)2 NeoStores (org.neo4j.kernel.impl.store.NeoStores)2