@Override public void close() throws IOException { is.close(); } }
/** * Writes raw bytes to the buffer without encoding. Same as calling * * {@link #writeRaw(byte[], int, int) writeRaw(rawBytes, 0, rawBytes.length)}. */ public Encoder writeRaw(byte[] rawBytes) throws IOException { return writeRaw(rawBytes, 0, rawBytes.length); }
/** * Encodes the beginning of an array. This method will encode with the size of the array. * Sub-class can override this to have different behavior * * @param encoder The encoder to use * @param elementSchema The {@link Schema} of the array element * @param size Number of array elements * @throws IOException If failed to encode */ protected void encodeArrayBegin(Encoder encoder, Schema elementSchema, int size) throws IOException { encoder.writeInt(size); }
@Override public Encoder apply(OutputStream input) { return new BinaryEncoder(input); } };
@Override public Encoder writeBytes(ByteBuffer bytes) throws IOException { return encoder.writeBytes(bytes); } }
@Override public Encoder writeBool(boolean b) throws IOException { return encoder.writeBool(b); }
@Override protected boolean readBool(Decoder decoder) throws IOException { return decoder.readBool(); }
@Override protected long readLong(Decoder decoder) throws IOException { return decoder.readLong(); }
@Override public void skipDouble() throws IOException { // Skip 8 bytes skipBytes(8L); }
@Override public boolean readBool() throws IOException { return readByte() == 1; }
/** * Encodes the ending of an array. This method writes out {@code 0} to signal the end of the array. * Sub-class can override this to have different behavior * * @param encoder The encoder to use * @param elementSchema The {@link Schema} of the array element * @param size Number of array elements * @throws IOException If failed to encode */ protected void encodeArrayEnd(Encoder encoder, Schema elementSchema, int size) throws IOException { encoder.writeInt(0); }
@Override public Encoder writeBytes(ByteBuffer bytes) throws IOException { return encoder.writeBytes(bytes); } }
@Override public void close() throws IOException { is.close(); } }
/** * Writes raw bytes to the buffer without encoding. Same as calling * * {@link #writeRaw(byte[], int, int) writeRaw(rawBytes, 0, rawBytes.length)}. */ public Encoder writeRaw(byte[] rawBytes) throws IOException { return writeRaw(rawBytes, 0, rawBytes.length); }
@Override public void skipFloat() throws IOException { // Skip 4 bytes skipBytes(4L); }
/** * Encodes the beginning of an array. This method will encode with the size of the array. * Sub-class can override this to have different behavior * * @param encoder The encoder to use * @param elementSchema The {@link Schema} of the array element * @param size Number of array elements * @throws IOException If failed to encode */ protected void encodeArrayBegin(Encoder encoder, Schema elementSchema, int size) throws IOException { encoder.writeInt(size); }
@Override public Encoder writeBytes(byte[] bytes, int off, int len) throws IOException { return encoder.writeBytes(bytes, off, len); }
@Override public void skipDouble() throws IOException { // Skip 8 bytes skipBytes(8L); }
/** * Encodes the ending of an array. This method writes out {@code 0} to signal the end of the array. * Sub-class can override this to have different behavior * * @param encoder The encoder to use * @param elementSchema The {@link Schema} of the array element * @param size Number of array elements * @throws IOException If failed to encode */ protected void encodeArrayEnd(Encoder encoder, Schema elementSchema, int size) throws IOException { encoder.writeInt(0); }
@Override public void skipFloat() throws IOException { // Skip 4 bytes skipBytes(4L); }