本文整理汇总了Java中com.esotericsoftware.kryo.Kryo.readObjectOrNull方法的典型用法代码示例。如果您正苦于以下问题:Java Kryo.readObjectOrNull方法的具体用法?Java Kryo.readObjectOrNull怎么用?Java Kryo.readObjectOrNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.esotericsoftware.kryo.Kryo
的用法示例。
在下文中一共展示了Kryo.readObjectOrNull方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public BSpline read(Kryo kryo, Input input, Class<BSpline> type) {
BSpline bSpline = new BSpline();
Class<? extends Vector> vectorType = kryo.readClass(input).getType();
int controlPointsLength = input.readInt();
if (controlPointsLength >= 0){
Vector<?>[] controlPoints = (Vector<?>[])java.lang.reflect.Array.newInstance(vectorType, controlPointsLength);
for (int i = 0; i < controlPointsLength; i++) {
controlPoints[i] = kryo.readObjectOrNull(input, vectorType); // vector type won't be null if control points had a length
}
bSpline.controlPoints = controlPoints;
}
bSpline.knots = kryo.readObjectOrNull(input, Array.class);
bSpline.degree = input.readInt(true);
bSpline.continuous = input.readBoolean();
bSpline.spanCount = input.readInt(true);
return bSpline;
}
示例2: read
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public CatmullRomSpline read(Kryo kryo, Input input, Class<CatmullRomSpline> type) {
CatmullRomSpline catmullRomSpline = new CatmullRomSpline();
Class<? extends Vector> vectorType = kryo.readClass(input).getType();
int controlPointsLength = input.readInt();
if (controlPointsLength >= 0){
Vector<?>[] controlPoints = (Vector<?>[])java.lang.reflect.Array.newInstance(vectorType, controlPointsLength);
for (int i = 0; i < controlPointsLength; i++) {
controlPoints[i] = kryo.readObjectOrNull(input, vectorType); // vector type won't be null if control points had a length
}
catmullRomSpline.controlPoints = controlPoints;
}
catmullRomSpline.continuous = input.readBoolean();
catmullRomSpline.spanCount = input.readInt(true);
return catmullRomSpline;
}
示例3: read
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public FloatCounter read(Kryo kryo, Input input, Class<FloatCounter> type) {
WindowedMean windowedMean = kryo.readObjectOrNull(input, WindowedMean.class);
FloatCounter floatCounter = new FloatCounter(windowedMean == null ? 0 : windowedMean.getWindowSize());
if (windowedMean != null) {
float[] windowedMeanValues = windowedMean.getWindowValues();
for (float f : windowedMeanValues) { // restores the private WindowedMean
floatCounter.put(f);
}
}
floatCounter.count = input.readInt();
floatCounter.total = input.readFloat();
floatCounter.min = input.readFloat();
floatCounter.max = input.readFloat();
floatCounter.average = input.readFloat();
floatCounter.latest = input.readFloat();
floatCounter.value = input.readFloat();
return floatCounter;
}
示例4: read
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public SortedIntList read(Kryo kryo, Input input, Class<SortedIntList> type) {
int length = input.readVarInt(true);
SortedIntList list = new SortedIntList();
kryo.reference(list);
Class elementClass = null;
Serializer serializer = null;
if (genericType != null) {
elementClass = genericType;
serializer = kryo.getSerializer(genericType);
genericType = null;
}
for (int i = 0; i < length; i++) {
int index = input.readInt();
Object value = serializer != null ?
kryo.readObjectOrNull(input, elementClass, serializer) : kryo.readClassAndObject(input);
list.insert(index, value);
}
return list;
}
示例5: deserialize
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public Object[] deserialize(byte[] message) {
try {
Input input = new Input(new ByteArrayInputStream(message));
Kryo kryo = pool.borrow();
Object[] objects = kryo.readObjectOrNull(input, Object[].class);
pool.release(kryo);
return objects;
} catch (KryoException e) {
throw new OmegaException("Unable to deserialize message", e);
}
}
示例6: read
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public T read (Kryo kryo, Input input, Class<T> type) {
int length = input.readVarInt(true);
input.readBoolean(); // currently unused
T map = create(length);
Class keyClass = null;
Class valueClass = null;
Serializer keySerializer = null;
if (keyGenericType != null) {
keyClass = keyGenericType;
if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
keyGenericType = null;
}
Serializer valueSerializer = null;
if (valueGenericType != null) {
valueClass = valueGenericType;
if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
valueGenericType = null;
}
kryo.reference(map);
for (int i = 0; i < length; i++) {
Object key;
if (keySerializer != null) {
key = kryo.readObject(input, keyClass, keySerializer);
} else
key = kryo.readClassAndObject(input);
Object value;
if (valueSerializer != null) {
value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
} else
value = kryo.readClassAndObject(input);
map.put(key, value);
}
return map;
}
示例7: read
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public IdentityMap read (Kryo kryo, Input input, Class<IdentityMap> type) {
int length = input.readVarInt(true);
input.readBoolean(); // currently unused
IdentityMap map = new IdentityMap(length);
Class keyClass = null;
Class valueClass = null;
Serializer keySerializer = null;
if (keyGenericType != null) {
keyClass = keyGenericType;
if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
keyGenericType = null;
}
Serializer valueSerializer = null;
if (valueGenericType != null) {
valueClass = valueGenericType;
if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
valueGenericType = null;
}
kryo.reference(map);
for (int i = 0; i < length; i++) {
Object key;
if (keySerializer != null) {
key = kryo.readObject(input, keyClass, keySerializer);
} else
key = kryo.readClassAndObject(input);
Object value;
if (valueSerializer != null) {
value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
} else
value = kryo.readClassAndObject(input);
map.put(key, value);
}
return map;
}
示例8: read
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public LongMap read (Kryo kryo, Input input, Class<LongMap> type) {
int length = input.readVarInt(true);
input.readBoolean(); // currently unused
LongMap map = new LongMap(length);
Class valueClass = null;
Serializer valueSerializer = null;
if (valueGenericType != null) {
valueClass = valueGenericType;
if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
valueGenericType = null;
}
kryo.reference(map);
for (int i = 0; i < length; i++) {
long key = input.readLong();
Object value;
if (valueSerializer != null) {
value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
} else
value = kryo.readClassAndObject(input);
map.put(key, value);
}
return map;
}
示例9: read
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public IntMap read (Kryo kryo, Input input, Class<IntMap> type) {
int length = input.readVarInt(true);
input.readBoolean(); // currently unused
IntMap map = new IntMap(length);
Class valueClass = null;
Serializer valueSerializer = null;
if (valueGenericType != null) {
valueClass = valueGenericType;
if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
valueGenericType = null;
}
kryo.reference(map);
for (int i = 0; i < length; i++) {
int key = input.readInt();
Object value;
if (valueSerializer != null) {
value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
} else
value = kryo.readClassAndObject(input);
map.put(key, value);
}
return map;
}
示例10: skipObsoleteObjectOrNull
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
/** Reads an object or null using the registered serializer, but does not return it. If the object type is a {@link Disposable},
* uses native memory, or is time consuming to instantiate, it should use an implementation of {@link SkippableSerializer}
* to avoid memory leaks or wasted instantiation time. */
public static <T> void skipObsoleteObjectOrNull (Kryo kryo, Input input, Class<T> type){
com.esotericsoftware.kryo.util.ObjectMap graphContext = kryo.getGraphContext();
final int branchDepth = graphContext.containsKey(OBSOLETE_BRANCH_KEY) ? (Integer)graphContext.get(OBSOLETE_BRANCH_KEY) : 0;
graphContext.put(OBSOLETE_BRANCH_KEY, branchDepth + 1);
kryo.readObjectOrNull(input, type);
graphContext.put(OBSOLETE_BRANCH_KEY, branchDepth);
}
示例11: read
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public Bezier read(Kryo kryo, Input input, Class<Bezier> type) {
Bezier bezier = new Bezier();
bezier.points = kryo.readObjectOrNull(input, Array.class);
return bezier;
}
示例12: read
import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public ArrayMap read (Kryo kryo, Input input, Class<ArrayMap> type) {
boolean ordered = input.readBoolean();
int length = input.readVarInt(true);
Class knownKeyClass = kryo.readClass(input).getType();
Class knownValueClass = kryo.readClass(input).getType();
ArrayMap map = new ArrayMap(ordered, length, knownKeyClass, knownValueClass);
Class keyClass = null;
Class valueClass = null;
Serializer keySerializer = null;
if (keyGenericType != null) {
keyClass = keyGenericType;
if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
keyGenericType = null;
}
Serializer valueSerializer = null;
if (valueGenericType != null) {
valueClass = valueGenericType;
if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
valueGenericType = null;
}
kryo.reference(map);
for (int i = 0; i < length; i++) {
Object key;
if (keySerializer != null) {
key = kryo.readObject(input, keyClass, keySerializer);
} else
key = kryo.readClassAndObject(input);
Object value;
if (valueSerializer != null) {
value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
} else
value = kryo.readClassAndObject(input);
map.put(key, value);
}
return map;
}