Package org.voltdb.catalog

Examples of org.voltdb.catalog.Table


        this.generator = new AccessGraphGenerator(this.info, catalog_proc);
        this.generator.generate(agraph);
        assert(agraph.getVertexCount() > 0);
       
        // Make sure it has a vertex for HISTORY
        Table catalog_tbl = this.getTable("HISTORY");
        DesignerVertex v = agraph.getVertex(catalog_tbl);
        assertNotNull(v);
       
        // And make sure that it has edges
        agraph.setVerbose(true);
        Collection<DesignerEdge> edges = agraph.getIncidentEdges(v);
        assertFalse(edges.isEmpty());
       
        Set<Table> expected = new HashSet<Table>();
        CollectionUtil.addAll(expected, this.getTable("WAREHOUSE"),
                                        this.getTable("DISTRICT"),
                                        this.getTable("CUSTOMER"));
        Set<Table> actual = new HashSet<Table>();
        for (DesignerEdge e : edges) {
            DesignerVertex other_v = agraph.getOpposite(v, e);
            assertNotNull(other_v);
            Table other_tbl = other_v.getCatalogItem();
            assertNotNull(other_tbl);
            if (other_tbl.equals(catalog_tbl)) {
                assertEquals(v, other_v);
            } else {
                assert(expected.contains(other_tbl)) : other_tbl;
                actual.add(other_tbl);
            }
View Full Code Here


   
    /**
     * testRewriteSQL
     */
    public void testRewriteSQL() throws Exception {
        Table catalog_tbl = this.getTable(TM1Constants.TABLENAME_SUBSCRIBER);
        Table view_tbl = CatalogUtil.getVerticalPartition(catalog_tbl).getDest();
        Map<Table, Table> m = new HashMap<Table, Table>();
        m.put(catalog_tbl, view_tbl);
       
        for (int i = 0; i < REWRITE_SQLS.length; i++) {
            String procName = String.format("TestRewrite%d", i);
View Full Code Here

     */
    public void testOrderByQuery() throws Exception {
        String vp_cols[] = { "S_ID", "SUB_NBR", "MSC_LOCATION" };
        super.setUp(new MockProjectBuilder(vp_cols), true);
       
        Table catalog_tbl = this.getTable(TM1Constants.TABLENAME_SUBSCRIBER);
        MaterializedViewInfo view = CatalogUtil.getVerticalPartition(catalog_tbl);
        assertNotNull(view);
        assertEquals(CatalogUtil.debug(view.getGroupbycols()), vp_cols.length, view.getGroupbycols().size());
       
        Procedure catalog_proc = this.getProcedure("TestOrderBy");
        Statement catalog_stmt = CollectionUtil.first(catalog_proc.getStatements());
        assert(catalog_stmt != null) : catalog_proc.getStatements();
        Object params[] = new Object[]{ "ABC" };
       
        Integer base_partition = new Random().nextInt(NUM_PARTITIONS);
       
        // We don't actually care whether this got turned to a single-partition txn
        // We just care that it got optimized properly with the ORDER BY
        VerticalPartitionPlanner vp_planner = new VerticalPartitionPlanner(catalog_db, true);
        boolean ret = vp_planner.optimizeStatement(catalog_stmt);
        assert(ret);
        p_estimator.clear();
        PartitionSet new_partitions = new PartitionSet();
        p_estimator.getAllPartitions(new_partitions, catalog_stmt, params, base_partition);
        assertNotNull(new_partitions);
//        System.err.println("NEW PARTITIONS: " + new_partitions);
        assertEquals(1, new_partitions.size());
        assertEquals(base_partition, CollectionUtil.first(new_partitions));
       
        // Make sure the ORDER BY column references the vertical partition table
        CatalogUtil.clearCache(catalog_db);
        PlanNodeUtil.clearCache();
        Collection<Column> orderByCols = CatalogUtil.getOrderByColumns(catalog_stmt);
        assertNotNull(orderByCols);
        assertFalse(orderByCols.isEmpty());
//        System.err.println(PlanNodeUtil.debug(PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, false)));
        for (Column catalog_col : orderByCols) {
            Table parent = catalog_col.getParent();
            assertNotNull(parent);
            assertEquals(view.getDest(), parent);
        } // FOR
       
    }
View Full Code Here

        int num_partitions = this.getServerConfig().getPartitionCount();
        Client client = this.getClient();
        final VoltTable vt = this.loadTable(client);
       
        Database catalog_db = CatalogUtil.getDatabase(this.getCatalog());
        Table catalog_tbl = catalog_db.getTables().get("TABLEC");
        assertNotNull(catalog_tbl);
        Column catalog_col = catalog_tbl.getColumns().get("C_VALUE0");
        assertNotNull(catalog_col);
       
        // Compute the AVG in Java so that we can compare
        Map<Integer, List<Integer>> values = new HashMap<Integer, List<Integer>>();
        vt.resetRowPosition();
View Full Code Here

    protected VoltTable loadTable(Client client) throws IOException, ProcCallException {
        int num_partitions = this.getServerConfig().getPartitionCount();
        int num_tuples = num_partitions * 10;

        Database catalog_db = CatalogUtil.getDatabase(this.getCatalog());
        Table catalog_tbl = catalog_db.getTables().get("TABLEC");
        assertNotNull(catalog_tbl);
       
        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 % 5;
            row[col++] = i % num_partitions;
            for ( ; col < col_cnt; col++) {
                int val = rand.nextInt(100);
                row[col] = val;
            } // FOR
            vt.addRow(row);
        } // FOR
       
        ClientResponse cr = client.callProcedure("@LoadMultipartitionTable", catalog_tbl.getName(), vt);
        assertEquals(Status.OK, cr.getStatus());
       
        return (vt);
    }
View Full Code Here

        catalog_proc.setPartitionparameter(mpp.getIndex());
       
        // First Test: Only partition one of the tables and make sure that
        // the MultiColumns don't map to the same partition
       
        Table catalog_tbl = this.getTable(clone_db, TM1Constants.TABLENAME_SPECIAL_FACILITY);
        Column catalog_cols[] = new Column[] {
            this.getColumn(clone_db, catalog_tbl, "S_ID"),
            this.getColumn(clone_db, catalog_tbl, "SF_TYPE"),
        };
        MultiColumn mc = MultiColumn.get(catalog_cols);
        assertNotNull(mc);
        catalog_tbl.setPartitioncolumn(mc);
        p_estimator.initCatalog(clone_catalogContext);
       
        Statement catalog_stmt = this.getStatement(clone_db, catalog_proc, "GetData");
        Long params[] = new Long[] {
            new Long(1111), // S_ID
            new Long(1111), // S_ID
            new Long(2222), // SF_TYPE
            new Long(3333), // START_TIME
            new Long(4444), // END_TIME
        };
        Map<String, PartitionSet> partitions = p_estimator.getTablePartitions(catalog_stmt, params, base_partition);
        assertNotNull(partitions);
        assertFalse(partitions.isEmpty());
       
        PartitionSet touched = new PartitionSet();
        for (String table_key : partitions.keySet()) {
            assertFalse(table_key, partitions.get(table_key).isEmpty());
            touched.addAll(partitions.get(table_key));
        } // FOR
        assertEquals(2, touched.size());
       
        // Second Test: Now make the other table multi-column partitioned and make
        // sure that the query goes to just one partition
       
        catalog_tbl = this.getTable(clone_db, TM1Constants.TABLENAME_CALL_FORWARDING);
        catalog_cols = new Column[] {
            this.getColumn(clone_db, catalog_tbl, "S_ID"),
            this.getColumn(clone_db, catalog_tbl, "SF_TYPE"),
        };
        mc = MultiColumn.get(catalog_cols);
        assertNotNull(mc);
        catalog_tbl.setPartitioncolumn(mc);
        p_estimator.initCatalog(clone_catalogContext);

        partitions = p_estimator.getTablePartitions(catalog_stmt, params, base_partition);
        assertNotNull(partitions);
        assertFalse(partitions.isEmpty());
View Full Code Here

        assertNotNull(mpp);
        assert(mpp.getIndex() >= 0);
        catalog_proc.setPartitionparameter(mpp.getIndex());
        p_estimator.initCatalog(clone_catalogContext);
       
        Table catalog_tbl = this.getTable(clone_db, TM1Constants.TABLENAME_ACCESS_INFO);
        Column catalog_cols[] = new Column[] {
            this.getColumn(clone_db, catalog_tbl, "S_ID"),
            this.getColumn(clone_db, catalog_tbl, "DATA1"),
        };
        MultiColumn mc = MultiColumn.get(catalog_cols);
        assertNotNull(mc);
        catalog_tbl.setPartitioncolumn(mc);
        p_estimator.initCatalog(clone_catalogContext);
       
        Statement catalog_stmt = this.getStatement(clone_db, catalog_proc, "GetData");
        Long params[] = new Long[] {
            new Long(1111), // S_ID
View Full Code Here

                assert (num_rows > 0);
                assert (num_rows <= TestMarkovLoader.this.current_batchsize);
                assert (TestMarkovLoader.this.total_rows <= TestMarkovLoader.this.current_tablesize);

                // VARCHAR Column checks
                Table catalog_tbl = TestMarkovLoader.this.getTable(tablename);
                table.resetRowPosition();
                while (table.advanceRow()) {
                    int row = table.getActiveRowIndex();
                    for (Column catalog_col : catalog_tbl.getColumns()) {
                        int index = catalog_col.getIndex();
                        VoltType col_type = VoltType.get(catalog_col.getType());
                        switch (col_type) {
                            case TINYINT:
                            case SMALLINT:
View Full Code Here

            // name, then we have
            // to skip this output column
            if (column_name.equalsIgnoreCase("tuple_address") || table_name == null)
                continue;

            Table catalog_tbl = null;
            try {
                catalog_tbl = catalog_db.getTables().get(table_name);
            } catch (Exception ex) {
                LOG.fatal("Failed to retrieve table '" + table_name + "'", ex);
                LOG.fatal(CatalogUtil.debug(catalog_db.getTables()));
                throw new RuntimeException(ex);
            }
            assert (catalog_tbl != null) : "Invalid table '" + table_name + "'";

            Column catalog_col = catalog_tbl.getColumns().get(column_name);
            assert (catalog_col != null) : "Invalid column '" + table_name + "." + column_name;

            columns.add(catalog_col);
        } // FOR
        return (columns);
View Full Code Here

        //
        MemoryEstimator estimator = new MemoryEstimator(stats, hasher);
        for (SiteEntry site : this.sites) {
            long site_size = 0l;
            for (FragmentEntry fragment : site.getFragments()) {
                Table catalog_tbl = fragment.getTable(catalog_db);
                Column partition_col = catalog_tbl.getPartitioncolumn();
                long size = estimator.estimate(catalog_tbl, partition_col, fragment.getHashKey());
                site_size += size;
                fragment.setEstimatedSize(size);
            } // FOR
            site.setEstimatedSize(site_size);
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.Table

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.