本文整理汇总了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;
}
示例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;
}
示例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);
}
};
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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()));
}
示例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()));
}