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


Java Kryo.newInstance方法代码示例

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


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

示例1: forSerialization

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
/**
 * Returns a new {@link LogicalPlanSerializer}
 * @param cluster cluster to used during serialization
 */
public static LogicalPlanSerializer forSerialization(final RelOptCluster cluster) {
  final Kryo kryo = new Kryo();
  // use objenesis for creating mock objects
  kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));

  final CalciteCatalogReader catalog = kryo.newInstance(CalciteCatalogReader.class);
  final StoragePluginRegistry registry = kryo.newInstance(StoragePluginRegistryImpl.class);
  final RelSerializer serializer = RelSerializer.newBuilder(kryo, cluster, catalog, registry).build();

  return new LogicalPlanSerializer() {

    @Override
    public byte[] serialize(final RelNode plan) {
      return serializer.serialize(plan);
    }

  };
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:KryoLogicalPlanSerializers.java

示例2: read

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public RelTraitSet read(final Kryo kryo, final Input input, final Class<RelTraitSet> type) {

  final int size = kryo.readObject(input, Integer.class);
  final RelTrait[] traits = new RelTrait[size];
  for (int i = 0; i < size; i++) {
    final RelTrait trait = (RelTrait) kryo.readClassAndObject(input);
    // normalize trait so that stupid calcite won't complain about == checks.
    traits[i] = trait.getTraitDef().canonize(trait);
  }

  final String digest = kryo.readObject(input, String.class);
  final Object cache = kryo.readClassAndObject(input);

  final RelTraitSet traitSet = kryo.newInstance(type);

  try {
    getField(NAME_CACHE).set(traitSet, cache);
    getField(NAME_TRAITS).set(traitSet, traits);
    getField(NAME_STRING).set(traitSet, digest);
  } catch (final NoSuchFieldException|IllegalAccessException e) {
    throw new RuntimeException("unable to deserialize TraitSet", e);
  }

  kryo.reference(traitSet);
  return traitSet;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:28,代码来源:RelTraitSerializers.java

示例3: read

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public T read(final Kryo kryo, final Input input, final Class<T> type) {
  // do not use delegate.read because we do not want it to cache the object. Rather, we will cache the normalized type.
  final T dataType = kryo.newInstance(type);
  final FieldSerializer.CachedField[] fields = delegate.getFields();
  for (int i = 0, n = fields.length; i < n; i++) {
    fields[i].read(input, dataType);
  }

  // be gentle to calcite and normalize the returned data type. normalization here means to use same type instances.
  final T result = (T) typeFactory.copyType(dataType);
  kryo.reference(result);
  return result;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:15,代码来源:RelDataTypeSerializer.java

示例4: read

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public T read(final Kryo kryo, final Input input, final Class<T> type) {
  try {
    final T object = kryo.newInstance(type);
    kryo.reference(object);
    object.readFields(new DataInputStream(input));
    return object;
  } catch (final IOException e) {
    throw new RuntimeException("unable to deserialize Writable object", e);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:12,代码来源:WritableSerializer.java

示例5: read

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public T read(Kryo kryo, Input input, Class<T> type) {
    int nfields = input.readInt(true);
    T object = kryo.newInstance(type);
    for(int i = 0; i < nfields; i++) {
        int id = input.readInt(true);
        try {
            fields.get(id).set(object, kryo.readClassAndObject(input));
        } catch(IllegalAccessException e) {
            throw new AssertionError(e);
        }
    }
    return object;
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:15,代码来源:CustomSerializer.java


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