Package com.facebook.presto.kafka

Examples of com.facebook.presto.kafka.KafkaColumnHandle


    public void testSimple()
    {
        String csv = "\"row 1\",row2,\"row3\",100,\"200\",300,4.5";

        CsvKafkaRowDecoder rowDecoder = new CsvKafkaRowDecoder();
        KafkaColumnHandle row1 = new KafkaColumnHandle("", 0, "row1", VarcharType.VARCHAR, "0", null, null, false, false, false);
        KafkaColumnHandle row2 = new KafkaColumnHandle("", 1, "row2", VarcharType.VARCHAR, "1", null, null, false, false, false);
        KafkaColumnHandle row3 = new KafkaColumnHandle("", 2, "row3", VarcharType.VARCHAR, "2", null, null, false, false, false);
        KafkaColumnHandle row4 = new KafkaColumnHandle("", 3, "row4", BigintType.BIGINT, "3", null, null, false, false, false);
        KafkaColumnHandle row5 = new KafkaColumnHandle("", 4, "row5", BigintType.BIGINT, "4", null, null, false, false, false);
        KafkaColumnHandle row6 = new KafkaColumnHandle("", 5, "row6", BigintType.BIGINT, "5", null, null, false, false, false);
        KafkaColumnHandle row7 = new KafkaColumnHandle("", 6, "row7", DoubleType.DOUBLE, "6", null, null, false, false, false);

        List<KafkaColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4, row5, row6, row7);
        Set<KafkaFieldValueProvider> providers = new HashSet<>();

        boolean corrupt = rowDecoder.decodeRow(csv.getBytes(StandardCharsets.UTF_8), providers, columns, buildMap(columns));
View Full Code Here


    {
        String csv = "True,False,0,1,\"0\",\"1\",\"true\",\"false\"";

        CsvKafkaRowDecoder rowDecoder = new CsvKafkaRowDecoder();

        KafkaColumnHandle row1 = new KafkaColumnHandle("", 0, "row1", BooleanType.BOOLEAN, "0", null, null, false, false, false);
        KafkaColumnHandle row2 = new KafkaColumnHandle("", 1, "row2", BooleanType.BOOLEAN, "1", null, null, false, false, false);
        KafkaColumnHandle row3 = new KafkaColumnHandle("", 2, "row3", BooleanType.BOOLEAN, "2", null, null, false, false, false);
        KafkaColumnHandle row4 = new KafkaColumnHandle("", 3, "row4", BooleanType.BOOLEAN, "3", null, null, false, false, false);
        KafkaColumnHandle row5 = new KafkaColumnHandle("", 4, "row5", BooleanType.BOOLEAN, "4", null, null, false, false, false);
        KafkaColumnHandle row6 = new KafkaColumnHandle("", 5, "row6", BooleanType.BOOLEAN, "5", null, null, false, false, false);
        KafkaColumnHandle row7 = new KafkaColumnHandle("", 6, "row7", BooleanType.BOOLEAN, "6", null, null, false, false, false);
        KafkaColumnHandle row8 = new KafkaColumnHandle("", 7, "row8", BooleanType.BOOLEAN, "7", null, null, false, false, false);

        List<KafkaColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4, row5, row6, row7, row8);

        Set<KafkaFieldValueProvider> providers = new HashSet<>();
View Full Code Here

    {
        String csv = ",,,";

        CsvKafkaRowDecoder rowDecoder = new CsvKafkaRowDecoder();

        KafkaColumnHandle row1 = new KafkaColumnHandle("", 0, "row1", VarcharType.VARCHAR, "0", null, null, false, false, false);
        KafkaColumnHandle row2 = new KafkaColumnHandle("", 1, "row2", BigintType.BIGINT, "1", null, null, false, false, false);
        KafkaColumnHandle row3 = new KafkaColumnHandle("", 2, "row3", DoubleType.DOUBLE, "2", null, null, false, false, false);
        KafkaColumnHandle row4 = new KafkaColumnHandle("", 3, "row4", BooleanType.BOOLEAN, "3", null, null, false, false, false);

        List<KafkaColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);

        Set<KafkaFieldValueProvider> providers = new HashSet<>();
View Full Code Here

        byte[] row = new byte[buf.position()];
        System.arraycopy(buf.array(), 0, row, 0, buf.position());

        RawKafkaRowDecoder rowDecoder = new RawKafkaRowDecoder();
        KafkaColumnHandle row1 = new KafkaColumnHandle("", 0, "row1", BigintType.BIGINT, "0", "LONG", null, false, false, false);
        KafkaColumnHandle row2 = new KafkaColumnHandle("", 1, "row2", BigintType.BIGINT, "8", "INT", null, false, false, false);
        KafkaColumnHandle row3 = new KafkaColumnHandle("", 2, "row3", BigintType.BIGINT, "12", "SHORT", null, false, false, false);
        KafkaColumnHandle row4 = new KafkaColumnHandle("", 3, "row4", BigintType.BIGINT, "14", "BYTE", null, false, false, false);
        KafkaColumnHandle row5 = new KafkaColumnHandle("", 4, "row5", VarcharType.VARCHAR, "15", null, null, false, false, false);

        List<KafkaColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4, row5);
        Set<KafkaFieldValueProvider> providers = new HashSet<>();

        boolean corrupt = rowDecoder.decodeRow(row, providers, columns, buildMap(columns));
View Full Code Here

    {
        String str = "Ich bin zwei Oeltanks";
        byte[] row = str.getBytes(StandardCharsets.UTF_8);

        RawKafkaRowDecoder rowDecoder = new RawKafkaRowDecoder();
        KafkaColumnHandle row1 = new KafkaColumnHandle("", 0, "row1", VarcharType.VARCHAR, null, null, null, false, false, false);
        KafkaColumnHandle row2 = new KafkaColumnHandle("", 1, "row2", VarcharType.VARCHAR, "0", null, null, false, false, false);
        KafkaColumnHandle row3 = new KafkaColumnHandle("", 2, "row3", VarcharType.VARCHAR, "0:4", null, null, false, false, false);
        KafkaColumnHandle row4 = new KafkaColumnHandle("", 3, "row4", VarcharType.VARCHAR, "5:8", null, null, false, false, false);

        List<KafkaColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);
        Set<KafkaFieldValueProvider> providers = new HashSet<>();

        boolean corrupt = rowDecoder.decodeRow(row, providers, columns, buildMap(columns));
View Full Code Here

        byte[] row = new byte[buf.position()];
        System.arraycopy(buf.array(), 0, row, 0, buf.position());

        RawKafkaRowDecoder rowDecoder = new RawKafkaRowDecoder();
        KafkaColumnHandle row1 = new KafkaColumnHandle("", 0, "row1", VarcharType.VARCHAR, null, "DOUBLE", null, false, false, false);
        KafkaColumnHandle row2 = new KafkaColumnHandle("", 1, "row2", VarcharType.VARCHAR, "8", "FLOAT", null, false, false, false);

        List<KafkaColumnHandle> columns = ImmutableList.of(row1, row2);
        Set<KafkaFieldValueProvider> providers = new HashSet<>();

        boolean corrupt = rowDecoder.decodeRow(row, providers, columns, buildMap(columns));
View Full Code Here

        byte[] row = new byte[buf.position()];
        System.arraycopy(buf.array(), 0, row, 0, buf.position());

        RawKafkaRowDecoder rowDecoder = new RawKafkaRowDecoder();
        KafkaColumnHandle row01 = new KafkaColumnHandle("", 0, "row01", BigintType.BIGINT, "0", "BYTE", null, false, false, false);
        KafkaColumnHandle row02 = new KafkaColumnHandle("", 1, "row02", BooleanType.BOOLEAN, "1", "LONG", null, false, false, false);
        KafkaColumnHandle row03 = new KafkaColumnHandle("", 2, "row03", BigintType.BIGINT, "9", "BYTE", null, false, false, false);
        KafkaColumnHandle row04 = new KafkaColumnHandle("", 3, "row04", BooleanType.BOOLEAN, "10", "LONG", null, false, false, false);

        KafkaColumnHandle row11 = new KafkaColumnHandle("", 4, "row11", BigintType.BIGINT, "18", "BYTE", null, false, false, false);
        KafkaColumnHandle row12 = new KafkaColumnHandle("", 5, "row12", BooleanType.BOOLEAN, "19", "INT", null, false, false, false);
        KafkaColumnHandle row13 = new KafkaColumnHandle("", 6, "row13", BigintType.BIGINT, "23", "BYTE", null, false, false, false);
        KafkaColumnHandle row14 = new KafkaColumnHandle("", 7, "row14", BooleanType.BOOLEAN, "24", "INT", null, false, false, false);

        KafkaColumnHandle row21 = new KafkaColumnHandle("", 8, "row21", BigintType.BIGINT, "28", "BYTE", null, false, false, false);
        KafkaColumnHandle row22 = new KafkaColumnHandle("", 9, "row22", BooleanType.BOOLEAN, "29", "SHORT", null, false, false, false);
        KafkaColumnHandle row23 = new KafkaColumnHandle("", 10, "row23", BigintType.BIGINT, "31", "BYTE", null, false, false, false);
        KafkaColumnHandle row24 = new KafkaColumnHandle("", 11, "row24", BooleanType.BOOLEAN, "32", "SHORT", null, false, false, false);

        KafkaColumnHandle row31 = new KafkaColumnHandle("", 12, "row31", BigintType.BIGINT, "34", "BYTE", null, false, false, false);
        KafkaColumnHandle row32 = new KafkaColumnHandle("", 13, "row32", BooleanType.BOOLEAN, "35", "BYTE", null, false, false, false);
        KafkaColumnHandle row33 = new KafkaColumnHandle("", 14, "row33", BigintType.BIGINT, "36", "BYTE", null, false, false, false);
        KafkaColumnHandle row34 = new KafkaColumnHandle("", 15, "row34", BooleanType.BOOLEAN, "37", "BYTE", null, false, false, false);

        List<KafkaColumnHandle> columns = ImmutableList.of(row01,
                row02,
                row03,
                row04,
View Full Code Here

            throws Exception
    {
        byte[] json = ByteStreams.toByteArray(TestJsonDecoder.class.getResourceAsStream("/decoder/json/message.json"));

        JsonKafkaRowDecoder rowDecoder = new JsonKafkaRowDecoder(PROVIDER.get());
        KafkaColumnHandle row1 = new KafkaColumnHandle("", 0, "row1", VarcharType.VARCHAR, "source", null, null, false, false, false);
        KafkaColumnHandle row2 = new KafkaColumnHandle("", 1, "row2", VarcharType.VARCHAR, "user/screen_name", null, null, false, false, false);
        KafkaColumnHandle row3 = new KafkaColumnHandle("", 2, "row3", BigintType.BIGINT, "id", null, null, false, false, false);
        KafkaColumnHandle row4 = new KafkaColumnHandle("", 3, "row4", BigintType.BIGINT, "user/statuses_count", null, null, false, false, false);
        KafkaColumnHandle row5 = new KafkaColumnHandle("", 4, "row5", BooleanType.BOOLEAN, "user/geo_enabled", null, null, false, false, false);

        List<KafkaColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4, row5);
        Set<KafkaFieldValueProvider> providers = new HashSet<>();

        boolean corrupt = rowDecoder.decodeRow(json, providers, columns, buildMap(columns));
View Full Code Here

            throws Exception
    {
        byte[] json = "{}".getBytes(StandardCharsets.UTF_8);

        JsonKafkaRowDecoder rowDecoder = new JsonKafkaRowDecoder(PROVIDER.get());
        KafkaColumnHandle row1 = new KafkaColumnHandle("", 0, "row1", VarcharType.VARCHAR, "very/deep/varchar", null, null, false, false, false);
        KafkaColumnHandle row2 = new KafkaColumnHandle("", 1, "row2", BigintType.BIGINT, "no_bigint", null, null, false, false, false);
        KafkaColumnHandle row3 = new KafkaColumnHandle("", 2, "row3", DoubleType.DOUBLE, "double/is_missing", null, null, false, false, false);
        KafkaColumnHandle row4 = new KafkaColumnHandle("", 3, "row4", BooleanType.BOOLEAN, "hello", null, null, false, false, false);

        List<KafkaColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);
        Set<KafkaFieldValueProvider> providers = new HashSet<>();

        boolean corrupt = rowDecoder.decodeRow(json, providers, columns, buildMap(columns));
View Full Code Here

            throws Exception
    {
        byte[] json = "{\"a_number\":481516,\"a_string\":\"2342\"}".getBytes(StandardCharsets.UTF_8);

        JsonKafkaRowDecoder rowDecoder = new JsonKafkaRowDecoder(PROVIDER.get());
        KafkaColumnHandle row1 = new KafkaColumnHandle("", 0, "row1", VarcharType.VARCHAR, "a_number", null, null, false, false, false);
        KafkaColumnHandle row2 = new KafkaColumnHandle("", 1, "row2", BigintType.BIGINT, "a_number", null, null, false, false, false);
        KafkaColumnHandle row3 = new KafkaColumnHandle("", 2, "row3", VarcharType.VARCHAR, "a_string", null, null, false, false, false);
        KafkaColumnHandle row4 = new KafkaColumnHandle("", 3, "row4", BigintType.BIGINT, "a_string", null, null, false, false, false);

        List<KafkaColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);
        Set<KafkaFieldValueProvider> providers = new HashSet<>();

        boolean corrupt = rowDecoder.decodeRow(json, providers, columns, buildMap(columns));
View Full Code Here

TOP

Related Classes of com.facebook.presto.kafka.KafkaColumnHandle

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.