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


Java Kryo.setInstantiatorStrategy方法代码示例

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


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

示例1: createKryoInstance

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
private Kryo createKryoInstance() {
    Kryo kryo = new Kryo();

    kryo.register(RakTable.class);
    kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
    kryo.setReferences(false);

    kryo.register(Collections.singletonList("").getClass(), new ArraysAsListSerializer());
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);
    SynchronizedCollectionsSerializer.registerSerializers(kryo);
    kryo.addDefaultSerializer(new ArrayList<>().subList(0, 0).getClass(), new CollectionSerializer());
    kryo.addDefaultSerializer(new LinkedList<>().subList(0, 0).getClass(), new CollectionSerializer());
    kryo.register(UUID.class, new UUIDSerializer());

    for (Class<?> clazz : mCustomSerializers.keySet()) {
        kryo.register(clazz, mCustomSerializers.get(clazz));
    }

    kryo.setInstantiatorStrategy(
            new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));

    return kryo;
}
 
开发者ID:isfaaghyth,项目名称:Rak,代码行数:24,代码来源:PlainData.java

示例2: create

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
/**
 * Creates a Kryo instance.
 *
 * @return Kryo instance
 */
@Override
public Kryo create() {
    log.trace("Creating Kryo instance for {}", this);
    Kryo kryo = new Kryo();
    kryo.setRegistrationRequired(registrationRequired);

    // TODO rethink whether we want to use StdInstantiatorStrategy
    kryo.setInstantiatorStrategy(
            new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));

    for (RegistrationBlock block : registeredBlocks) {
        int id = block.begin();
        if (id == FLOATING_ID) {
            id = kryo.getNextRegistrationId();
        }
        for (Pair<Class<?>, Serializer<?>> entry : block.types()) {
            register(kryo, entry.getLeft(), entry.getRight(), id++);
        }
    }
    return kryo;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:KryoNamespace.java

示例3: 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

示例4: readObject

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public static Object readObject(InputStream inputStream) {
  Kryo kryo = new Kryo();
  kryo.register(java.lang.invoke.SerializedLambda.class);
  kryo.register(ClosureSerializer.Closure.class, new ClosureSerializer());
  kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));

  Input input = new Input(inputStream);
  return kryo.readClassAndObject(input);
}
 
开发者ID:spotify,项目名称:hype,代码行数:10,代码来源:SerializationUtil.java

示例5: initialValue

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
protected Kryo initialValue() {

    Kryo kryo = new Kryo();
    kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
    return kryo;
}
 
开发者ID:TFdream,项目名称:mango,代码行数:8,代码来源:KryoSerializer.java

示例6: getKryoObject

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
private Kryo getKryoObject() {
    Kryo kryo = new Kryo();
    kryo.setInstantiatorStrategy(new SerializingInstantiatorStrategy());
    kryo.register(KMeansDetectionModel.class);
    kryo.register(AthenaMLFeatureConfiguration.class);
    kryo.register(DetectionModel.class);
    kryo.register(FeatureConstraint.class);
    kryo.register(AthenaFeatureField.class);
    kryo.register(AthenaIndexField.class);
    kryo.register(AthenaField.class);
    kryo.register(FeatureConstraintOperator.class);
    kryo.register(FeatureConstraintOperatorType.class);
    kryo.register(FeatureConstraintType.class);
    kryo.register(AthenaMLFeatureConfiguration.class);
    kryo.register(Marking.class);
    kryo.register(FeatureDatabaseMgmtManager.class);
    kryo.register(Indexing.class);
    kryo.register(ClusterModelSummary.class);
    kryo.register(KMeansDetectionAlgorithm.class);
    kryo.register(KmeansModelSummary.class);
    kryo.register(Accumulator.class);
    kryo.register(ClusterModelSummary.UniqueFlowAccumulatorParam.class);
    kryo.register(ClusterModelSummary.LongAccumulatorParam.class);
    kryo.register(ClassificationMarkingElement.class);
    kryo.register(TargetAthenaValue.class);
    return kryo;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:ModelSerialization.java

示例7: treeNode

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Test
public void treeNode() {
    final Result<DecisionTreeRuleSet> result = (new CommisionRuleSetSupplier()).get();
    EhSupport.ensure(result.isSuccess(), "Could not create decision tree");
    final DecisionTreeRuleSet ruleSet = result.getData();

    final TreeNode node = DecisionTreeFactory.constructDecisionTree(ruleSet, DecisionTreeType.SINGLE);

    final Kryo kryo = new Kryo();
    // no default no-arg constructors
    kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());

    final InstantiatorStrategy defaultInstantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
    kryo.getRegistration(ArrayList.class)
            .setInstantiator(defaultInstantiatorStrategy.newInstantiatorOf(ArrayList.class));
    kryo.getRegistration(HashSet.class)
            .setInstantiator(defaultInstantiatorStrategy.newInstantiatorOf(HashSet.class));
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);

    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final Output output = new Output(out);
    kryo.writeObject(output, node);
    output.flush();
    output.close();

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray());
    final Input kryoInput = new Input(inputStream);
    final TreeNode tree = kryo.readObject(kryoInput, BaseTreeNode.class);

    final SingleDecisionTreeFactoryTest test = new SingleDecisionTreeFactoryTest();
    test.checkTreeNode(tree, ruleSet);

    assertEquals(node, tree);
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:35,代码来源:TreeSerializationTest.java

示例8: KryoUnsafePacketFactory

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public KryoUnsafePacketFactory(Class<T> type, int id, Kryo kryo) {
	super(type, id);
	this.kryo = kryo;
	kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
}
 
开发者ID:BRjDevs,项目名称:BRjLibs,代码行数:6,代码来源:KryoUnsafePacketFactory.java

示例9: KryoPacketFactory

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public KryoPacketFactory(Class<T> type, int id, Kryo kryo) {
	super(type, id);
	this.kryo = kryo;
	kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
}
 
开发者ID:BRjDevs,项目名称:BRjLibs,代码行数:6,代码来源:KryoPacketFactory.java


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