@Override public int readInt() throws IOException { try { return input.readInt(); } catch (KryoException e) { throw new IOException(e); } }
@Override public int readInt() throws IOException { try { return input.readInt(); } catch (KryoException e) { throw new IOException(e); } }
@Override public byte[] readBytes() throws IOException { try { int len = input.readInt(); if (len < 0) { return null; } else if (len == 0) { return new byte[]{}; } else { return input.readBytes(len); } } catch (KryoException e) { throw new IOException(e); } }
@Override public byte[] readBytes() throws IOException { try { int len = input.readInt(); if (len < 0) { return null; } else if (len == 0) { return new byte[]{}; } else { return input.readBytes(len); } } catch (KryoException e) { throw new IOException(e); } }
@Override public PyInteger read(Kryo kryo, Input input, Class<PyInteger> type) { return new PyInteger(input.readInt()); } }
/** * just get target taskId */ public static int deserializeTaskId(byte[] ser) { Input _kryoInput = new Input(1); _kryoInput.setBuffer(ser); return _kryoInput.readInt(); } }
@Override public ByteBuffer read(Kryo kryo, Input input, Class<ByteBuffer> type) { int len = input.readInt(); return ByteBuffer.wrap(input.readBytes(len)); } }
public List<Object> deserializeStrings(Input input) { List<Object> values = new ArrayList<Object>(); int size = input.readInt(true); for (int i = 0; i < size; i++) { values.add(input.readString()); } return values; }
@Override public Object read(Kryo kryo, Input input, Class c) { int len = input.readInt(); byte[] ser = new byte[len]; input.readBytes(ser); ByteArrayInputStream bis = new ByteArrayInputStream(ser); try { ObjectInputStream ois = new ObjectInputStream(bis); return ois.readObject(); } catch (Exception e) { throw new RuntimeException(e); } } }
@Override public TupleImpl read(Kryo kryo, Input input, Class<TupleImpl> type) { int length = input.readInt(); byte[] bytes = input.readBytes(length); return tupleDeserializer.deserialize(bytes); } }
public static MessageId deserialize(Input in) throws IOException { int numAnchors = in.readInt(true); Map<Long, Long> anchorsToIds = new HashMap<>(); for (int i = 0; i < numAnchors; i++) { anchorsToIds.put(in.readLong(), in.readLong()); } return new MessageId(anchorsToIds); }
public static MessageId deserialize(Input in) throws IOException { int numAnchors = in.readInt(true); if (numAnchors == 0) { return null; } Map<Long, Long> anchorsToIds = new HashMap<>(); for (int i = 0; i < numAnchors; i++) { anchorsToIds.put(in.readLong(), in.readLong()); } return new MessageId(anchorsToIds); } }
@Override public LocalTime read(Kryo kryo, Input input, Class<LocalTime> type) { final int time = input.readInt(true); return new LocalTime(time, ISOChronology.getInstanceUTC().withZone(DateTimeZone.UTC)); }
public PyObject read(Kryo kryo, Input input, Class<PyObject> type) { int len = input.readInt(); byte[] serPo = input.readBytes(len); try { return (PyObject) SerializationUtils.deserializeObject(serPo); } catch (IOException e) { throw new KryoException("Failed to deserialize object.", e); } catch (ClassNotFoundException e) { // this should only be possible if jython isn't on the class-path throw new KryoException("Failed to deserialize object.", e); } } }
public List<Object> deserializeFrom(Input input) { int type = input.readInt(true); switch (type) { case Values.OBJECT: return deserialize(input); case Values.STRING: return deserializeStrings(input); case Values.INTEGER: return deserializeIntegers(input); default: return deserialize(input); } }
@Override public TestRecord read(Kryo kryo, Input input, Class<TestRecord> type) { int length = input.readInt(); byte[] buffer = input.readBytes(length); return new TestRecord(buffer); } }