Beispiel #1
0
  static void deserializeComparators(Configuration conf, TupleMRConfig mrConfig)
      throws TupleMRException {
    String[] comparatorRefs = conf.getStrings(CONF_COMPARATOR_REFERENCES);
    String[] comparatorInstanceFiles = conf.getStrings(CONF_COMPARATOR_INSTANCES);

    if (comparatorRefs == null) {
      return;
    }
    try {
      for (int i = 0; i < comparatorRefs.length; i++) {
        String[] ref = comparatorRefs[i].split("\\|");
        String instanceFile = comparatorInstanceFiles[i];

        // Here we use "false" as last parameter because otherwise it could be
        // an infinite loop. We will call setConf() later.
        RawComparator<?> comparator =
            InstancesDistributor.loadInstance(conf, RawComparator.class, instanceFile, false);

        if (ref[0].equals(COMMON)) {
          setComparator(mrConfig.getCommonCriteria(), ref[1], comparator);
        } else {
          setComparator(
              mrConfig.getSpecificOrderBys().get(new Integer(ref[0])), ref[1], comparator);
        }
      }
    } catch (IOException e) {
      throw new TupleMRException(e);
    }
  }