Package org.voltdb.catalog

Examples of org.voltdb.catalog.Statement


    /**
     * testGetOrderByColumns
     */
    public void testGetOrderByColumns() throws Exception {
        Procedure catalog_proc = this.getProcedure(ostatByCustomerId.class);
        Statement catalog_stmt = this.getStatement(catalog_proc, "getLastOrder");
        Table catalog_tbl = this.getTable(TPCCConstants.TABLENAME_ORDERS);
        Column expected[] = { this.getColumn(catalog_tbl, "O_ID") };

        Collection<Column> cols = CatalogUtil.getOrderByColumns(catalog_stmt);
        assertNotNull(cols);
View Full Code Here


    /**
     * testCopyQueryPlans
     */
    public void testCopyQueryPlans() throws Exception {
        Procedure catalog_proc = this.getProcedure(neworder.class);
        Statement catalog_stmt = this.getStatement(catalog_proc, "getWarehouseTaxRate");

        Map<String, Object> orig_values = new HashMap<String, Object>();
        for (String f : catalog_stmt.getFields()) {
            orig_values.put(f, catalog_stmt.getField(f));
        } // FOR
        Map<String, Map<String, Object>> orig_frag_values = new HashMap<String, Map<String, Object>>();
        for (PlanFragment catalog_frag : CollectionUtils.union(catalog_stmt.getFragments(), catalog_stmt.getMs_fragments())) {
            Map<String, Object> m = new HashMap<String, Object>();
            for (String f : catalog_frag.getFields()) {
                Object val = catalog_frag.getField(f);
                if (val instanceof String)
                    val = StringUtil.md5sum(val.toString());
                m.put(f, val);
            } // FOR
            orig_frag_values.put(catalog_frag.fullName(), m);
        } // FOR
        // System.err.println(StringUtil.formatMaps(orig_frag_values));
        // System.err.println(StringUtil.SINGLE_LINE);

        Statement copy = catalog_proc.getStatements().add("TestStatement");
        assertNotNull(copy);
        assertFalse(copy.getHas_singlesited());
        assertEquals(0, copy.getFragments().size());
        assertTrue(copy.getFullplan().isEmpty());
        assertTrue(copy.getExptree().isEmpty());
        assertFalse(copy.getHas_multisited());
        assertEquals(0, copy.getMs_fragments().size());
        assertTrue(copy.getMs_fullplan().isEmpty());
        assertTrue(copy.getMs_exptree().isEmpty());

        CatalogUtil.copyQueryPlans(catalog_stmt, copy);

        // Make sure we didn't change the original
        for (String f : orig_values.keySet()) {
            assertEquals(f, orig_values.get(f), catalog_stmt.getField(f));
        } // FOR
        for (PlanFragment catalog_frag : CollectionUtils.union(catalog_stmt.getFragments(), catalog_stmt.getMs_fragments())) {
            Map<String, Object> m = orig_frag_values.get(catalog_frag.fullName());
            // System.err.println(catalog_frag.fullName());
            for (String f : m.keySet()) {
                Object orig_val = m.get(f);
                Object new_val = catalog_frag.getField(f);
                if (new_val instanceof String)
                    new_val = StringUtil.md5sum(new_val.toString());
                // System.err.println(String.format("\t%s = %s", f, new_val));
                assertEquals(catalog_frag.fullName() + " - " + f, orig_val, new_val);
            } // FOR
            // System.err.println(StringUtil.SINGLE_LINE);
        } // FOR

        // And then check that the destination was updated
        assertEquals(catalog_stmt.getHas_singlesited(), copy.getHas_singlesited());
        assertEquals(catalog_stmt.getFragments().size(), copy.getFragments().size());
        assertEquals(catalog_stmt.getFullplan(), copy.getFullplan());
        assertEquals(catalog_stmt.getExptree(), copy.getExptree());
        assertEquals(catalog_stmt.getHas_multisited(), copy.getHas_multisited());
        assertEquals(catalog_stmt.getMs_fragments().size(), copy.getMs_fragments().size());
        assertEquals(catalog_stmt.getMs_fullplan(), copy.getMs_fullplan());
        assertEquals(catalog_stmt.getMs_exptree(), copy.getMs_exptree());

        // Make sure the PlanFragments are the same
        for (boolean sp : new boolean[] { true, false }) {
            CatalogMap<PlanFragment> copy_src_fragments = null;
            CatalogMap<PlanFragment> copy_dest_fragments = null;
            if (sp) {
                copy_src_fragments = catalog_stmt.getFragments();
                copy_dest_fragments = copy.getFragments();
            } else {
                copy_src_fragments = catalog_stmt.getMs_fragments();
                copy_dest_fragments = copy.getMs_fragments();
            }
            assert (copy_src_fragments != null);
            assert (copy_dest_fragments != null);

            for (PlanFragment copy_src_frag : copy_src_fragments) {
View Full Code Here

    @Test
    public void testComparePathsFull_Penalty1() throws Exception {
        // Grab the actual path in the State and cut it off after the first
        // invocation of neworder.getCustomer().
        Procedure catalog_proc = this.getProcedure(TARGET_PROCEDURE);
        Statement catalog_stmt = this.getStatement(catalog_proc, "getCustomer");
        List<MarkovVertex> actual = this.txn_state.getActualPath();
        List<MarkovVertex> orig = new ArrayList<MarkovVertex>(actual);
        actual.clear();
        for (MarkovVertex mv : orig) {
            actual.add(mv);
            if (mv.getCatalogItemName().equalsIgnoreCase(catalog_stmt.getName())) {
                break;
            }
        } // FOR
        assertNotSame(orig.size(), actual.size());
       
View Full Code Here

        } // FOR
       
        // Then add another transaction for another procedure that doesn't have
        // duplicate queries
        Procedure new_proc = this.getProcedure(GetAccessData.class);
        Statement new_stmt = this.getStatement(new_proc, "GetData");
        TransactionTrace new_txn_trace = new TransactionTrace(pruned.getTransactionCount() + 100, new_proc, new Object[] { new Long(1), new Long(2) });
        for (int i = 0; i < NUM_QUERIES; i++) {
            Object new_params[] = new Object[] { new Long(i), new Long(2) };
            QueryTrace new_query_trace = new QueryTrace(new_stmt, new_params, i % 3);
            new_txn_trace.addQuery(new_query_trace);
View Full Code Here

            assert(prefetchState != null);
            for (int i = 0; i < batchSize; i++) {
                // We always have to update the query tracker regardless of whether
                // the query was prefetched or not. This is so that we can ensure
                // that we execute the queries in the right order.
                Statement stmt = batchStmts[i].getStatement();
                stmtCounters[i] = queryTracker.addQuery(stmt, stmtPartitions[i], batchParams[i]);
            } // FOR
            // FIXME PrefetchQueryUtil.checkSQLStmtBatch(this, ts, plan, batchSize, batchStmts, batchParams);
        } // PREFETCH
       
View Full Code Here

                if (frag.getPartitionId() != this.partitionId) {
                    has_remote = true;
                }
                for (int frag_id : frag.getFragmentIdList()) {
                    PlanFragment catalog_frag = CatalogUtil.getPlanFragment(catalogContext.database, frag_id);
                    Statement catalog_stmt = catalog_frag.getParent();
                    assert(catalog_stmt != null);
                    Procedure catalog_proc = catalog_stmt.getParent();
                    if (catalog_proc.equals(ts.getProcedure()) == false) {
                        LOG.warn(ts.debug() + "\n" + allFragmentBuilders + "\n---- INVALID ----\n" + frag);
                        String msg = String.format("%s - Unexpected %s", ts, catalog_frag.fullName());
                        throw new ServerFaultException(msg, ts.getTransactionId());
                    }
View Full Code Here

     * testMultipleAggregates
     */
    @Test
    public void testMultipleAggregates() throws Exception {
        Procedure catalog_proc = this.getProcedure("MultipleAggregates");
        Statement catalog_stmt = this.getStatement(catalog_proc, "sql");
        this.check(catalog_stmt);
    }
View Full Code Here

     * testExtractReferencedColumns
     */
    @Test
    public void testExtractReferencedColumns() throws Exception {
        Procedure catalog_proc = this.getProcedure("DistinctCount");
        Statement catalog_stmt = this.getStatement(catalog_proc, "sql");
       
        AbstractPlanNode root = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, true);
        assertNotNull(root);
       
        Collection<SeqScanPlanNode> scan_nodes = PlanNodeUtil.getPlanNodes(root, SeqScanPlanNode.class);
View Full Code Here

     * testDistinctAggregate
     */
    @Test
    public void testDistinctAggregate() throws Exception {
        Procedure catalog_proc = this.getProcedure("DistinctAggregate");
        Statement catalog_stmt = this.getStatement(catalog_proc, "sql");
        this.check(catalog_stmt);
    }
View Full Code Here

     * testDistinctCount
     */
    @Test
    public void testDistinctCount() throws Exception {
        Procedure catalog_proc = this.getProcedure("DistinctCount");
        Statement catalog_stmt = this.getStatement(catalog_proc, "sql");
        this.check(catalog_stmt);
    }
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.Statement

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.