Package shark.api

Examples of shark.api.JavaTableRDD


        Assert.assertTrue(result.contains("val_407"));
    }

    @Test
    public void sql2rdd() {
        JavaTableRDD result = sc.sql2rdd("select val from test_java");
        JavaRDD<String> values = result.map(new Function<Row, String>() {
            @Override
            public String call(Row x) {
                return x.getString(0);
            }
        });
View Full Code Here


        Assert.assertTrue(values.collect().contains("val_407"));
    }

    @Test
    public void filter() {
        JavaTableRDD result = sc.sql2rdd("select * from users_java");
        JavaTableRDD filtered = result.filter(new Function<Row, Boolean>() {
            @Override
            public Boolean call(Row row) throws Exception {
                return row.getString("name").equals("B");
            }
        }).cache();
        Assert.assertEquals(1, filtered.count());
        Assert.assertEquals(2, filtered.first().getInt("id").intValue());
    }
View Full Code Here

        Assert.assertEquals(2, filtered.first().getInt("id").intValue());
    }

    @Test
    public void union() {
        JavaTableRDD a = sc.sql2rdd("select * from users_java where name = \"A\"");
        JavaTableRDD b = sc.sql2rdd("select * from users_java where name = \"B\"");
        JavaTableRDD union = a.union(b);
        Assert.assertEquals(3, union.count());
        List<String> uniqueNames = union.map(new Function<Row, String>() {
            @Override
            public String call(Row row) throws Exception {
                return row.getString("name");
            }
        }).distinct().collect();
View Full Code Here

TOP

Related Classes of shark.api.JavaTableRDD

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.