當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。