本文整理匯總了Java中com.esotericsoftware.kryo.Kryo.readClassAndObject方法的典型用法代碼示例。如果您正苦於以下問題:Java Kryo.readClassAndObject方法的具體用法?Java Kryo.readClassAndObject怎麽用?Java Kryo.readClassAndObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.esotericsoftware.kryo.Kryo
的用法示例。
在下文中一共展示了Kryo.readClassAndObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: read
import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public DefaultLink read(Kryo kryo, Input input, Class<DefaultLink> type) {
ProviderId providerId = (ProviderId) kryo.readClassAndObject(input);
ConnectPoint src = (ConnectPoint) kryo.readClassAndObject(input);
ConnectPoint dst = (ConnectPoint) kryo.readClassAndObject(input);
Type linkType = (Type) kryo.readClassAndObject(input);
State state = (State) kryo.readClassAndObject(input);
boolean isDurable = input.readBoolean();
return DefaultLink.builder()
.providerId(providerId)
.src(src)
.dst(dst)
.type(linkType)
.state(state)
.isExpected(isDurable)
.build();
}
示例3: deserialize
import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public Object deserialize(InputStream input) throws IOException {
Kryo kryo = pool.borrow();
Input in = new Input(input);
Object result = kryo.readClassAndObject(in);
in.close();
input.close();
pool.release(kryo);
return result;
}
示例4: deserialize
import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public Object deserialize(final InputStream in) throws IOException {
Kryo kryo = kryoFactory.getKryo();
Input input = new Input(in);
Object result = kryo.readClassAndObject(input);
input.close();
kryoFactory.returnKryo(kryo);
return result;
}
示例5: read
import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public HostLocation read(Kryo kryo, Input input, Class<HostLocation> type) {
DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
PortNumber portNumber = (PortNumber) kryo.readClassAndObject(input);
long time = input.readLong();
return new HostLocation(deviceId, portNumber, time);
}
示例6: read
import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public EncodedDiscreteResources read(Kryo kryo, Input input, Class<EncodedDiscreteResources> cls) {
@SuppressWarnings("unchecked")
List<ClosedOpenRange> ranges = kryo.readObject(input, ArrayList.class);
DiscreteResourceCodec codec = (DiscreteResourceCodec) kryo.readClassAndObject(input);
RangeSet<Integer> rangeSet = TreeRangeSet.create();
ranges.stream()
.map(x -> Range.closedOpen(x.lowerBound(), x.upperBound()))
.forEach(rangeSet::add);
return new EncodedDiscreteResources(rangeSet, codec);
}
示例7: read
import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public DefaultPort read(Kryo kryo, Input input, Class<DefaultPort> aClass) {
Element element = (Element) kryo.readClassAndObject(input);
PortNumber number = kryo.readObject(input, PortNumber.class);
boolean isEnabled = input.readBoolean();
Port.Type type = kryo.readObject(input, Port.Type.class);
long portSpeed = input.readLong();
Annotations annotations = (Annotations) kryo.readClassAndObject(input);
return new DefaultPort(element, number, isEnabled, type, portSpeed, annotations);
}
示例8: 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;
}
示例9: read
import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public ObjectFloatMap read (Kryo kryo, Input input, Class<ObjectFloatMap> type) {
int length = input.readVarInt(true);
input.readBoolean(); // currently unused
ObjectFloatMap map = create(length);
Class keyClass = null;
Serializer keySerializer = null;
if (keyGenericType != null) {
keyClass = keyGenericType;
if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
keyGenericType = 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);
float value = input.readFloat();
map.put(key, value);
}
return map;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例13: read
import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public ObjectIntMap read (Kryo kryo, Input input, Class<ObjectIntMap> type) {
int length = input.readVarInt(true);
input.readBoolean(); // currently unused
ObjectIntMap map = create(length);
Class keyClass = null;
Serializer keySerializer = null;
if (keyGenericType != null) {
keyClass = keyGenericType;
if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
keyGenericType = 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);
int value = input.readInt();
map.put(key, value);
}
return map;
}
示例14: deserialize
import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
/**
* Deserializes given byte array to Object using Kryo instance in pool.
*
* @param bytes serialized bytes
* @param <T> deserialized Object type
* @return deserialized Object
*/
public <T> T deserialize(final byte[] bytes) {
Input in = new Input(bytes);
Kryo kryo = borrow();
try {
@SuppressWarnings("unchecked")
T obj = (T) kryo.readClassAndObject(in);
return obj;
} finally {
release(kryo);
}
}
示例15: read
import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public ImmutableList<Object> read(final Kryo kryo, final Input input, final Class<ImmutableList<Object>> type) {
final int size = input.readInt(true);
final Object[] values = new Object[size];
for (int i = 0; i < size; ++i) {
values[i] = kryo.readClassAndObject(input);
}
final ImmutableList<Object> result = ImmutableList.copyOf(values);
kryo.reference(result);
return result;
}