当前位置: 首页>>代码示例>>Java>>正文


Java GenericsUtil.getClass方法代码示例

本文整理汇总了Java中org.apache.hadoop.util.GenericsUtil.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java GenericsUtil.getClass方法的具体用法?Java GenericsUtil.getClass怎么用?Java GenericsUtil.getClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.util.GenericsUtil的用法示例。


在下文中一共展示了GenericsUtil.getClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: storeArray

import org.apache.hadoop.util.GenericsUtil; //导入方法依赖的package包/类
/**
 * Stores the array of items in the configuration with the given keyName.
 * 
 * @param <K> the class of the item
 * @param conf the configuration to use 
 * @param items the objects to be stored
 * @param keyName the name of the key to use
 * @throws IndexOutOfBoundsException if the items array is empty
 * @throws IOException : forwards Exceptions from the underlying 
 * {@link Serialization} classes.         
 */
public static <K> void storeArray(Configuration conf, K[] items,
    String keyName) throws IOException {

  DefaultStringifier<K> stringifier = new DefaultStringifier<K>(conf, 
      GenericsUtil.getClass(items[0]));
  try {
    StringBuilder builder = new StringBuilder();
    for (K item : items) {
      builder.append(stringifier.toString(item)).append(SEPARATOR);
    }
    conf.set(keyName, builder.toString());
  }
  finally {
    stringifier.close();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:28,代码来源:DefaultStringifier.java

示例2: toString

import org.apache.hadoop.util.GenericsUtil; //导入方法依赖的package包/类
@Override
public String toString() {
  Configuration conf = new Configuration();
  conf.set("io.serializations",
           "org.apache.hadoop.io.serializer.JavaSerialization,"
           + "org.apache.hadoop.io.serializer.WritableSerialization");
  DefaultStringifier<Map<String,String>> mapStringifier = new DefaultStringifier<Map<String,String>>(conf,
      GenericsUtil.getClass(params));
  try {
    return mapStringifier.toString(params);
  } catch (IOException e) {
    log.info("Encountered IOException while deserializing returning empty string", e);
    return "";
  }
  
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:17,代码来源:Parameters.java

示例3: parseParams

import org.apache.hadoop.util.GenericsUtil; //导入方法依赖的package包/类
public static Map<String,String> parseParams(String serializedString) throws IOException {
  Configuration conf = new Configuration();
  conf.set("io.serializations",
           "org.apache.hadoop.io.serializer.JavaSerialization,"
           + "org.apache.hadoop.io.serializer.WritableSerialization");
  Map<String,String> params = Maps.newHashMap();
  DefaultStringifier<Map<String,String>> mapStringifier = new DefaultStringifier<Map<String,String>>(conf,
      GenericsUtil.getClass(params));
  return mapStringifier.fromString(serializedString);
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:11,代码来源:Parameters.java

示例4: store

import org.apache.hadoop.util.GenericsUtil; //导入方法依赖的package包/类
/**
 * Stores the item in the configuration with the given keyName.
 * 
 * @param <K>  the class of the item
 * @param conf the configuration to store
 * @param item the object to be stored
 * @param keyName the name of the key to use
 * @throws IOException : forwards Exceptions from the underlying 
 * {@link Serialization} classes. 
 */
public static <K> void store(Configuration conf, K item, String keyName)
throws IOException {

  DefaultStringifier<K> stringifier = new DefaultStringifier<K>(conf,
      GenericsUtil.getClass(item));
  conf.set(keyName, stringifier.toString(item));
  stringifier.close();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:DefaultStringifier.java


注:本文中的org.apache.hadoop.util.GenericsUtil.getClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。