Examples of HStatement


Examples of org.apache.hadoop.hbase.hbql.client.HStatement

    @Test
    public void selectAll() throws HBqlException {

        final String query1 = "SELECT count() as cnt, max(val5) as max, min(val5) as min, min(val5+1) as min2 " +
                              "FROM aggmapping";
        HStatement stmt = connection.createStatement();
        List<HRecord> recList1 = stmt.executeQueryAndFetch(query1);
        assertTrue(recList1.size() == 1);
        HRecord rec = recList1.get(0);
        long cnt = (Long)rec.getCurrentValue("cnt");
        int max = (Integer)rec.getCurrentValue("max");
        int min = (Integer)rec.getCurrentValue("min");
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HStatement

        // Get a connection with an HTablePool size of 10
        HConnectionManager.setMaxPoolReferencesPerTablePerConnection(10);
        HConnection conn = HConnectionManager.newConnection();

        HStatement stmt = conn.createStatement();
        stmt.execute("CREATE TABLE table12 (f1(), f3()) IF NOT tableexists('table12')");

        stmt.execute("CREATE TEMP MAPPING sch9 FOR TABLE table12"
                     + "("
                     + "keyval key, "
                     + "f1 ("
                     + "    val1 string alias val1, "
                     + "    val2 string alias val2 "
                     + "), "
                     + "f3 ("
                     + "    val1 int alias val5, "
                     + "    val2 int alias val6 "
                     + "))");

        HResultSet<HRecord> rs = stmt.executeQuery("select * from sch9");

        for (HRecord rec : rs) {
            int val5 = (Integer)rec.getCurrentValue("val5");
            int val6 = (Integer)rec.getCurrentValue("val6");
            String val1 = (String)rec.getCurrentValue("val1");
            String val2 = (String)rec.getCurrentValue("val2");

            System.out.print("val5: " + val5);
            System.out.print(", val6: " + val6);
            System.out.print(", val1: " + val1);
            System.out.println(", val2: " + val2);
        }

        stmt.execute("DISABLE TABLE table12");
        stmt.execute("DROP TABLE table12");
        stmt.close();

        conn.close();

        // END SNIPPET: hbqlapi1
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HStatement

        // START SNIPPET: hbqlapi3

        HConnection conn = HConnectionManager.newConnection();

        HStatement stmt = conn.createStatement();
        stmt.execute("CREATE TABLE table12 (f1(), f3()) IF NOT tableexists('table12')");

        stmt.execute("CREATE TEMP MAPPING sch9 FOR TABLE table12"
                     + "("
                     + "keyval key, "
                     + "f1 ("
                     + "    val1 string alias val1, "
                     + "    val2 string alias val2 "
                     + "), "
                     + "f3 ("
                     + "    val1 int alias val5, "
                     + "    val2 int alias val6 "
                     + "))");

        if (!AsyncExecutorManager.asyncExecutorExists("async1"))
            AsyncExecutorManager.newAsyncExecutor("async1", 1, 10, Long.MAX_VALUE);

        conn.setAsyncExecutorName("async1");

        QueryFuture future = stmt.executeQueryAsync("select * from sch9",
                                                    new QueryListenerAdapter<HRecord>() {
                                                        public void onEachRow(final HRecord rec) throws HBqlException {
                                                            int val5 = (Integer)rec.getCurrentValue("val5");
                                                            int val6 = (Integer)rec.getCurrentValue("val6");
                                                            String val1 = (String)rec.getCurrentValue("val1");
                                                            String val2 = (String)rec.getCurrentValue("val2");

                                                            System.out.print("val5: " + val5);
                                                            System.out.print(", val6: " + val6);
                                                            System.out.print(", val1: " + val1);
                                                            System.out.println(", val2: " + val2);
                                                        }

                                                        public void onException(final ExceptionSource source,
                                                                                final HBqlException e) {
                                                            e.printStackTrace();
                                                        }
                                                    });

        try {
            future.await();
        }
        catch (InterruptedException e) {
            e.printStackTrace();
        }

        stmt.close();

        conn.close();

        // END SNIPPET: hbqlapi3
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HStatement

    private int showValues(final String sql, final boolean expectException) {

        Exception ex = null;
        try {
            HStatement stmt = connection.createStatement();
            HResultSet<HRecord> results = stmt.executeQuery(sql);

            int rec_cnt = 0;
            System.out.println("Results:");

            for (HRecord rec : results) {
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HStatement

    }

    @Test
    public void simpleSelect1() throws HBqlException {

        HStatement stmt = connection.createStatement();
        // stmt.execute("DROP INDEX foo1 ON MAPPING tab4 if indexexistsfortable('table21', 'foo1')");
        stmt.execute("CREATE INDEX foo1 ON MAPPING tab4 (f1:val1) if not indexexistsformapping('foo1', 'tab4')");

        final String q1 = "select * from tab4";
        final int rec_cnt = showValues(q1, false);
        assertTrue(rec_cnt == 10);
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HStatement

        }
    }

    private static void showValues(final String sql, final int cnt, final boolean printValues) throws HBqlException {

        HStatement stmt = connection.createStatement();
        HResultSet<HRecord> results = stmt.executeQuery(sql);

        int rec_cnt = 0;
        for (HRecord rec : results) {

            String keyval = (String)rec.getCurrentValue("keyval");
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HStatement

    private static int showValues(final HConnection conn,
                                  final String sql,
                                  final int cnt,
                                  final boolean printValues) throws HBqlException {

        HStatement stmt = conn.createStatement();
        HResultSet<HRecord> results = stmt.executeQuery(sql);

        int rec_cnt = 0;
        for (HRecord rec : results) {

            String keyval = (String)rec.getCurrentValue("keyval");
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HStatement

    }

    @Test
    public void simpleSelect9a() throws HBqlException {

        HStatement stmt = connection.createStatement();
        System.out.println(stmt.execute("CREATE QUERY EXECUTOR POOL threadPool1 " +
                                        "(max_executor_pool_size: 5, max_thread_count: 2, " +
                                        "threads_read_results: true, completion_queue_size: 100) " +
                                        "if not queryExecutorPoolExists('threadPool1')"));

        // ExecutorPoolManager.newExecutorPool("threadPool1", 2, 10);
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HStatement

    }

    @Test
    public void simpleSelect10() throws HBqlException {

        HStatement stmt = connection.createStatement();

        System.out.println(stmt.execute("CREATE QUERY EXECUTOR POOL threadPool1 " +
                                        "(max_executor_pool_size: 5, max_thread_count: 4, " +
                                        "threads_read_results: true, completion_queue_size: 100) " +
                                        "if not queryExecutorPoolExists('threadPool1')"));
        System.out
                .println(stmt.execute("DROP QUERY EXECUTOR POOL threadPool1 if queryExecutorPoolExists('threadPool1')"));
        System.out.println(stmt.execute("CREATE QUERY EXECUTOR POOL threadPool1 " +
                                        "(max_executor_pool_size: 5, max_thread_count: 4, " +
                                        "threads_read_results: true, completion_queue_size: 100)"));

        connection.setQueryExecutorPoolName("threadPool1");
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HStatement

                        firstTime = false;
                    q1.append("'0000000001'TO '0000000009'");
                }
                q1.append("SERVER FILTER where val1+'ss' BETWEEN '11ss' AND '13ss' ");

                HStatement stmt = connection.createStatement();
                QueryFuture future = stmt.executeQueryAsync(q1.toString(), new QueryListener<HRecord>() {
                    AtomicInteger rec_cnt = new AtomicInteger(0);

                    public void onQueryStart() {
                        //System.out.println("Starting query");
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.