@Override public void setItemCount(long itemCount) throws IOException { super.setItemCount(itemCount); out.setItemCount(itemCount); }
BinaryDecoder configure(byte[] data, int offset, int length) { configureSource(DecoderFactory.DEFAULT_BUFFER_SIZE, new ByteArrayByteSource( data, offset, length)); return this; }
/** * Writes given record using specified schema. * @param record record to serialize * @param schema schema to use for serialization * @return serialized record */ public static byte[] writeRecord(GenericRecord record, Schema schema) throws IOException { ByteArrayOutputStream stream = new ByteArrayOutputStream(); BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(stream, null); new GenericDatumWriter<>(schema).write(record, encoder); encoder.flush(); return stream.toByteArray(); } }
@Override public void readExternal(java.io.ObjectInput in) throws java.io.IOException { READER$.read(this, org.apache.avro.specific.SpecificData.getDecoder(in)); }
private void ensureBounds(int l) throws IOException { while (buf.length < (pos + l)) { if (blockStack[stackTop].state == BlockedValue.State.REGULAR) { compact(); } else { super.writeFixed(buf, 0, pos); pos = 0; } } }
@Override protected Decoder getDecoder() throws IOException { return new ResolvingDecoder(schema, readerSchema, super.getDecoder()); } @Override
@Override public void writeLong(long n) throws IOException { ensureBounds(10); pos += BinaryData.encodeLong(n, buf, pos); }
@Override public void writeInt(int n) throws IOException { ensureBounds(5); pos += BinaryData.encodeInt(n, buf, pos); }
@Override public void writeBoolean(boolean b) throws IOException { ensureBounds(1); pos += BinaryData.encodeBoolean(b, buf, pos); }
@Override public void writeDouble(double d) throws IOException { ensureBounds(8); pos += BinaryData.encodeDouble(d, buf, pos); }
@Override public void writeIndex(int unionIndex) throws IOException { ensureBounds(5); pos += BinaryData.encodeInt(unionIndex, buf, pos); }
@Override public void writeFloat(float f) throws IOException { ensureBounds(4); pos += BinaryData.encodeFloat(f, buf, pos); }
@Override protected Decoder getDecoder() throws IOException { return new ValidatingDecoder(schema, super.getDecoder()); } @Override
@Override void genSourceData() { Random r = newRandom(); sourceData = new Object[count]; for (int i = 0; i < sourceData.length; i++) { sourceData[i] = genSingleRecord(r); } reuse = genSingleRecord(r); }
@Override public void readExternal(java.io.ObjectInput in) throws java.io.IOException { READER$.read(this, SpecificData.getDecoder(in)); }
@Override public void readExternal(java.io.ObjectInput in) throws java.io.IOException { READER$.read(this, org.apache.avro.specific.SpecificData.getDecoder(in)); }