Java Code Examples for com.esotericsoftware.kryo.Kryo#readObjectOrNull()
The following examples show how to use
com.esotericsoftware.kryo.Kryo#readObjectOrNull() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObjectSpace.java From RuinsOfRevenge with MIT License | 6 votes |
public void read (Kryo kryo, Input input) { objectID = input.readInt(true); int methodClassID = input.readInt(true); Class methodClass = kryo.getRegistration(methodClassID).getType(); byte methodIndex = input.readByte(); CachedMethod cachedMethod; try { cachedMethod = getMethods(kryo, methodClass)[methodIndex]; } catch (IndexOutOfBoundsException ex) { throw new KryoException("Invalid method index " + methodIndex + " for class: " + methodClass.getName()); } method = cachedMethod.method; args = new Object[cachedMethod.serializers.length]; for (int i = 0, n = args.length; i < n; i++) { Serializer serializer = cachedMethod.serializers[i]; if (serializer != null) args[i] = kryo.readObjectOrNull(input, method.getParameterTypes()[i], serializer); else args[i] = kryo.readClassAndObject(input); } responseID = input.readByte(); }
Example 2
Source File: KryoMessageFormat.java From txle with Apache License 2.0 | 5 votes |
@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); } }
Example 3
Source File: GrpcTxEventEndpointImpl.java From txle with Apache License 2.0 | 5 votes |
private 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 RuntimeException("Unable to deserialize message", e); } }
Example 4
Source File: KryoMessageFormat.java From servicecomb-pack with Apache License 2.0 | 5 votes |
@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); } }
Example 5
Source File: ObjectSpace.java From kryonet with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void read (Kryo kryo, Input input) { objectID = input.readInt(true); int methodClassID = input.readInt(true); Class methodClass = kryo.getRegistration(methodClassID).getType(); byte methodIndex = input.readByte(); try { cachedMethod = getMethods(kryo, methodClass)[methodIndex]; } catch (IndexOutOfBoundsException ex) { throw new KryoException("Invalid method index " + methodIndex + " for class: " + methodClass.getName()); } Serializer[] serializers = cachedMethod.serializers; Class[] parameterTypes = cachedMethod.method.getParameterTypes(); Object[] args = new Object[serializers.length]; this.args = args; for (int i = 0, n = args.length; i < n; i++) { Serializer serializer = serializers[i]; if (serializer != null) args[i] = kryo.readObjectOrNull(input, parameterTypes[i], serializer); else args[i] = kryo.readClassAndObject(input); } responseData = input.readByte(); }
Example 6
Source File: KryoTest.java From RoaringBitmap with Apache License 2.0 | 5 votes |
public static RoaringBitmap readRoaringFromFile(File f, Serializer<RoaringBitmap> serializer) throws FileNotFoundException { Kryo kryo = createKryo(); Input inputMap = new Input(new FileInputStream(f)); RoaringBitmap roaring = kryo.readObjectOrNull(inputMap, RoaringBitmap.class, serializer); inputMap.close(); return roaring; }
Example 7
Source File: Http2JMeter.java From jsflight with Apache License 2.0 | 4 votes |
public List<RestoredRequest> getRequests(String file, int limit) throws IOException { List<RestoredRequest> requests = new ArrayList<>(); FastInput input = new FastInput(new FileInputStream(file)); Kryo kryo = new Kryo(); kryo.register(HashMap.class, new MapSerializer()); while (input.available() > 0) { InternalEventRecorder.InternalEventRecord record = kryo.readObject(input, InternalEventRecorder.InternalEventRecord.class); String tag = new String(record.tag).trim(); if (tag.equalsIgnoreCase(HttpRecorderHelper.HTTP_RECORDER_TAG)) { HttpRecordInformation information = (HttpRecordInformation)record.data; RestoredRequest request = new RestoredRequest(); if (information.params != null && information.params.length > 0) { FastInput paramsInput = new FastInput(new ByteArrayInputStream(information.params)); request.parameters = kryo.readObject(paramsInput, HashMap.class); request.headers = kryo.readObject(paramsInput, HashMap.class); request.contentLength = kryo.readObjectOrNull(paramsInput, Integer.class); request.contentType = kryo.readObjectOrNull(paramsInput, String.class); request.uri = kryo.readObjectOrNull(paramsInput, String.class); request.method = kryo.readObjectOrNull(paramsInput, String.class); request.contextPath = kryo.readObjectOrNull(paramsInput, String.class); request.cookies = kryo.readObject(paramsInput, HashMap.class); } if (information.payload != null && information.payload.length > 0) { request.payload = new String(information.payload); } request.additional = information.additional; request.timestampNs = record.timestampNs; if (limit > 0 && requests.size() >= limit) { break; } requests.add(request); } } return requests; }
Example 8
Source File: Perceptron.java From incubator-samoa with Apache License 2.0 | 4 votes |
@Override public Perceptron read(Kryo kryo, Input input, Class<Perceptron> type) { PerceptronData perceptronData = kryo.readObjectOrNull(input, PerceptronData.class); return perceptronData.build(); }
Example 9
Source File: TargetMean.java From incubator-samoa with Apache License 2.0 | 4 votes |
@Override public TargetMean read(Kryo kryo, Input input, Class<TargetMean> type) { TargetMeanData data = kryo.readObjectOrNull(input, TargetMeanData.class); return data.build(); }
Example 10
Source File: MastershipTermSerializer.java From onos with Apache License 2.0 | 4 votes |
@Override public MastershipTerm read(Kryo kryo, Input input, Class<MastershipTerm> type) { final NodeId node = kryo.readObjectOrNull(input, NodeId.class, nodeIdSerializer()); final long term = input.readLong(); return MastershipTerm.of(node, term); }
Example 11
Source File: Perceptron.java From samoa with Apache License 2.0 | 4 votes |
@Override public Perceptron read(Kryo kryo, Input input, Class<Perceptron> type) { PerceptronData perceptronData = kryo.readObjectOrNull(input, PerceptronData.class); return perceptronData.build(); }
Example 12
Source File: TargetMean.java From samoa with Apache License 2.0 | 4 votes |
@Override public TargetMean read(Kryo kryo, Input input, Class<TargetMean> type) { TargetMeanData data = kryo.readObjectOrNull(input, TargetMeanData.class); return data.build(); }