本文整理了Java中com.esotericsoftware.kryo.Kryo.getNextRegistrationId()
方法的一些代码示例,展示了Kryo.getNextRegistrationId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kryo.getNextRegistrationId()
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.Kryo
类名称:Kryo
方法名:getNextRegistrationId
[英]Returns the lowest, next available integer ID.
[中]返回最低的下一个可用整数ID。
代码示例来源:origin: apache/flink
/**
* Apply a list of {@link KryoRegistration} to a Kryo instance. The list of registrations is
* assumed to already be a final resolution of all possible registration overwrites.
*
* <p>The registrations are applied in the given order and always specify the registration id as
* the next available id in the Kryo instance (providing the id just extra ensures nothing is
* overwritten, and isn't strictly required);
*
* @param kryo the Kryo instance to apply the registrations
* @param resolvedRegistrations the registrations, which should already be resolved of all possible registration overwrites
*/
public static void applyRegistrations(Kryo kryo, Collection<KryoRegistration> resolvedRegistrations) {
Serializer<?> serializer;
for (KryoRegistration registration : resolvedRegistrations) {
serializer = registration.getSerializer(kryo);
if (serializer != null) {
kryo.register(registration.getRegisteredClass(), serializer, kryo.getNextRegistrationId());
} else {
kryo.register(registration.getRegisteredClass(), kryo.getNextRegistrationId());
}
}
}
}
代码示例来源:origin: apache/flink
final int nextId = kryo.getNextRegistrationId();
代码示例来源:origin: atomix/atomix
/**
* Creates a Kryo instance.
*
* @return Kryo instance
*/
@Override
public Kryo create() {
LOGGER.trace("Creating Kryo instance for {}", this);
Kryo kryo = new Kryo();
kryo.setClassLoader(classLoader);
kryo.setRegistrationRequired(registrationRequired);
// If compatible serialization is enabled, override the default serializer.
if (compatible) {
kryo.setDefaultSerializer(CompatibleFieldSerializer::new);
}
// 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;
}
代码示例来源:origin: org.apache.apex/apex-engine
public void init()
{
firstAvailableRegistrationId = kryo.getNextRegistrationId();
nextAvailableRegistrationId = firstAvailableRegistrationId;
}
代码示例来源:origin: com.alibaba.blink/flink-core
/**
* Apply a list of {@link KryoRegistration} to a Kryo instance. The list of registrations is
* assumed to already be a final resolution of all possible registration overwrites.
*
* <p>The registrations are applied in the given order and always specify the registration id as
* the next available id in the Kryo instance (providing the id just extra ensures nothing is
* overwritten, and isn't strictly required);
*
* @param kryo the Kryo instance to apply the registrations
* @param resolvedRegistrations the registrations, which should already be resolved of all possible registration overwrites
*/
public static void applyRegistrations(Kryo kryo, Collection<KryoRegistration> resolvedRegistrations) {
Serializer<?> serializer;
for (KryoRegistration registration : resolvedRegistrations) {
serializer = registration.getSerializer(kryo);
if (serializer != null) {
kryo.register(registration.getRegisteredClass(), serializer, kryo.getNextRegistrationId());
} else {
kryo.register(registration.getRegisteredClass(), kryo.getNextRegistrationId());
}
}
}
}
代码示例来源:origin: org.apache.flink/flink-core
/**
* Apply a list of {@link KryoRegistration} to a Kryo instance. The list of registrations is
* assumed to already be a final resolution of all possible registration overwrites.
*
* <p>The registrations are applied in the given order and always specify the registration id as
* the next available id in the Kryo instance (providing the id just extra ensures nothing is
* overwritten, and isn't strictly required);
*
* @param kryo the Kryo instance to apply the registrations
* @param resolvedRegistrations the registrations, which should already be resolved of all possible registration overwrites
*/
public static void applyRegistrations(Kryo kryo, Collection<KryoRegistration> resolvedRegistrations) {
Serializer<?> serializer;
for (KryoRegistration registration : resolvedRegistrations) {
serializer = registration.getSerializer(kryo);
if (serializer != null) {
kryo.register(registration.getRegisteredClass(), serializer, kryo.getNextRegistrationId());
} else {
kryo.register(registration.getRegisteredClass(), kryo.getNextRegistrationId());
}
}
}
}
代码示例来源:origin: com.esotericsoftware.kryo/kryo
/** Registers the class using the lowest, next available integer ID and the specified serializer. If the class is already
* registered, the existing entry is updated with the new serializer. Registering a primitive also affects the corresponding
* primitive wrapper.
* <p>
* Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when
* using this method. The order must be the same at deserialization as it was for serialization. */
public Registration register (Class type, Serializer serializer) {
Registration registration = classResolver.getRegistration(type);
if (registration != null) {
registration.setSerializer(serializer);
return registration;
}
return classResolver.register(new Registration(type, serializer, getNextRegistrationId()));
}
代码示例来源:origin: com.esotericsoftware/kryo-shaded
/** Registers the class using the lowest, next available integer ID and the specified serializer. If the class is already
* registered, the existing entry is updated with the new serializer. Registering a primitive also affects the corresponding
* primitive wrapper.
* <p>
* Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when
* using this method. The order must be the same at deserialization as it was for serialization. */
public Registration register (Class type, Serializer serializer) {
Registration registration = classResolver.getRegistration(type);
if (registration != null) {
registration.setSerializer(serializer);
return registration;
}
return classResolver.register(new Registration(type, serializer, getNextRegistrationId()));
}
代码示例来源:origin: svn2github/kryo
/** Registers the class using the lowest, next available integer ID and the specified serializer. If the class is already
* registered, the existing entry is updated with the new serializer. Registering a primitive also affects the corresponding
* primitive wrapper.
* <p>
* Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when
* using this method. The order must be the same at deserialization as it was for serialization. */
public Registration register (Class type, Serializer serializer) {
Registration registration = classResolver.getRegistration(type);
if (registration != null) {
registration.setSerializer(serializer);
return registration;
}
return classResolver.register(new Registration(type, serializer, getNextRegistrationId()));
}
代码示例来源:origin: com.esotericsoftware/kryo
/** Registers the class using the lowest, next available integer ID and the specified serializer. If the class is already
* registered, the existing entry is updated with the new serializer. Registering a primitive also affects the corresponding
* primitive wrapper.
* <p>
* Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when
* using this method. The order must be the same at deserialization as it was for serialization. */
public Registration register (Class type, Serializer serializer) {
Registration registration = classResolver.getRegistration(type);
if (registration != null) {
registration.setSerializer(serializer);
return registration;
}
return classResolver.register(new Registration(type, serializer, getNextRegistrationId()));
}
代码示例来源:origin: io.atomix/atomix-kryo
/**
* 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<?>[], com.esotericsoftware.kryo.Serializer<?>> entry : block.types()) {
register(kryo, entry.getLeft(), entry.getRight(), id++);
}
}
return kryo;
}
代码示例来源:origin: org.onosproject/onlab-misc
/**
* 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);
// If compatible serialization is enabled, override the default serializer.
if (compatible) {
kryo.setDefaultSerializer(CompatibleFieldSerializer::new);
}
// 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;
}
代码示例来源:origin: io.atomix/atomix-utils
/**
* Creates a Kryo instance.
*
* @return Kryo instance
*/
@Override
public Kryo create() {
log.trace("Creating Kryo instance for {}", this);
Kryo kryo = new Kryo();
kryo.setClassLoader(classLoader);
kryo.setRegistrationRequired(registrationRequired);
// If compatible serialization is enabled, override the default serializer.
if (compatible) {
kryo.setDefaultSerializer(CompatibleFieldSerializer::new);
}
// 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;
}
代码示例来源:origin: inspectIT/inspectIT
int nextRegistrationId = kryo.getNextRegistrationId();
nextRegistrationId += 9;
内容来源于网络,如有侵权,请联系作者删除!