org.apache.tez.runtime.library.common.ConfigUtils Java Examples

The following examples show how to use org.apache.tez.runtime.library.common.ConfigUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestConfigTranslationMRToTez.java    From incubator-tez with Apache License 2.0 6 votes vote down vote up
@Test
// Tests derived keys - i.e. the actual key is not set, but the value is 
// derived from a fallback key.
public void testComplexKeys() {

  JobConf confVertex1 = new JobConf();
  
  confVertex1.set(MRJobConfig.MAP_OUTPUT_KEY_CLASS, IntWritable.class.getName());
  
  confVertex1.unset(MRJobConfig.KEY_COMPARATOR);
  confVertex1.unset(MRJobConfig.GROUP_COMPARATOR_CLASS);
  
  MRHelpers.translateVertexConfToTez(confVertex1);

  assertEquals(IntWritable.Comparator.class.getName(), ConfigUtils
      .getIntermediateOutputKeyComparator(confVertex1).getClass().getName());
  assertEquals(IntWritable.Comparator.class.getName(), ConfigUtils
      .getIntermediateInputKeyComparator(confVertex1).getClass().getName());
}
 
Example #2
Source File: OrderedGroupedKVInputConfig.java    From tez with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Builder setAdditionalConfiguration(String key, String value) {
  Objects.requireNonNull(key, "Key cannot be null");
  if (ConfigUtils.doesKeyQualify(key,
      Lists.newArrayList(OrderedGroupedKVInput.getConfigurationKeySet(),
          TezRuntimeConfiguration.getRuntimeAdditionalConfigKeySet()),
      TezRuntimeConfiguration.getAllowedPrefixes())) {
    if (value == null) {
      this.conf.unset(key);
    } else {
      this.conf.set(key, value);
    }
  }
  return this;
}
 
Example #3
Source File: UnorderedPartitionedKVOutputConfig.java    From tez with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Builder setAdditionalConfiguration(String key, String value) {
  Objects.requireNonNull(key, "Key cannot be null");
  if (ConfigUtils.doesKeyQualify(key,
      Lists.newArrayList(UnorderedPartitionedKVOutput.getConfigurationKeySet(),
          TezRuntimeConfiguration.getRuntimeAdditionalConfigKeySet()),
      TezRuntimeConfiguration.getAllowedPrefixes())) {
    if (value == null) {
      this.conf.unset(key);
    } else {
      this.conf.set(key, value);
    }
  }
  return this;
}
 
Example #4
Source File: OrderedPartitionedKVOutputConfig.java    From tez with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Builder setAdditionalConfiguration(String key, String value) {
  Objects.requireNonNull(key, "Key cannot be null");
  if (ConfigUtils.doesKeyQualify(key,
      Lists.newArrayList(OrderedPartitionedKVOutput.getConfigurationKeySet(),
          TezRuntimeConfiguration.getRuntimeAdditionalConfigKeySet()),
      TezRuntimeConfiguration.getAllowedPrefixes())) {
    if (value == null) {
      this.conf.unset(key);
    } else {
      this.conf.set(key, value);
    }
  }
  return this;
}
 
Example #5
Source File: TestConfigTranslationMRToTez.java    From tez with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 5000)
// Tests derived keys - i.e. the actual key is not set, but the value is 
// derived from a fallback key.
public void testComplexKeys() {

  JobConf confVertex1 = new JobConf();
  
  confVertex1.set(MRJobConfig.MAP_OUTPUT_KEY_CLASS, IntWritable.class.getName());
  
  confVertex1.unset(MRJobConfig.KEY_COMPARATOR);
  confVertex1.unset(MRJobConfig.GROUP_COMPARATOR_CLASS);
  
  MRHelpers.translateMRConfToTez(confVertex1);

  assertEquals(IntWritable.Comparator.class.getName(), ConfigUtils
      .getIntermediateOutputKeyComparator(confVertex1).getClass().getName());
  assertEquals(IntWritable.Comparator.class.getName(), ConfigUtils
      .getIntermediateInputKeyComparator(confVertex1).getClass().getName());
}
 
Example #6
Source File: OrderedGroupedKVInputConfig.java    From tez with Apache License 2.0 6 votes vote down vote up
/**
 * Set serialization class and the relevant comparator to be used for sorting.
 * Providing custom serialization class could change the way, keys needs to be compared in
 * sorting. Providing invalid comparator here could create invalid results.
 *
 * @param serializationClassName
 * @param comparatorClassName
 * @param serializerConf         the serializer configuration. This can be null, and is a
 *                               {@link java.util.Map} of key-value pairs. The keys should be limited
 *                               to the ones required by the comparator.
 * @return this object for further chained method calls
 */
public Builder setKeySerializationClass(String serializationClassName,
    String comparatorClassName, @Nullable Map<String, String> serializerConf) {
  Preconditions.checkArgument(serializationClassName != null,
      "serializationClassName cannot be null");
  Preconditions.checkArgument(comparatorClassName != null,
      "comparator cannot be null");
  this.conf.set(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY, serializationClassName + ","
      + conf.get(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY));
  setKeyComparatorClass(comparatorClassName, null);
  if (serializerConf != null) {
    // Merging the confs for now. Change to be specific in the future.
    ConfigUtils.mergeConfsWithExclusions(this.conf, serializerConf,
        TezRuntimeConfiguration.getRuntimeConfigKeySet());
  }
  return this;
}
 
Example #7
Source File: ShuffledUnorderedKVReader.java    From incubator-tez with Apache License 2.0 6 votes vote down vote up
public ShuffledUnorderedKVReader(ShuffleManager shuffleManager, Configuration conf,
    CompressionCodec codec, boolean ifileReadAhead, int ifileReadAheadLength, int ifileBufferSize,
    TezCounter inputRecordCounter)
    throws IOException {
  this.shuffleManager = shuffleManager;

  this.codec = codec;
  this.ifileReadAhead = ifileReadAhead;
  this.ifileReadAheadLength = ifileReadAheadLength;
  this.ifileBufferSize = ifileBufferSize;
  this.inputRecordCounter = inputRecordCounter;

  this.keyClass = ConfigUtils.getIntermediateInputKeyClass(conf);
  this.valClass = ConfigUtils.getIntermediateInputValueClass(conf);

  this.keyIn = new DataInputBuffer();
  this.valIn = new DataInputBuffer();

  SerializationFactory serializationFactory = new SerializationFactory(conf);

  this.keyDeserializer = serializationFactory.getDeserializer(keyClass);
  this.keyDeserializer.open(keyIn);
  this.valDeserializer = serializationFactory.getDeserializer(valClass);
  this.valDeserializer.open(valIn);
}
 
Example #8
Source File: UnorderedKVOutputConfig.java    From tez with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Builder setAdditionalConfiguration(String key, String value) {
  Objects.requireNonNull(key, "Key cannot be null");
  if (ConfigUtils.doesKeyQualify(key,
      Lists.newArrayList(UnorderedKVOutput.getConfigurationKeySet(),
          TezRuntimeConfiguration.getRuntimeAdditionalConfigKeySet()),
      TezRuntimeConfiguration.getAllowedPrefixes())) {
    if (value == null) {
      this.conf.unset(key);
    } else {
      this.conf.set(key, value);
    }
  }
  return this;
}
 
Example #9
Source File: TestConfigTranslationMRToTez.java    From tez with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 5000)
public void testMRToTezKeyTranslation() {
  JobConf confVertex1 = new JobConf();
  confVertex1.set(MRJobConfig.MAP_OUTPUT_KEY_CLASS,
      IntWritable.class.getName());
  confVertex1.set(MRJobConfig.MAP_OUTPUT_VALUE_CLASS,
      LongWritable.class.getName());
  confVertex1.setBoolean(MRJobConfig.MAP_OUTPUT_COMPRESS, true);

  MRHelpers.translateMRConfToTez(confVertex1);

  // Verify translation
  assertEquals(IntWritable.class.getName(), ConfigUtils
      .getIntermediateOutputKeyClass(confVertex1).getName());
  assertEquals(LongWritable.class.getName(), ConfigUtils
      .getIntermediateOutputValueClass(confVertex1).getName());
  assertEquals(IntWritable.class.getName(), ConfigUtils
      .getIntermediateInputKeyClass(confVertex1).getName());
  assertEquals(LongWritable.class.getName(), ConfigUtils
      .getIntermediateInputValueClass(confVertex1).getName());
  assertTrue(ConfigUtils.shouldCompressIntermediateOutput(confVertex1));
  assertTrue(ConfigUtils.isIntermediateInputCompressed(confVertex1));
}
 
Example #10
Source File: UnorderedKVReader.java    From tez with Apache License 2.0 6 votes vote down vote up
public UnorderedKVReader(ShuffleManager shuffleManager, Configuration conf,
    CompressionCodec codec, boolean ifileReadAhead, int ifileReadAheadLength, int ifileBufferSize,
    TezCounter inputRecordCounter, InputContext context)
    throws IOException {
  this.shuffleManager = shuffleManager;
  this.context = context;
  this.codec = codec;
  this.ifileReadAhead = ifileReadAhead;
  this.ifileReadAheadLength = ifileReadAheadLength;
  this.ifileBufferSize = ifileBufferSize;
  this.inputRecordCounter = inputRecordCounter;

  this.keyClass = ConfigUtils.getIntermediateInputKeyClass(conf);
  this.valClass = ConfigUtils.getIntermediateInputValueClass(conf);

  this.keyIn = new DataInputBuffer();
  this.valIn = new DataInputBuffer();

  SerializationFactory serializationFactory = new SerializationFactory(conf);

  this.keyDeserializer = serializationFactory.getDeserializer(keyClass);
  this.keyDeserializer.open(keyIn);
  this.valDeserializer = serializationFactory.getDeserializer(valClass);
  this.valDeserializer.open(valIn);
}
 
Example #11
Source File: OrderedGroupedKVInput.java    From tez with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
protected synchronized void createValuesIterator()
    throws IOException {
  // Not used by ReduceProcessor
  RawComparator rawComparator = ConfigUtils.getIntermediateInputKeyComparator(conf);
  Class<?> keyClass = ConfigUtils.getIntermediateInputKeyClass(conf);
  Class<?> valClass = ConfigUtils.getIntermediateInputValueClass(conf);
  LOG.info(getContext().getSourceVertexName() + ": " + "creating ValuesIterator with "
      + "comparator=" + rawComparator.getClass().getName()
      + ", keyClass=" + keyClass.getName()
      + ", valClass=" + valClass.getName());

  vIter = new ValuesIterator(rawIter, rawComparator, keyClass, valClass,
      conf, inputKeyCounter, inputValueCounter);

}
 
Example #12
Source File: TestConfigTranslationMRToTez.java    From incubator-tez with Apache License 2.0 6 votes vote down vote up
@Test
public void testMRToTezKeyTranslation() {
  JobConf confVertex1 = new JobConf();
  confVertex1.set(MRJobConfig.MAP_OUTPUT_KEY_CLASS,
      IntWritable.class.getName());
  confVertex1.set(MRJobConfig.MAP_OUTPUT_VALUE_CLASS,
      LongWritable.class.getName());
  confVertex1.setBoolean(MRJobConfig.MAP_OUTPUT_COMPRESS, true);

  MRHelpers.translateVertexConfToTez(confVertex1);

  // Verify translation
  assertEquals(IntWritable.class.getName(), ConfigUtils
      .getIntermediateOutputKeyClass(confVertex1).getName());
  assertEquals(LongWritable.class.getName(), ConfigUtils
      .getIntermediateOutputValueClass(confVertex1).getName());
  assertEquals(IntWritable.class.getName(), ConfigUtils
      .getIntermediateInputKeyClass(confVertex1).getName());
  assertEquals(LongWritable.class.getName(), ConfigUtils
      .getIntermediateInputValueClass(confVertex1).getName());
  assertTrue(ConfigUtils.shouldCompressIntermediateOutput(confVertex1));
  assertTrue(ConfigUtils.isIntermediateInputCompressed(confVertex1));
}
 
Example #13
Source File: UnorderedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
/**
 * Set serialization class responsible for providing serializer/deserializer for values.
 *
 * @param serializationClassName
 * @param serializerConf         the serializer configuration. This can be null, and is a
 *                               {@link java.util.Map} of key-value pairs. The keys should be limited
 *                               to the ones required by the comparator.
 * @return this object for further chained method calls
 */
public Builder setValueSerializationClass(String serializationClassName,
                                          @Nullable Map<String, String> serializerConf) {
  Preconditions.checkArgument(serializationClassName != null,
      "serializationClassName cannot be null");
  this.conf.set(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY, serializationClassName + ","
      + conf.get(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY));
  if (serializerConf != null) {
    // Merging the confs for now. Change to be specific in the future.
    ConfigUtils.mergeConfsWithExclusions(this.conf, serializerConf,
        TezRuntimeConfiguration.getRuntimeConfigKeySet());
  }
  return this;
}
 
Example #14
Source File: WeightedRangePartitionerTez.java    From spork with Apache License 2.0 5 votes vote down vote up
@Override
public void init() {
    Map<String, Object> quantileMap = null;
    if (PigProcessor.sampleMap != null) {
        // We've collected sampleMap in PigProcessor
        quantileMap = PigProcessor.sampleMap;
    } else {
        LOG.warn("Quantiles map is empty");
        inited = true;
        return;
    }

    long start = System.currentTimeMillis();
    try {
        DataBag quantilesList = (DataBag) quantileMap.get(FindQuantiles.QUANTILES_LIST);
        InternalMap weightedPartsData = (InternalMap) quantileMap.get(FindQuantiles.WEIGHTED_PARTS);
        estimatedNumPartitions = (Integer)quantileMap.get(PigProcessor.ESTIMATED_NUM_PARALLELISM);
        convertToArray(quantilesList);
        for (Entry<Object, Object> ent : weightedPartsData.entrySet()) {
            Tuple key = (Tuple) ent.getKey(); // sample item which repeats
            float[] probVec = getProbVec((Tuple) ent.getValue());
            weightedParts.put(getPigNullableWritable(key),
                    new DiscreteProbabilitySampleGenerator(probVec));
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    comparator = ConfigUtils.getIntermediateInputKeyComparator(job);
    LOG.info("Initialized WeightedRangePartitionerTez. Time taken: " + (System.currentTimeMillis() - start));
    inited = true;
}
 
Example #15
Source File: UnorderedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Builder setFromConfiguration(Configuration conf) {
  // Maybe ensure this is the first call ? Otherwise this can end up overriding other parameters
  Preconditions.checkArgument(conf != null, "Configuration cannot be null");
  Map<String, String> map = ConfigUtils.extractConfigurationMap(conf,
      Lists.newArrayList(UnorderedKVOutput.getConfigurationKeySet(),
          TezRuntimeConfiguration.getRuntimeAdditionalConfigKeySet()), TezRuntimeConfiguration.getAllowedPrefixes());
  ConfigUtils.addConfigMapToConfiguration(this.conf, map);
  return this;
}
 
Example #16
Source File: OrderedGroupedKVInputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
/**
 * Set the key comparator class and it's associated configuration. This method should only be
 * used if the comparator requires some specific configuration, which is typically not the
 * case. {@link #setKeyComparatorClass(String)} is the preferred method for setting a
 * comparator.
 *
 * @param comparatorClassName the key comparator class name
 * @param comparatorConf      the comparator configuration. This can be null, and is a {@link
 *                            java.util.Map} of key-value pairs. The keys should be limited to
 *                            the ones required by the comparator.
 * @return instance of the current builder
 */
public Builder setKeyComparatorClass(String comparatorClassName,
                                     @Nullable Map<String, String> comparatorConf) {
  Objects.requireNonNull(comparatorClassName, "Comparator class name cannot be null");
  this.conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_KEY_COMPARATOR_CLASS,
      comparatorClassName);
  if (comparatorConf != null) {
    // Merging the confs for now. Change to be specific in the future.
    ConfigUtils.mergeConfsWithExclusions(this.conf, comparatorConf,
        TezRuntimeConfiguration.getRuntimeConfigKeySet());
  }
  return this;
}
 
Example #17
Source File: UnorderedKVInputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Builder setFromConfiguration(Configuration conf) {
  // Maybe ensure this is the first call ? Otherwise this can end up overriding other parameters
  Preconditions.checkArgument(conf != null, "Configuration cannot be null");
  Map<String, String> map = ConfigUtils.extractConfigurationMap(conf,
      Lists.newArrayList(UnorderedKVInput.getConfigurationKeySet(),
          TezRuntimeConfiguration.getRuntimeAdditionalConfigKeySet()), TezRuntimeConfiguration.getAllowedPrefixes());
  ConfigUtils.addConfigMapToConfiguration(this.conf, map);
  return this;
}
 
Example #18
Source File: UnorderedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
@InterfaceAudience.Private
Builder() {
  Map<String, String> tezDefaults = ConfigUtils
      .extractConfigurationMap(TezRuntimeConfiguration.getTezRuntimeConfigDefaults(),
          UnorderedKVOutput.getConfigurationKeySet());
  ConfigUtils.addConfigMapToConfiguration(this.conf, tezDefaults);
  ConfigUtils.addConfigMapToConfiguration(this.conf, TezRuntimeConfiguration.getOtherConfigDefaults());
}
 
Example #19
Source File: OrderedGroupedKVInputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
/**
 * Serialization class to be used for serializing values.
 *
 * @param serializationClassName
 * @param serializerConf         the serializer configuration. This can be null, and is a
 *                               {@link java.util.Map} of key-value pairs. The keys should be limited
 *                               to the ones required by the comparator.
 * @return this object for further chained method calls
 */
public Builder setValueSerializationClass(String serializationClassName,
                                          @Nullable Map<String, String> serializerConf) {
  Preconditions.checkArgument(serializationClassName != null,
      "serializationClassName cannot be null");
  this.conf.set(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY, serializationClassName + ","
      + conf.get(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY));
  if (serializerConf != null) {
    // Merging the confs for now. Change to be specific in the future.
    ConfigUtils.mergeConfsWithExclusions(this.conf, serializerConf,
        TezRuntimeConfiguration.getRuntimeConfigKeySet());
  }
  return this;
}
 
Example #20
Source File: UnorderedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Builder setFromConfigurationUnfiltered(Configuration conf) {
  // Maybe ensure this is the first call ? Otherwise this can end up overriding other parameters
  Preconditions.checkArgument(conf != null, "Configuration cannot be null");
  ConfigUtils.mergeConfs(this.conf, conf);
  return this;
}
 
Example #21
Source File: UnorderedPartitionedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
public Builder setCompression(boolean enabled, @Nullable String compressionCodec,
                              @Nullable Map<String, String> codecConf) {
  this.conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS, enabled);
  if (enabled && compressionCodec != null) {
    this.conf
        .set(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, compressionCodec);
  }
  if (codecConf != null) {
    // Merging the confs for now. Change to be specific in the future.
    ConfigUtils.mergeConfsWithExclusions(this.conf, codecConf,
        TezRuntimeConfiguration.getRuntimeConfigKeySet());
  }
  return this;
}
 
Example #22
Source File: OrderedPartitionedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
public Builder setCompression(boolean enabled, @Nullable String compressionCodec,
                              @Nullable Map<String, String> codecConf) {
  this.conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS, enabled);
  if (enabled && compressionCodec != null) {
    this.conf
        .set(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, compressionCodec);
  }
  if (codecConf != null) {
    // Merging the confs for now. Change to be specific in the future.
    ConfigUtils.mergeConfsWithExclusions(this.conf, codecConf,
        TezRuntimeConfiguration.getRuntimeConfigKeySet());
  }
  return this;
}
 
Example #23
Source File: OrderedPartitionedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
/**
 * Set the key comparator class and it's associated configuration. This method should only be
 * used if the comparator requires some specific configuration, which is typically not the
 * case. {@link #setKeyComparatorClass(String)} is the preferred method for setting a
 * comparator.
 *
 * @param comparatorClassName the key comparator class name
 * @param comparatorConf      the comparator configuration. This can be null, and is a {@link
 *                            java.util.Map} of key-value pairs. The keys should be limited to
 *                            the ones required by the comparator.
 * @return instance of the current builder
 */
public Builder setKeyComparatorClass(String comparatorClassName,
                                     @Nullable Map<String, String> comparatorConf) {
  Objects.requireNonNull(comparatorClassName, "Comparator class name cannot be null");
  this.conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_KEY_COMPARATOR_CLASS,
      comparatorClassName);
  if (comparatorConf != null) {
    // Merging the confs for now. Change to be specific in the future.
    ConfigUtils.mergeConfsWithExclusions(this.conf, comparatorConf,
        TezRuntimeConfiguration.getRuntimeConfigKeySet());
  }
  return this;
}
 
Example #24
Source File: OrderedPartitionedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Builder setFromConfigurationUnfiltered(Configuration conf) {
  // Maybe ensure this is the first call ? Otherwise this can end up overriding other parameters
  Preconditions.checkArgument(conf != null, "Configuration cannot be null");
  ConfigUtils.mergeConfs(this.conf, conf);
  return this;
}
 
Example #25
Source File: OrderedPartitionedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Builder setFromConfiguration(Configuration conf) {
  // Maybe ensure this is the first call ? Otherwise this can end up overriding other parameters
  Preconditions.checkArgument(conf != null, "Configuration cannot be null");
  Map<String, String> map = ConfigUtils.extractConfigurationMap(conf,
      Lists.newArrayList(OrderedPartitionedKVOutput.getConfigurationKeySet(),
          TezRuntimeConfiguration.getRuntimeAdditionalConfigKeySet()), TezRuntimeConfiguration.getAllowedPrefixes());
  ConfigUtils.addConfigMapToConfiguration(this.conf, map);
  return this;
}
 
Example #26
Source File: OrderedPartitionedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Builder setAdditionalConfiguration(Map<String, String> confMap) {
  Objects.requireNonNull(confMap, "ConfMap cannot be null");
  Map<String, String> map = ConfigUtils.extractConfigurationMap(confMap,
      Lists.newArrayList(OrderedPartitionedKVOutput.getConfigurationKeySet(),
          TezRuntimeConfiguration.getRuntimeAdditionalConfigKeySet()), TezRuntimeConfiguration.getAllowedPrefixes());
  ConfigUtils.addConfigMapToConfiguration(this.conf, map);
  return this;
}
 
Example #27
Source File: UnorderedPartitionedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
/**
 * Set serialization class responsible for providing serializer/deserializer for values.
 *
 * @param serializationClassName
 * @param serializerConf         the serializer configuration. This can be null, and is a
 *                               {@link java.util.Map} of key-value pairs. The keys should be limited
 *                               to the ones required by the comparator.
 * @return this object for further chained method calls
 */
public Builder setValueSerializationClass(String serializationClassName,
                                          @Nullable Map<String, String> serializerConf) {
  Preconditions.checkArgument(serializationClassName != null,
      "serializationClassName cannot be null");
  this.conf.set(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY, serializationClassName + ","
      + conf.get(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY));
  if (serializerConf != null) {
    // Merging the confs for now. Change to be specific in the future.
    ConfigUtils.mergeConfsWithExclusions(this.conf, serializerConf,
        TezRuntimeConfiguration.getRuntimeConfigKeySet());
  }
  return this;
}
 
Example #28
Source File: OrderedPartitionedKVOutputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
@InterfaceAudience.Private
Builder setPartitioner(String partitionerClassName, @Nullable Map<String, String> partitionerConf) {
  Objects.requireNonNull(partitionerClassName, "Partitioner class name cannot be null");
  this.conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_PARTITIONER_CLASS, partitionerClassName);
  if (partitionerConf != null) {
    // Merging the confs for now. Change to be specific in the future.
    ConfigUtils.mergeConfsWithExclusions(this.conf, partitionerConf,
        TezRuntimeConfiguration.getRuntimeConfigKeySet());
  }
  return this;
}
 
Example #29
Source File: MRCombiner.java    From tez with Apache License 2.0 5 votes vote down vote up
public MRCombiner(TaskContext taskContext) throws IOException {
  final Configuration userConf = TezUtils.createConfFromUserPayload(taskContext.getUserPayload());
  useNewApi = ConfigUtils.useNewApi(userConf);
  if (useNewApi) {
    conf = new JobConf(userConf);
  } else {
    conf = userConf;
  }

  assert(taskContext instanceof InputContext || taskContext instanceof OutputContext);
  if (taskContext instanceof OutputContext) {
    this.keyClass = ConfigUtils.getIntermediateOutputKeyClass(conf);
    this.valClass = ConfigUtils.getIntermediateOutputValueClass(conf);
    this.comparator = ConfigUtils.getIntermediateOutputKeyComparator(conf);
    this.reporter = new MRTaskReporter((OutputContext)taskContext);
  } else {
    this.keyClass = ConfigUtils.getIntermediateInputKeyClass(conf);
    this.valClass = ConfigUtils.getIntermediateInputValueClass(conf);
    this.comparator = ConfigUtils.getIntermediateInputKeyComparator(conf);
    this.reporter = new MRTaskReporter((InputContext)taskContext);
  }

  combineInputRecordsCounter = taskContext.getCounters().findCounter(TaskCounter.COMBINE_INPUT_RECORDS);
  combineOutputRecordsCounter = taskContext.getCounters().findCounter(TaskCounter.COMBINE_OUTPUT_RECORDS);
  
  boolean isMap = conf.getBoolean(MRConfig.IS_MAP_PROCESSOR,false);
  this.mrTaskAttemptID = new TaskAttemptID(
      new TaskID(String.valueOf(taskContext.getApplicationId()
          .getClusterTimestamp()), taskContext.getApplicationId().getId(),
          isMap ? TaskType.MAP : TaskType.REDUCE,
          taskContext.getTaskIndex()), taskContext.getTaskAttemptNumber());
  
  LOG.info("Using combineKeyClass: " + keyClass + ", combineValueClass: " + valClass + ", combineComparator: " +comparator + ", useNewApi: " + useNewApi);
}
 
Example #30
Source File: UnorderedKVInputConfig.java    From tez with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Builder setAdditionalConfiguration(Map<String, String> confMap) {
  Objects.requireNonNull(confMap, "ConfMap cannot be null");
  Map<String, String> map = ConfigUtils.extractConfigurationMap(confMap,
      Lists.newArrayList(UnorderedKVInput.getConfigurationKeySet(),
          TezRuntimeConfiguration.getRuntimeAdditionalConfigKeySet()), TezRuntimeConfiguration.getAllowedPrefixes());
  ConfigUtils.addConfigMapToConfiguration(this.conf, map);
  return this;
}