Example #1
0
 /**
  * Make a copy of a writable object using serialization to a buffer.
  *
  * @param orig The object to copy
  * @return The copied object
  */
 public static <T extends Writable> T clone(T orig, Configuration conf) {
   try {
     @SuppressWarnings("unchecked") // Unchecked cast from Class to Class<T>
     T newInst = ReflectionUtils.newInstance((Class<T>) orig.getClass(), conf);
     ReflectionUtils.copy(conf, orig, newInst);
     return newInst;
   } catch (IOException e) {
     throw new RuntimeException("Error writing/reading clone buffer", e);
   }
 }
  @SuppressWarnings("unchecked")
  private void add(Configuration conf, String serializationName) {
    try {

      Class<? extends Serialization> serializionClass =
          (Class<? extends Serialization>) conf.getClassByName(serializationName);
      serializations.add(ReflectionUtils.newInstance(serializionClass, getConf()));
    } catch (ClassNotFoundException e) {
      LOG.warn("Serilization class not found: " + StringUtils.stringifyException(e));
    }
  }
 /** Construct a new {@link WritableComparable} instance. */
 public WritableComparable newKey() {
   return ReflectionUtils.newInstance(keyClass, null);
 }