@Override protected long maybeSkip(long count) throws IOException { // Work around some bugs in Input.skip() int remaining = input.limit() - input.position(); if (remaining == 0) { long skipped = inputStream.skip(count); if (skipped > 0) { extraSkipped += skipped; } return skipped; } else if (count <= remaining) { input.setPosition(input.position() + (int) count); return count; } else { input.setPosition(input.limit()); return remaining; } }
/** * Returns if the input has more bytes that Kryo can read. This method will first check if any * bytes are left to read in the Input's internal buffer. If no bytes are left there, will check * the underlying input stream if the amount of available bytes is more than zero. * * @param input * {@link Input} * @return True if there is at least 1 bytes to read, false otherwise. * @throws IOException * If {@link IOException} occurs on the Input's input stream. */ public static boolean hasMoreBytes(Input input) throws IOException { if (input.limit() > input.position()) { return true; } else { return (null != input.getInputStream()) && (input.getInputStream().available() > 0); } } }
@Override public Slice deserialize(Input input) { if (input.getInputStream() != null) { // The input is backed by a stream, cannot directly use its internal buffer try { return new Slice(input.readBytes(input.available())); } catch (IOException ex) { throw Throwables.propagate(ex); } } else { return new Slice(input.getBuffer(), input.position(), input.limit() - input.position()); } } }
try { input.setBuffer(dspair.state.buffer, dspair.state.offset, dspair.state.length); while (input.position() < input.limit()) { ClassIdPair pair = (ClassIdPair)readClassAndObject(input); classResolver.registerExplicit(pair);
@Override public <T> T deserialize(final MessageBufferInput data, final Class<T> clazz) throws IOException { try (Holder k = getKryoHolder()) { final Input input = k.input; input.setBuffer(data.getBuffer(), data.getPosition(), data.getLimit()); final T ret = kryoRunner.doDeserialize(k, input, clazz); data.setPosition(input.position()); // forward to where Kryo finished. return ret; } catch (final KryoException ke) { throw new IOException("Failed to deserialize.", ke); } catch (final IllegalArgumentException e) { // this happens when requiring registration but deserializing an unregistered class throw new IOException("Failed to deserialize. Did you require registration and attempt to deserialize an unregistered class?", e); } }
public void read (Input input, Object object) { try { if (TRACE) trace("kryo", "Read field: " + this + " (" + type.getName() + ")" + " pos=" + input.position()); Object value;
public void read (Input input, Object object) { try { if (TRACE) trace("kryo", "Read field: " + this + " (" + type.getName() + ")" + " pos=" + input.position()); Object value;
public void read (Input input, Object object) { try { if (TRACE) trace("kryo", "Read field: " + this + " (" + type.getName() + ")" + " pos=" + input.position()); Object value;
final public void read (Input input, Object object) { try { if (TRACE) trace("kryo", "Read field: " + this + " (" + type.getName() + ")" + " pos=" + input.position()); Object value;