コード例 #1
0
  /*
   * We are testing one filter against all the partition fields.
   * The filter has the form "fieldA = valueA".
   * The partitions have the form partitionOne=valueOne/partitionTwo=ValueTwo/partitionThree=valueThree
   * 1. For a filter to match one of the partitions, lets say partitionA for example, we need:
   * fieldA = partittionOne and valueA = valueOne. If this condition occurs, we return true.
   * 2. If fieldA does not match any one of the partition fields we also return true, it means we ignore this filter
   * because it is not on a partition field.
   * 3. If fieldA = partittionOne and valueA != valueOne, then we return false.
   */
  private boolean testOneFilter(
      List<HivePartition> partitionFields, Object filter, InputData input) {
    // Let's look first at the filter
    FilterParser.BasicFilter bFilter = (FilterParser.BasicFilter) filter;

    boolean isFilterOperationEqual = (bFilter.getOperation() == FilterParser.Operation.HDOP_EQ);
    if (!isFilterOperationEqual) /* in case this is not an "equality filter" we ignore it here - in partition filtering */ {
      return true;
    }

    int filterColumnIndex = bFilter.getColumn().index();
    String filterValue = bFilter.getConstant().constant().toString();
    ColumnDescriptor filterColumn = input.getColumn(filterColumnIndex);
    String filterColumnName = filterColumn.columnName();

    for (HivePartition partition : partitionFields) {
      if (filterColumnName.equals(partition.name)) {
        /* the filter field matches a partition field, but the values do not match */
        return filterValue.equals(partition.val);
      }
    }

    /* filter field did not match any partition field, so we ignore this filter and hence return true */
    return true;
  }
コード例 #2
0
 private void printOneBasicFilter(Object filter) {
   FilterParser.BasicFilter bFilter = (FilterParser.BasicFilter) filter;
   boolean isOperationEqual = (bFilter.getOperation() == FilterParser.Operation.HDOP_EQ);
   int columnIndex = bFilter.getColumn().index();
   String value = bFilter.getConstant().constant().toString();
   LOG.debug(
       "isOperationEqual: "
           + isOperationEqual
           + " columnIndex: "
           + columnIndex
           + " value: "
           + value);
 }