Class QueryMatches


  • public class QueryMatches
    extends Object
    INTERNAL: Object used to hold query results during computation.
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryMatches​(Collection columnDefs, QueryContext context)
      INTERNAL: Creates a new matches object with the given column definitions.
      QueryMatches​(QueryMatches matches)
      INTERNAL: Creates a new (empty) matches object with the same column definitions as the QueryMatches object passed in the parameter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(Object[][] newdata, int length)
      EXPERIMENTAL: Adds input array to this table.
      void add​(QueryResultIF extra)
      EXPERIMENTAL: Adds QueryResultIF matches to this table.
      void add​(QueryMatches extra)
      INTERNAL: Adds all the matches in the given table to this table.
      protected void addNonRedundant​(QueryMatches matches)
      INTERNAL: Adds all rows which do not already exist.
      boolean bound​(int colix)
      INTERNAL: Checks whether the variable represented by the indexed column is bound.
      void clear()
      INTERNAL: Empties the table.
      String dump()  
      void ensureCapacity​(int requirement)
      INTERNAL: Ensures that the table has at least the given size.
      Object getColumnDefinition​(int ix)
      INTERNAL: Returns definition of column.
      int getIndex​(Float num)
      INTERNAL: Returns the index of the given float constant in the table.
      int getIndex​(Integer num)
      INTERNAL: Returns the index of the given integer constant in the table.
      int getIndex​(Object argument)
      INTERNAL: Returns the column index of the given object in the table.
      int getIndex​(String str)
      INTERNAL: Returns the index of the given string constant in the table.
      int getIndex​(TMObjectIF constant)
      INTERNAL: Returns the index of the given constant in the table.
      int getIndex​(Variable var)
      INTERNAL: Returns the index of the given variable in the table.
      QueryContext getQueryContext()
      INTERNAL: Returns the query context.
      int[][] getTranslationSpec​(Object[] intarguments, QueryMatches extmatches, Object[] extarguments)
      INTERNAL: Computes the translation specification array, which gives the connection between this and the other match table.
      int getVariableIndex​(String varname)
      INTERNAL: Returns the index of the given variable in the table.
      boolean hasLiteralColumns()
      INTERNAL: Checks whether any of the columns are literal columns representing a literal in the query.
      void increaseCapacity()
      INTERNAL: Used to increase the size of the table when full.
      void insertConstants()
      INTERNAL: Inserts the constant values in the constant columns.
      boolean isEmpty()
      INTERNAL: Returns true if there are no matches.
      QueryMatches merge​(int[] intspec, QueryMatches extmatches, int[] extspec, int[] equalpairs)
      INTERNAL: Merges this match table (from inside a rule) with another match table (from the calling context), producing a new set of matches (corresponding to the result of the rule, as viewed from the outside).
      protected void remove​(QueryMatches matches)
      INTERNAL: Removes the rows which have matching counterparts in the argument.
      QueryMatches removeDuplicates()  
      void translate​(int[] fromCols, QueryMatches toQM, int[] toCols)
      INTERNAL: Translates matches in this table into corresponding matches in the other.
    • Field Detail

      • initialSize

        public static int initialSize
      • last

        public int last
      • size

        public int size
      • data

        public Object[][] data
      • columnDefinitions

        public Object[] columnDefinitions
      • colcount

        public int colcount
    • Constructor Detail

      • QueryMatches

        public QueryMatches​(Collection columnDefs,
                            QueryContext context)
        INTERNAL: Creates a new matches object with the given column definitions.
      • QueryMatches

        public QueryMatches​(QueryMatches matches)
        INTERNAL: Creates a new (empty) matches object with the same column definitions as the QueryMatches object passed in the parameter.
    • Method Detail

      • getVariableIndex

        public int getVariableIndex​(String varname)
        INTERNAL: Returns the index of the given variable in the table.
      • getIndex

        public int getIndex​(TMObjectIF constant)
        INTERNAL: Returns the index of the given constant in the table.
      • getIndex

        public int getIndex​(Variable var)
        INTERNAL: Returns the index of the given variable in the table.
      • getIndex

        public int getIndex​(String str)
        INTERNAL: Returns the index of the given string constant in the table.
      • getIndex

        public int getIndex​(Integer num)
        INTERNAL: Returns the index of the given integer constant in the table.
      • getIndex

        public int getIndex​(Float num)
        INTERNAL: Returns the index of the given float constant in the table.
      • getIndex

        public int getIndex​(Object argument)
        INTERNAL: Returns the column index of the given object in the table.
      • getColumnDefinition

        public Object getColumnDefinition​(int ix)
        INTERNAL: Returns definition of column.
      • increaseCapacity

        public void increaseCapacity()
        INTERNAL: Used to increase the size of the table when full.
      • ensureCapacity

        public void ensureCapacity​(int requirement)
        INTERNAL: Ensures that the table has at least the given size.
      • clear

        public void clear()
        INTERNAL: Empties the table.
      • getQueryContext

        public QueryContext getQueryContext()
        INTERNAL: Returns the query context.
      • hasLiteralColumns

        public boolean hasLiteralColumns()
        INTERNAL: Checks whether any of the columns are literal columns representing a literal in the query.
      • isEmpty

        public boolean isEmpty()
        INTERNAL: Returns true if there are no matches.
      • insertConstants

        public void insertConstants()
        INTERNAL: Inserts the constant values in the constant columns. Uses the information in the column definitions to do this.
      • bound

        public boolean bound​(int colix)
        INTERNAL: Checks whether the variable represented by the indexed column is bound.
      • add

        public void add​(QueryMatches extra)
        INTERNAL: Adds all the matches in the given table to this table. Note that the two tables must have the same layout.
      • add

        public void add​(Object[][] newdata,
                        int length)
        EXPERIMENTAL: Adds input array to this table.
      • add

        public void add​(QueryResultIF extra)
        EXPERIMENTAL: Adds QueryResultIF matches to this table.
      • remove

        protected void remove​(QueryMatches matches)
        INTERNAL: Removes the rows which have matching counterparts in the argument.
      • addNonRedundant

        protected void addNonRedundant​(QueryMatches matches)
        INTERNAL: Adds all rows which do not already exist. Matching ignores nulls in the rows being added.
      • getTranslationSpec

        public int[][] getTranslationSpec​(Object[] intarguments,
                                          QueryMatches extmatches,
                                          Object[] extarguments)
                                   throws InvalidQueryException
        INTERNAL: Computes the translation specification array, which gives the connection between this and the other match table.
        Parameters:
        intarguments - Actual received parameters in rule invocation.
        extarguments - Declared parameters in rule declaration.
        Returns:
        an array of type int[][] that looks like [intspec, extspec], where intspec is the specification for this match and extspec is the specification for the other match.
        Throws:
        InvalidQueryException
      • translate

        public void translate​(int[] fromCols,
                              QueryMatches toQM,
                              int[] toCols)
        INTERNAL: Translates matches in this table into corresponding matches in the other.
      • merge

        public QueryMatches merge​(int[] intspec,
                                  QueryMatches extmatches,
                                  int[] extspec,
                                  int[] equalpairs)
        INTERNAL: Merges this match table (from inside a rule) with another match table (from the calling context), producing a new set of matches (corresponding to the result of the rule, as viewed from the outside).
        Parameters:
        intspec - Mapping from general column no (?) to column no in this QM object.
        extspec - Mapping from general column no (?) to column no in extmatches.
        equalpairs - See RulePredicate.getEqualPairs() for explanation. Numbers are argument numbers.