Beispiel #1
0
  /**
   * Get a list of indexes which can be used for rewrite.
   *
   * @return
   * @throws SemanticException
   */
  private Map<Table, List<Index>> getIndexesForRewrite() throws SemanticException {
    List<String> supportedIndexes = new ArrayList<String>();
    supportedIndexes.add(AggregateIndexHandler.class.getName());

    // query the metastore to know what columns we have indexed
    Collection<Table> topTables = parseContext.getTopToTable().values();
    Map<Table, List<Index>> indexes = new HashMap<Table, List<Index>>();
    for (Table tbl : topTables) {
      List<Index> tblIndexes = IndexUtils.getIndexes(tbl, supportedIndexes);
      if (tblIndexes.size() > 0) {
        indexes.put(tbl, tblIndexes);
      }
    }

    return indexes;
  }
Beispiel #2
0
 /**
  * This method checks if the index is built on all partitions of the base table. If not, then the
  * method returns false as we do not apply optimization for this case.
  *
  * @param tableScan
  * @param indexes
  * @return
  * @throws SemanticException
  */
 private boolean checkIfIndexBuiltOnAllTablePartitions(
     TableScanOperator tableScan, Map<Table, List<Index>> indexes) throws SemanticException {
   // check if we have indexes on all partitions in this table scan
   Set<Partition> queryPartitions;
   try {
     queryPartitions = IndexUtils.checkPartitionsCoveredByIndex(tableScan, parseContext, indexes);
     if (queryPartitions == null) { // partitions not covered
       return false;
     }
   } catch (HiveException e) {
     LOG.error("Fatal Error: problem accessing metastore", e);
     throw new SemanticException(e);
   }
   if (queryPartitions.size() != 0) {
     return true;
   }
   return false;
 }