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


Java Serialization类代码示例

本文整理汇总了Java中org.apache.hadoop.io.serializer.Serialization的典型用法代码示例。如果您正苦于以下问题:Java Serialization类的具体用法?Java Serialization怎么用?Java Serialization使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Serialization类属于org.apache.hadoop.io.serializer包,在下文中一共展示了Serialization类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeCopyForPassByValue

import org.apache.hadoop.io.serializer.Serialization; //导入依赖的package包/类
private <E> E makeCopyForPassByValue(Serialization<E> serialization,
                                      E obj) throws IOException {
  Serializer<E> ser =
    serialization.getSerializer(GenericsUtil.getClass(obj));
  Deserializer<E> deser =
    serialization.getDeserializer(GenericsUtil.getClass(obj));

  DataOutputBuffer dof = threadLocalDataOutputBuffer.get();

  dof.reset();
  ser.open(dof);
  ser.serialize(obj);
  ser.close();
  obj = ReflectionUtils.newInstance(GenericsUtil.getClass(obj),
                                    getChainJobConf());
  ByteArrayInputStream bais =
    new ByteArrayInputStream(dof.getData(), 0, dof.getLength());
  deser.open(bais);
  deser.deserialize(obj);
  deser.close();
  return obj;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:Chain.java

示例2: getSerialization

import org.apache.hadoop.io.serializer.Serialization; //导入依赖的package包/类
/**
 * Gets serializer for specified class.
 *
 * @param cls Class.
 * @param jobConf Job configuration.
 * @return Appropriate serializer.
 */
@SuppressWarnings("unchecked")
private HadoopSerialization getSerialization(Class<?> cls, Configuration jobConf) throws IgniteCheckedException {
    A.notNull(cls, "cls");

    SerializationFactory factory = new SerializationFactory(jobConf);

    Serialization<?> serialization = factory.getSerialization(cls);

    if (serialization == null)
        throw new IgniteCheckedException("Failed to find serialization for: " + cls.getName());

    if (serialization.getClass() == WritableSerialization.class)
        return new HadoopWritableSerialization((Class<? extends Writable>)cls);

    return new HadoopSerializationWrapper(serialization, cls);
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:HadoopV2TaskContext.java

示例3: getMapperCollector

import org.apache.hadoop.io.serializer.Serialization; //导入依赖的package包/类
/**
 * Returns the OutputCollector to be used by a Mapper instance in the chain.
 *
 * @param mapperIndex index of the Mapper instance to get the OutputCollector.
 * @param output      the original OutputCollector of the task.
 * @param reporter    the reporter of the task.
 * @return the OutputCollector to be used in the chain.
 */
@SuppressWarnings({"unchecked"})
public OutputCollector getMapperCollector(int mapperIndex,
                                          OutputCollector output,
                                          Reporter reporter) {
  Serialization keySerialization = mappersKeySerialization.get(mapperIndex);
  Serialization valueSerialization =
    mappersValueSerialization.get(mapperIndex);
  return new ChainOutputCollector(mapperIndex, keySerialization,
                                  valueSerialization, output, reporter);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:Chain.java

示例4: ChainOutputCollector

import org.apache.hadoop.io.serializer.Serialization; //导入依赖的package包/类
public ChainOutputCollector(int index, Serialization<K> keySerialization,
                            Serialization<V> valueSerialization,
                            OutputCollector output, Reporter reporter) {
  this.nextMapperIndex = index + 1;
  this.keySerialization = keySerialization;
  this.valueSerialization = valueSerialization;
  this.output = output;
  this.reporter = reporter;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:Chain.java

示例5: collect

import org.apache.hadoop.io.serializer.Serialization; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
public void collect(K key, V value) throws IOException {
  if (nextMapperIndex < mappers.size()) {
    // there is a next mapper in chain

    // only need to ser/deser if there is next mapper in the chain
    if (keySerialization != null) {
      key = makeCopyForPassByValue(keySerialization, key);
      value = makeCopyForPassByValue(valueSerialization, value);
    }

    // gets ser/deser and mapper of next in chain
    Serialization nextKeySerialization =
      mappersKeySerialization.get(nextMapperIndex);
    Serialization nextValueSerialization =
      mappersValueSerialization.get(nextMapperIndex);
    Mapper nextMapper = mappers.get(nextMapperIndex);

    // invokes next mapper in chain
    nextMapper.map(key, value,
                   new ChainOutputCollector(nextMapperIndex,
                                            nextKeySerialization,
                                            nextValueSerialization,
                                            output, reporter),
                   reporter);
  } else {
    // end of chain, user real output collector
    output.collect(key, value);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:Chain.java


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