Package org.apache.hadoop.hbase.hbql.client

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


        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();
        }

View Full Code Here


                    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");
                    }

                    public void onEachRow(final HRecord rec) throws HBqlException {
                        String keyval = (String)rec.getCurrentValue("keyval");
                        String val1 = (String)rec.getCurrentValue("val1");
                        int val2 = (Integer)rec.getCurrentValue("f1:val2");
                        int val3 = (Integer)rec.getCurrentValue("val3");
                        //System.out.println("Current Values: " + keyval + " : " + val1 + " : " + val2 + " : " + val3);
                        this.rec_cnt.incrementAndGet();
                    }

                    public void onQueryComplete() {
                        System.out.println("Finished query with rec_cnt = " + rec_cnt.get() + " vs " + (keyCount * 3));
                        assertTrue(rec_cnt.get() == keyCount * 3);
                    }

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

            for (final QueryFuture future : futureList) {
                try {
                    future.await();
                }
                catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.hbql.client.QueryFuture

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.