Package org.voltdb.catalog

Examples of org.voltdb.catalog.ColumnRef


            // Add the parent ColumnRef to the Constraint
            // The name of the column ref is the name of the column in this
            // table, which then points
            // to the column in the foreign table
            //
            ColumnRef catalog_fkey_col_ref = catalog_const.getForeignkeycols().add(catalog_col.getName());
            catalog_fkey_col_ref.setColumn(catalog_fkey_col);

            //
            // Add the ConstraintRef to the child Column
            //
            ConstraintRef catalog_const_ref = catalog_col.getConstraints().add(catalog_const.getName());
View Full Code Here


                    if (!colRefIter.hasNext()) {
                        retval.sortDirection = SortDirectionType.INVALID;
                        break;
                    }

                    ColumnRef colRef = colRefIter.next();
                    if (colInfo.tableName.equals(table.getTypeName()) &&
                        colInfo.columnName.equals(colRef.getColumn().getTypeName()) &&
                        colInfo.ascending == ascending) {

                        if (ascending)
                            retval.sortDirection = SortDirectionType.ASC;
                        else
                            retval.sortDirection = SortDirectionType.DESC;

                        retval.use = IndexUseType.INDEX_SCAN;
                    } else {
                        retval.sortDirection = SortDirectionType.INVALID;
                        break;
                    }
                }
            }
        }

        // cover as much of the index as possible with expressions that use
        // index columns
        for (ColumnRef colRef : CatalogUtil.getSortedCatalogItems(index.getColumns(), "index")) {
            Column col = colRef.getColumn();
            if (eqColumns.containsKey(col) && (eqColumns.get(col).size() >= 0)) {
                AbstractExpression expr = eqColumns.get(col).remove(0);
                retval.indexExprs.add(expr);
                retval.endExprs.add(expr);
            } else {
View Full Code Here

                    dest_cons.setForeignkeytable(dest_fkey_tbl);
                    for (ColumnRef src_cref : ((Constraint) src_item).getForeignkeycols()) {
                        CatalogCloner.clone(src_cref, dest_catalog);

                        // Correct what it's pointing to
                        ColumnRef dest_colref = dest_cons.getForeignkeycols().get(src_cref.getName());
                        assert (dest_colref != null);
                        dest_colref.setColumn(dest_fkey_tbl.getColumns().get(src_cref.getColumn().getName()));
                    } // FOR
                }
            }

            // Important: We have to add ConstraintRefs to Columns *after* we add the columns
View Full Code Here

        for (ColumnRef src_colref : src_refs) {
            // First clone it
            CatalogCloner.clone(src_colref, dest_tbl.getCatalog());

            // Correct what it's pointing to
            ColumnRef dest_colref = dest_refs.get(src_colref.getName());
            dest_colref.setColumn(dest_tbl.getColumns().get(src_colref.getColumn().getName()));
        } // FOR
    }
View Full Code Here

                // need to set other index data here (column, etc)
                for (int i = 0, cnt = index.getColumns().size(); i < cnt; i++) {
                    Column catalog_col = index.getColumns().get(i);
                    Column new_catalog_col = new_catalog_tbl.getColumns().get(catalog_col.getName());
                    ColumnRef cref = new_catalog_index.getColumns().add(new_catalog_col.getName());
                    cref.setColumn(new_catalog_col);
                    cref.setIndex(i);
                } // FOR
            } // FOR
        } // FOR

        //
View Full Code Here

                    System.err.println(CatalogUtil.getDisplayName(ref0) + " <-> " + CatalogUtil.getDisplayName(ref1));
                this.checkFields(Table.class, ref0.getTable(), ref1.getTable());
            }
            // ColumnRefs
            else if (field_val0 instanceof ColumnRef) {
                ColumnRef ref0 = (ColumnRef) field_val0;
                ColumnRef ref1 = (ColumnRef) field_val1;
                if (debug)
                    System.err.println(CatalogUtil.getDisplayName(ref0) + " <-> " + CatalogUtil.getDisplayName(ref1));
                this.checkFields(Column.class, ref0.getColumn(), ref1.getColumn());
            }
            // CatalogMap
            else if (field_val0 != null && ClassUtil.getSuperClasses(field_val0.getClass()).contains(CatalogType.class)) {
                CatalogType type0 = (CatalogType) field_val0;
                CatalogType type1 = (CatalogType) field_val1;
View Full Code Here

        else
                index.setType(IndexType.HASH_TABLE.getValue());

        // need to set other index data here (column, etc)
        for (int i = 0; i < columns.length; i++) {
            ColumnRef cref = index.getColumns().add(columns[i].getTypeName());
            cref.setColumn(columns[i]);
            cref.setIndex(i);
        }

        String msg = "Created index: " + name + " on table: " +
                     table.getTypeName() + " of type: " + IndexType.get(index.getType()).name();
View Full Code Here

                    String to_colname = attrs.getNamedItem("to").getNodeValue();
                    Column to_col = catalog_fkey_tbl.getColumns().get(to_colname);

                    // Make a reference in the fromcolumn to their column in the constraint
                    // We store the name of from_olumn as the name of the reference in the catalog
                    ColumnRef cref = catalog_const.getForeignkeycols().add(from_col.getTypeName());
                    cref.setColumn(to_col);

                    // Add a ConstraintRef for the from_column
                    ConstraintRef const_ref = from_col.getConstraints().add(catalog_const.getTypeName());
                    const_ref.setConstraint(catalog_const);
                }
View Full Code Here

            // add the group by columns from the src table
            for (int i = 0; i < stmt.groupByColumns.size(); i++) {
                ParsedSelectStmt.ParsedColInfo gbcol = stmt.groupByColumns.get(i);
                Column srcCol = srcColumnArray.get(gbcol.index);
                ColumnRef cref = matviewinfo.getGroupbycols().add(srcCol.getTypeName());
                // groupByColumns is iterating in order of groups. Store that grouping order
                // in the column ref index. When the catalog is serialized, it will, naturally,
                // scramble this order like a two year playing dominos, presenting the data
                // in a meaningless sequence.
                cref.setIndex(i);           // the column offset in the view's grouping order
                cref.setColumn(srcCol);     // the source column from the base (non-view) table
            }

            ParsedSelectStmt.ParsedColInfo countCol = stmt.displayColumns.get(stmt.groupByColumns.size());
            assert(countCol.expression.getExpressionType() == ExpressionType.AGGREGATE_COUNT);
            assert(countCol.expression.getLeft() == null);
            processMaterializedViewColumn(matviewinfo, srcTable, destTable, destColumnArray.get(stmt.groupByColumns.size()),
                    ExpressionType.AGGREGATE_COUNT, null);

            // create an index and constraint for the table
            Index pkIndex = destTable.getIndexes().add("MATVIEW_PK_INDEX");
            pkIndex.setType(IndexType.BALANCED_TREE.getValue());
            pkIndex.setUnique(true);
            // add the group by columns from the src table
            // assume index 1 throuh #grpByCols + 1 are the cols
            for (int i = 0; i < stmt.groupByColumns.size(); i++) {
                ColumnRef c = pkIndex.getColumns().add(String.valueOf(i));
                c.setColumn(destColumnArray.get(i));
                c.setIndex(i);
                if (LOG.isDebugEnabled())
                    LOG.debug(String.format("VIEW:%s Group By Columns %02d: %s",
                            destTable.getName(), i, c.getColumn().fullName()));
            }
            Constraint pkConstraint = destTable.getConstraints().add("MATVIEW_PK_CONSTRAINT");
            pkConstraint.setType(ConstraintType.PRIMARY_KEY.getValue());
            pkConstraint.setIndex(pkIndex);
View Full Code Here

        int i = 0;
        assert(catalog_cols != null);
        assert(catalog_cols.isEmpty() == false) : "No vertical partitioning columns for " + catalog_view.fullName();
        for (Column catalog_col : catalog_cols) {
            // MaterializedView ColumnRef
            ColumnRef catalog_ref = catalog_view.getGroupbycols().add(catalog_col.getName());
            catalog_ref.setColumn(catalog_col);
            catalog_ref.setIndex(i++);
           
            // VirtualTable Column
            Column virtual_col = virtual_tbl.getColumns().add(catalog_col.getName());
            virtual_col.setDefaulttype(catalog_col.getDefaulttype());
            virtual_col.setDefaultvalue(catalog_col.getDefaultvalue());
            virtual_col.setIndex(catalog_col.getIndex());
            virtual_col.setNullable(catalog_col.getNullable());
            virtual_col.setSize(catalog_col.getSize());
            virtual_col.setType(catalog_col.getType());
            if (debug.val)
                LOG.debug(String.format("Added VerticalPartition column %s", virtual_col.fullName()));
           
            // If they want an index, then we'll make one based on every column except for the column
            // that the table is partitioned on
            if (createIndex) {
                boolean include = true;
                if (partition_col instanceof MultiColumn) {
                    include = (((MultiColumn)partition_col).contains(catalog_col) == false);
                }
                else if (catalog_col.equals(partition_col)) {
                    if (debug.val)
                        LOG.debug("VerticalParition -> " + catalog_col.fullName() + " = " + partition_col.fullName());
                    include = false;
                }
                if (include) indexColumns.add(virtual_col);
            }
        } // FOR
       
        if (createIndex) {
            if (indexColumns.isEmpty()) {
                Map<String, Object> m = new LinkedHashMap<String, Object>();
                m.put("Partition Column", partition_col.fullName());
                m.put("VP Table Columns", virtual_tbl.getColumns());
                m.put("Passed-in Columns", CatalogUtil.debug(catalog_cols));
                LOG.error(String.format("Failed to find index columns for table '%s'\n%s",
                                        catalog_tbl.getName(), StringUtil.formatMaps(m)));
                throw new Exception(String.format("No columns selected for index on %s", viewName));
            }
            String idxName = "SYS_IDX_" + viewName;
            Index virtual_idx = virtual_tbl.getIndexes().get(idxName);
            if (virtual_idx == null) {
                virtual_idx = virtual_tbl.getIndexes().add(idxName);
            }
            virtual_idx.getColumns().clear();
           
            IndexType idxType = (indexColumns.size() == 1 ? IndexType.HASH_TABLE : IndexType.BALANCED_TREE);
            virtual_idx.setType(idxType.getValue());
            i = 0;
            for (Column catalog_col : indexColumns) {
                ColumnRef cref = virtual_idx.getColumns().add(catalog_col.getTypeName());
                cref.setColumn(catalog_col);
                cref.setIndex(i++);
            } // FOR
           
            if (debug.val)
                LOG.debug(String.format("Created %s index '%s' for vertical partition '%s'",
                                        idxType, idxName, viewName));
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.ColumnRef

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.