@Override
    public int compare(Partition o1, Partition o2) {
      List<Object[]> orders = MetaStoreUtils.makeOrderSpecs(req.getOrder());
      for (Object[] order : orders) {
        int partKeyIndex = (int) order[0];
        boolean isAsc = "asc".equalsIgnoreCase((String)order[1]);
        String partVal1 = o1.getValues().get(partKeyIndex), partVal2 = o2.getValues().get(partKeyIndex);
        int val = partVal1.compareTo(partVal2);
        if (val == 0) {
          continue;
        } else if (partVal1.equals(req.getDefaultPartitionName())) {
          return isAsc ? 1 : -1;
        } else if (partVal2.equals(req.getDefaultPartitionName())) {
          return isAsc ? -1 : 1;
        } else {
          String type = table.getPartitionKeys().get(partKeyIndex).getType();
          if (org.apache.hadoop.hive.metastore.ColumnType.IntegralTypes.contains(type)) {
            val = (Double.valueOf(partVal1) - Double.valueOf(partVal2)) > 0 ? 1 : -1;
          }
          return isAsc ? val : - val;
        }
      }

      try {
        return Warehouse.makePartName(table.getPartitionKeys(), o1.getValues()).compareTo(
            Warehouse.makePartName(table.getPartitionKeys(), o2.getValues()));
      } catch (MetaException e) {
        throw new RuntimeException(e);
      }
    }
@param partialPvals partition values, can be partial.  This really means that missing values
                   are represented by empty str.
@param maxParts maximum number of partitions to fetch, or -1 for all
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java