Package org.neo4j.batchimport.importer

Examples of org.neo4j.batchimport.importer.RowData


import static org.junit.Assert.assertEquals;

public class DataTest {
    @Test
    public void testConvertType() throws Exception {
        RowData data = new RowData("a:int\tb:float\tc:float", "\t", 0);
        data.processLine("100\t100.0\t1E+10");
        Map<String,Object> row = data.getProperties();
        assertEquals(100, row.get("a"));
        assertEquals(true,row.get("b") instanceof Float);
        assertEquals(100.0F, row.get("b"));
        assertEquals(true,row.get("b") instanceof Float);
        assertEquals(100.0F, row.get("b"));
View Full Code Here


        assertEquals(1E+10F, row.get("c"));
    }

    @Test
    public void testRelationship() throws Exception {
        RowData data = new RowData("start\tend\ttype\tproperty", "\t", 3);
        data.processLine("1\t2\tTYPE\tPROPERTY");
        Map<String,Object> row = data.getProperties();
        assertEquals("1", data.getValue(0));
        assertEquals("2", data.getValue(1));
        assertEquals("TYPE", data.getTypeLabels()[0]);
        assertEquals("PROPERTY", row.get("property"));
    }
View Full Code Here

        assertEquals("PROPERTY", row.get("property"));
    }

    @Test
    public void testRelationshipWithNoProperty() throws Exception {
        RowData data = new RowData("start\tend\ttype", "\t", 3);
        data.processLine("1\t2\tTYPE");
        assertEquals("1", data.getValue(0));
        assertEquals("2", data.getValue(1));
        assertEquals("TYPE", data.getTypeLabels()[0]);
    }
View Full Code Here

        assertEquals("TYPE", data.getTypeLabels()[0]);
    }

    @Test
    public void testNodeLabels() throws Exception {
        RowData data = new RowData("labels", "\t", 3);
        data.processLine("TYPE1,TYPE2");
        assertEquals("TYPE1", data.getTypeLabels()[0]);
        assertEquals("TYPE2", data.getTypeLabels()[1]);
    }
View Full Code Here

        assertEquals("TYPE1", data.getTypeLabels()[0]);
        assertEquals("TYPE2", data.getTypeLabels()[1]);
    }
    @Test
    public void testNodeLabelsWithLabelType() throws Exception {
        RowData data = new RowData("foo:label", "\t", 3);
        data.processLine("TYPE1,TYPE2");
        assertEquals("TYPE1", data.getTypeLabels()[0]);
        assertEquals("TYPE2", data.getTypeLabels()[1]);
    }
View Full Code Here

        assertEquals("TYPE1", data.getTypeLabels()[0]);
        assertEquals("TYPE2", data.getTypeLabels()[1]);
    }
    @Test
    public void testArrayType() throws Exception {
        RowData data = new RowData("a:int\tb:float\tc:string_array", "\t", 0);
        data.processLine("100\t100.0\tbagels,coffee,tea");
        Map<String,Object> row = data.getProperties();
        assertEquals(100, row.get("a"));
        assertEquals(true,row.get("b") instanceof Float);
        assertEquals(100.0F, row.get("b"));
        assertEquals(true,row.get("b") instanceof Float);
        assertEquals(100.0F, row.get("b"));
View Full Code Here

        assertArrayEquals(new String[]{"bagels", "coffee", "tea"}, (String[]) row.get("c"));
    }

    @Test
    public void testBooleanArrayType() throws Exception {
        RowData data = new RowData("a:int\tb:float\tc:boolean_array", "\t", 0);
        data.processLine("100\t100.0\ttrue,false,true");
        Map<String,Object> row = data.getProperties();
        assertEquals(100, row.get("a"));
        assertEquals(true,row.get("b") instanceof Float);
        assertEquals(100.0F, row.get("b"));
        assertEquals(true,row.get("b") instanceof Float);
        assertEquals(100.0F, row.get("b"));
View Full Code Here

        assertEquals(true,row.get("c") instanceof boolean[]);
        Assert.assertTrue(Arrays.equals(new boolean[]{true, false, true}, (boolean[]) row.get("c")));
    }
    @Test
    public void testIntArrayType() throws Exception {
        RowData data = new RowData("a:int\tb:float\tc:int_array", "\t", 0);
        data.processLine("100\t100.0\t1,2,3");
        Map<String,Object> row = data.getProperties();
        assertEquals(100, row.get("a"));
        assertEquals(true,row.get("b") instanceof Float);
        assertEquals(100.0F, row.get("b"));
        assertEquals(true,row.get("b") instanceof Float);
        assertEquals(100.0F, row.get("b"));
View Full Code Here

    }

    @Test
    public void testPerformance() throws Exception {
        final BufferedReader reader = new BufferedReader(new FileReader(TEST_CSV));
        final RowData rowData = new RowData(reader.readLine(), "\t", 0);

        int res = 0;
        long time = System.currentTimeMillis();
        String line;
        while ((line = reader.readLine()) != null) {
            rowData.processLine(line);
            res += rowData.getColumnCount();
        }
        time = System.currentTimeMillis() - time;
        System.out.println("time = " + time + " ms.");
        Assert.assertEquals((ROWS-1) * COLS, res);
    }
View Full Code Here

        assertEquals("3",map.get("c"));
    }

    @Test
    public void testConvert() throws Exception {
        final RowData rowData = new RowData("a:int\tb:float\tc:boolean", "\t", 0);
        final Map<String,Object> map = rowData.updateMap("1\t2.1\ttrue");
        assertEquals(1,map.get("a"));
        assertEquals(2.1F,map.get("b"));
        assertEquals(true,map.get("c"));
    }
View Full Code Here

TOP

Related Classes of org.neo4j.batchimport.importer.RowData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.