Class SubsetColumnTable

  • All Implemented Interfaces:
    RootTable, TableDataSource

    public final class SubsetColumnTable
    extends FilterTable
    implements RootTable
    This object is a filter that sits atop a Table object. Its purpose is to only provide a view of the columns that are required. In a Select query we may create a query with only the subset of columns that were originally in the table set. This object allows us to provide an interface to only the columns that the Table is allowed to access.

    This method implements RootTable which means a union operation will not decend further past this table when searching for the roots.

    • Field Detail

      • column_map

        private int[] column_map
        Maps from the column in this table to the column in the parent table. The number of entries of this should match the number of columns in this table.
      • reverse_column_map

        private int[] reverse_column_map
        Maps from the column in the parent table, to the column in this table. The size of this should match the number of columns in the parent table.
      • subset_table_def

        private DataTableDef subset_table_def
        The DataTableDef object that describes the subset column of this table.
      • aliases

        private Variable[] aliases
        The resolved Variable aliases for this subset. These are returned by getResolvedVariable and used in searches for findResolvedVariable. This can be used to remap the variable names used to match the columns.
    • Constructor Detail

      • SubsetColumnTable

        public SubsetColumnTable​(Table parent)
        The Constructor.
    • Method Detail

      • setColumnMap

        public void setColumnMap​(int[] mapping,
                                 Variable[] aliases)
        Adds a column map into this table. The int array contains a map to the column in the parent object that we want the column number to reference. For example, to select columns 4, 8, 1, 2 into this new table, the array would be { 4, 8, 1, 2 }.
      • getColumnCount

        public int getColumnCount()
        Returns the number of columns in the table.
        Overrides:
        getColumnCount in class FilterTable
      • findFieldName

        public int findFieldName​(Variable v)
        Given a fully qualified variable field name, ie. 'APP.CUSTOMER.CUSTOMERID' this will return the column number the field is at. Returns -1 if the field does not exist in the table.
        Overrides:
        findFieldName in class FilterTable
      • getDataTableDef

        public DataTableDef getDataTableDef()
        Returns the DataTableDef object that describes the columns and name of this table. For a SubsetColumnTable object, this returns the columns that were mapped via the 'setColumnMap' method.
        Specified by:
        getDataTableDef in interface TableDataSource
        Overrides:
        getDataTableDef in class FilterTable
      • getResolvedVariable

        public Variable getResolvedVariable​(int column)
        Returns a fully qualified Variable object that represents the name of the column at the given index. For example, new Variable(new TableName("APP", "CUSTOMER"), "ID")
        Overrides:
        getResolvedVariable in class FilterTable
      • setToRowTableDomain

        final void setToRowTableDomain​(int column,
                                       IntegerVector row_set,
                                       TableDataSource ancestor)
        Given a set, this trickles down through the Table hierarchy resolving the given row_set to a form that the given ancestor understands. Say you give the set { 0, 1, 2, 3, 4, 5, 6 }, this function may check down three levels and return a new 7 element set with the rows fully resolved to the given ancestors domain.
        Overrides:
        setToRowTableDomain in class FilterTable
      • getCellContents

        public final TObject getCellContents​(int column,
                                             int row)
        Returns an object that represents the information in the given cell in the table. This will generally be an expensive algorithm, so calls to it should be kept to a minimum. Note that the offset between two rows is not necessarily 1.
        Specified by:
        getCellContents in interface TableDataSource
        Overrides:
        getCellContents in class FilterTable
      • typeEquals

        public boolean typeEquals​(RootTable table)
        This function is used to check that two tables are identical. This is used in operations like 'union' that need to determine that the roots are infact of the same type.
        Specified by:
        typeEquals in interface RootTable
      • toString

        public java.lang.String toString()
        Returns a string that represents this table.
        Overrides:
        toString in class Table