Package org.voltdb

Examples of org.voltdb.VoltTable


                secondString,
                "",
                "",
                VoltType.NULL_DECIMAL
        };
        VoltTable results[] = client.callProcedure("Insert", params).getResults();
        params = null;
        firstString = null;
        secondString = null;

        assertEquals(results.length, 1);
View Full Code Here


                case DECIMAL:
                    BigDecimal bd = VoltDecimalHelper.deserializeBigDecimal(fds);
                    VoltDecimalHelper.serializeBigDecimal(bd, fs);
                    break;
                case VOLTTABLE:
                    VoltTable table = fds.readObject(VoltTable.class);
                    fs.writeObject(table);
                    break;
                default:
                    throw new RuntimeException("FIXME: Unsupported type " + type);
                }
View Full Code Here

        // Make sure that our vote is actually in the real table and materialized views
        String query = "SELECT COUNT(*) FROM votes";
        ClientResponse cresponse = client.callProcedure("@AdHoc", query);
        System.err.println(cresponse);
        assertEquals(Status.OK, cresponse.getStatus());
        VoltTable results[] = cresponse.getResults();
        assertEquals(1, results.length);
        assertEquals(numCompleted.get(), results[0].asScalarLong());
       
       
        // TODO: We should go through the log and make sure that all of our
View Full Code Here

   
    @Test
    public void testMMRquery1 () throws IOException, ProcCallException {
        //int num_partitions = this.getServerConfig().getPartitionCount();
        Client client = this.getClient();
        final VoltTable vt = this.loadTable_ORDER_LINE(client);
       
        assertEquals(vt.getColumnCount(), 10);
       
        // Computer Query1 information
        /* MapReduce OLAP Experimental Queries
        addStmtProcedure("OLAPQuery1",
                         "SELECT ol_number, SUM(ol_quantity), SUM(ol_amount), " +
                         "       AVG(ol_quantity), AVG(ol_amount), COUNT(*)" +
                         "  FROM ORDER_LINE " +
                         " GROUP BY ol_number order by ol_number");*/
       
        // 0:ol_number,1:sum(ol_quantity),2:SUM(ol_amount),3:weight(ol_quantity),4:weight(ol_amount),5:sum
        List< List<Object>> rtLists = new ArrayList< List< Object >>();
        vt.resetRowPosition();
        Map<Integer,Integer> map = new HashMap<Integer,Integer>();
        //Set <Integer> keyset = new HashSet <Integer>();
        Integer ct = 0;
        while(vt.advanceRow()) {
            Integer key = new Integer ((int) vt.getLong(3));
            if (!map.containsKey(key)) {
                map.put(new Integer ((int) vt.getLong(3)),ct);
                List <Object> cont = new ArrayList<Object>();
                rtLists.add(ct,cont);
               
                cont.add(0,key);
                //rtLists.get(ct).add(0, vt.getLong(3));
                if (cont.size() < 2) cont.add(1, vt.getLong(7));
                else cont.set(1, vt.getLong(7) + ((Long)cont.get(1)).longValue());
                if (cont.size() < 3) cont.add(2, vt.getDouble(8));
                else cont.set(2, vt.getDouble(8) + ((Double)cont.get(2)).doubleValue());
                if (cont.size() < 4) cont.add(3, 1);
                else cont.set(3, ((Integer)cont.get(3)).intValue() + 1);
               
                ct++;
            } else {
                int index = map.get(key);
                assertEquals(key, rtLists.get(index).get(0));
                //rtLists.get(ct).set(0, vt.getLong(3));
                rtLists.get(index).set(1, vt.getLong(7) + ((Long)rtLists.get(index).get(1)).longValue());
                rtLists.get(index).set(2, vt.getDouble(8) + ((Double)rtLists.get(index).get(2)).doubleValue());
                rtLists.get(index).set(3, ((Integer)rtLists.get(index).get(3) ).intValue()+ 1);
            }
        }
       
        // execute MapReduce Transaction to check the result
View Full Code Here

                CONSTRAINT OL_FKEY_S FOREIGN KEY (OL_I_ID, OL_SUPPLY_W_ID) REFERENCES STOCK (S_I_ID, S_W_ID)
              );
              */
       
        Random rand = new Random(0);
        VoltTable vt = CatalogUtil.getVoltTable(catalog_tbl);
        int col_cnt = vt.getColumnCount();
        for (int i = 0; i < num_tuples; i++) {
            Object row[] = new Object[col_cnt];
            int col = 0;
            row[col++] = i;
            row[col++] = i;
            row[col++] = i;
            row[col++] = rand.nextInt(10); // OL_NUMBER
            col+=3; // disregard OL_I_ID,OL_SUPPLY_W_ID,OL_DELIVERY_D
            row[col++] = i * 2;
            row[col++] = 1.2 * i;
            row[col++] = "null message";
            assertEquals(col, 10);
            vt.addRow(row);
        } // FOR
       
        ClientResponse cr = client.callProcedure("@LoadMultipartitionTable", catalog_tbl.getName(), vt);
        assertEquals(Status.OK, cr.getStatus());
       
View Full Code Here

        return (cresponse);
    }
   
    public static long getRowCount(Client client, Table tbl) throws Exception {
        ClientResponse cresponse = getStats(client, SysProcSelector.TABLE);
        VoltTable result = cresponse.getResults()[0];
       
        long count = 0;
        boolean found = false;
        while (result.advanceRow()) {
            if (tbl.getName().equalsIgnoreCase(result.getString("TABLE_NAME"))) {
                found = true;
                count += result.getLong("TUPLE_COUNT");
                if (tbl.getIsreplicated()) break;
            }
        } // WHILE
        if (found == false) {
            throw new IllegalArgumentException("Invalid table '" + tbl + "'");
View Full Code Here

     * @param num_tuples
     * @throws IOException
     * @throws ProcCallException
     */
    public static void loadRandomData(Client client, Table catalog_tbl, Random rand, int num_tuples) throws IOException, ProcCallException {
        VoltTable vt = CatalogUtil.getVoltTable(catalog_tbl);
        int num_cols = catalog_tbl.getColumns().size();
        VoltType types[] = new VoltType[num_cols];
        int maxSizes[] = new int[num_cols];
        for (Column catalog_col : catalog_tbl.getColumns()) {
            int idx = catalog_col.getIndex();
            types[idx] = VoltType.get(catalog_col.getType());
            if (types[idx] == VoltType.STRING) {
                maxSizes[idx] = catalog_col.getSize();
            }
        } // FOR
       
        for (int i = 0; i < num_tuples; i++) {
            Object row[] = new Object[num_cols];
            for (int col = 0; col < num_cols; col++) {
                row[col] = VoltTypeUtil.getRandomValue(types[col], rand);
                if (types[col] == VoltType.STRING) {
                    if (row[col].toString().length() >= maxSizes[col]) {
                        row[col] = row[col].toString().substring(0, maxSizes[col]-1);
                    }
                }
            } // FOR (col)
            vt.addRow(row);
        } // FOR (row)
        // System.err.printf("Loading %d rows for %s\n%s\n\n", vt.getRowCount(), catalog_tbl, vt.toString());
        load(client, catalog_tbl, vt);
    }
View Full Code Here

            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        if (returnData != 0) {
            /**
             * Return large data set so that IO buffers fill faster
             */
            final VoltTable table = new VoltTable(new VoltTable.ColumnInfo[] {
                    new VoltTable.ColumnInfo("foo", VoltType.STRING),
                    new VoltTable.ColumnInfo("foo", VoltType.STRING),
                    new VoltTable.ColumnInfo("foo", VoltType.STRING)
            });
            table.addRow(returnString, returnString, returnString);

            return new VoltTable[] {table};
        } else {
            return new VoltTable[0];
        }
View Full Code Here

        this.initializeDatabase(client);
       
        String query = "SELECT COUNT(*) FROM contestants";
        ClientResponse cresponse = client.callProcedure("@AdHoc", query);
        assertEquals(Status.OK, cresponse.getStatus());
        VoltTable results[] = cresponse.getResults();
        assertEquals(1, results.length);
        assertEquals(VoterConstants.NUM_CONTESTANTS, results[0].asScalarLong());
        System.err.println(results[0]);
    }
View Full Code Here

                                                        voteId++,
                                                        phoneNumber,
                                                        contestantNumber,
                                                        maxVotesPerPhoneNumber);
        assertEquals(Status.OK, cresponse.getStatus());
        VoltTable results[] = cresponse.getResults();
        assertEquals(1, results.length);
        assertEquals(VoterConstants.VOTE_SUCCESSFUL, results[0].asScalarLong());
       
        // Make sure that our vote is actually in the real table and materialized views
        String query = "SELECT COUNT(*) FROM votes";
View Full Code Here

TOP

Related Classes of org.voltdb.VoltTable

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.