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

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


        assertTrue(recList3.size() == 2);

        final String query4 = "SELECT val1, val5, (val5 - val5 + val5) as val6, (val5+val5) as val7 FROM tab8 " +
                              "WITH KEYS :key1";

        HPreparedStatement pstmt = connection.prepareStatement(query4);

        pstmt.setParameter("key1", "0000000001");
        List<HRecord> recList4 = pstmt.executeQueryAndFetch();

        assertTrue(recList4.size() == 1);

        final String query5 = "SELECT val1, val5, (val5 - val5 + val5) as val6, (val5+val5) as val7 FROM tab8 " +
                              "WITH KEYS :key1, :key2";

        pstmt = connection.prepareStatement(query5);
        pstmt.setParameter("key1", "0000000001");
        pstmt.setParameter("key2", "0000000002");
        List<HRecord> recList5 = pstmt.executeQueryAndFetch();

        assertTrue(recList5.size() == 2);

        final String query6 = "SELECT val1, val5, (val5 - val5 + val5) as val6, (val5+val5) as val7 FROM tab8 " +
                              "WITH KEYS :key1";
        pstmt = connection.prepareStatement(query6);

        List<String> listOfKeys = Lists.newArrayList();
        listOfKeys.add("0000000001");
        listOfKeys.add("0000000002");
        listOfKeys.add("0000000003");
        pstmt.setParameter("key1", listOfKeys);

        List<HRecord> recList6 = pstmt.executeQueryAndFetch();
        assertTrue(recList6.size() == 3);
    }
View Full Code Here


            boolean val2 = (Boolean)rec.getCurrentValue("expr-1");
            assertTrue(!val2);
        }

        final String query2 = "SELECT EVAL(:val1), EVAL(:val2) FROM tab8";
        HPreparedStatement pstmt = connection.prepareStatement(query2);
        pstmt.setParameter("val1", "TRUE OR FALSE");
        pstmt.setParameter("val2", "TRUE AND FALSE");
        List<HRecord> recList2 = pstmt.executeQueryAndFetch();
        assertTrue(recList2.size() == 10);
        for (final HRecord rec : recList2) {
            boolean val1 = (Boolean)rec.getCurrentValue("expr-0");
            assertTrue(val1);
            boolean val2 = (Boolean)rec.getCurrentValue("expr-1");
View Full Code Here

    private static void insertRecords(final HConnection connection,
                                      final int cnt,
                                      final String msg) throws HBqlException {

        HPreparedStatement stmt = connection.prepareStatement(
                "insert into pool_test " +
                "(keyval, val1, val2, val3, val11, val12, val13, val21, val22, val23 ) values " +
                "(:key, :val1, :val2, :val3, :val11, :val12, :val13, :val21, :val22, :val23)");

        for (int i = 0; i < cnt; i++) {

            final String keyval = Util.getZeroPaddedNonNegativeNumber(i, TestSupport.keywidth);

            int randomNum = randomVal.nextInt();
            String randomStr = "" + randomNum;

            stmt.setParameter("key", keyval);
            stmt.setParameter("val1", randomStr);
            stmt.setParameter("val2", randomStr + " " + msg);
            stmt.setParameter("val3", randomStr + " " + msg + " " + msg);
            stmt.setParameter("val11", randomStr);
            stmt.setParameter("val12", randomStr + " " + msg);
            stmt.setParameter("val13", randomStr + " " + msg + " " + msg);
            stmt.setParameter("val21", randomStr);
            stmt.setParameter("val22", randomStr + " " + msg);
            stmt.setParameter("val23", randomStr + " " + msg + " " + msg);
            stmt.execute();
        }
    }
View Full Code Here

    }

    private static void insertRecords(final HConnection connection,
                                      final int cnt) throws HBqlException {

        HPreparedStatement stmt = connection.prepareStatement("insert into tab3 " +
                                                              "(keyval, val1, val2, val3) values " +
                                                              "(:key, :val1, :val2, DEFAULT)");

        for (int i = 0; i < cnt; i++) {

            int val = 10 + i;

            final String keyval = Util.getZeroPaddedNonNegativeNumber(i, TestSupport.keywidth);

            stmt.setParameter("key", keyval);
            stmt.setParameter("val1", "" + val);
            stmt.setParameter("val2", val);
            stmt.execute();
        }
    }
View Full Code Here

        final String q1 = "insert into tab3 " +
                          "(keyval, val1, val2) " +
                          "select keyval, val1+val1, val2+1 FROM tab3 ";
        showValues();

        HPreparedStatement stmt = connection.prepareStatement(q1);

        ExecutionResults executionResults = stmt.execute();

        System.out.println(executionResults);

        showValues();
View Full Code Here

        final String q1 = "insert into tab3 " +
                          "(keyval, f1(val1, val2)) " +
                          "select keyval, val1+val1, val2+1 FROM tab3 ";
        showValues();

        HPreparedStatement stmt = connection.prepareStatement(q1);

        ExecutionResults executionResults = stmt.execute();

        System.out.println(executionResults);

        showValues();
View Full Code Here

        List<AnnotatedAllTypes> vals = insertSomeData(cnt, true);

        assertTrue(vals.size() == cnt);

        HPreparedStatement pstmt = conn.prepareStatement("select * from alltypes2 WITH LIMIT :limit");

        pstmt.setParameter("limit", cnt / 2);

        HResultSet<AnnotatedAllTypes> recs = pstmt.executeQuery(AnnotatedAllTypes.class);

        int reccnt = 0;
        for (final AnnotatedAllTypes rec : recs)
            assertTrue(rec.equals(vals.get(reccnt++)));

View Full Code Here

        List<RecordAllTypes> vals = insertSomeData(cnt, true);

        assertTrue(vals.size() == cnt);

        HPreparedStatement stmt = conn.prepareStatement("select * from alltypes WITH LIMIT :limit");

        stmt.setParameter("limit", cnt / 2);
        HResultSet<HRecord> recs = stmt.executeQuery();

        int reccnt = 0;
        for (final HRecord rec : recs)
            assertTrue((new RecordAllTypes(rec)).equals(vals.get(reccnt++)));

View Full Code Here

        List<RecordAllTypes> vals = insertSomeData(cnt, true);

        assertTrue(vals.size() == cnt);

        HPreparedStatement stmt = conn.prepareStatement("select * from alltypes " +
                                                        "WITH " +
                                                        "SERVER FILTER WHERE 1=1 " +
                                                        "LIMIT :limit");

        stmt.setParameter("limit", cnt / 2);
        HResultSet<HRecord> recs = stmt.executeQuery();

        int reccnt = 0;
        for (final HRecord rec : recs)
            assertTrue((new RecordAllTypes(rec)).equals(vals.get(reccnt++)));

View Full Code Here

    public static void insertRecords(final HConnection connection,
                                     final int cnt,
                                     final String msg) throws HBqlException {

        HPreparedStatement stmt = connection.prepareStatement(
                "insert into tab2 "
                + "(keyval, val1, val2, val5, val6, f3mapval1, f3mapval2, val8) values "
                + "(:key, :val1, :val2, :val5, :val6, :f3mapval1, :f3mapval2, :val8)");

        for (int i = 0; i < cnt; i++) {

            final String keyval = Util.getZeroPaddedNonNegativeNumber(i, TestSupport.keywidth);
            keyList.add(keyval);

            int val5 = randomVal.nextInt();
            String s_val5 = "" + val5;
            val1List.add(s_val5);
            val5List.add(val5);

            Map<String, String> mapval1 = Maps.newHashMap();
            mapval1.put("mapcol1", "mapcol1 val" + i + " " + msg);
            mapval1.put("mapcol2", "mapcol2 val" + i + " " + msg);

            Map<String, String> mapval2 = Maps.newHashMap();
            mapval2.put("mapcol1-b", "mapcol1-b val" + i + " " + msg);
            mapval2.put("mapcol2-b", "mapcol2-b val" + i + " " + msg);
            mapval2.put("mapcol3-b", "mapcol3-b val" + i + " " + msg);

            int[] intv1 = new int[5];
            val8check = new int[5];
            for (int j = 0; j < intv1.length; j++) {
                intv1[j] = j * 10;
                val8check[j] = intv1[j];
            }

            stmt.setParameter("key", keyval);
            stmt.setParameter("val1", s_val5);
            stmt.setParameter("val2", s_val5 + " " + msg);
            stmt.setParameter("val5", val5);
            stmt.setParameter("val6", i * 100);
            stmt.setParameter("f3mapval1", mapval1);
            stmt.setParameter("f3mapval2", mapval2);
            stmt.setParameter("val8", intv1);
            stmt.execute();
        }
    }
View Full Code Here

TOP

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

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.