@Override public void writeString(Utf8 utf8) throws IOException { writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
@Override public void writeString(Utf8 utf8) throws IOException { this.writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
@Override public void writeString(Utf8 utf8) throws IOException { this.writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
@Override public ByteBuffer readBytes(ByteBuffer old) throws IOException { Symbol actual = parser.advance(Symbol.BYTES); if (actual == Symbol.STRING) { Utf8 s = in.readString(null); return ByteBuffer.wrap(s.getBytes(), 0, s.getByteLength()); } else { assert actual == Symbol.BYTES; return in.readBytes(old); } }
@Override public ByteBuffer readBytes(ByteBuffer old) throws IOException { Symbol actual = parser.advance(Symbol.BYTES); if (actual == Symbol.STRING) { Utf8 s = in.readString(null); return ByteBuffer.wrap(s.getBytes(), 0, s.getByteLength()); } else { assert actual == Symbol.BYTES; return in.readBytes(old); } }
@Override public void writeString(Utf8 utf8) throws IOException { encodeString(utf8.getBytes(), 0, utf8.getByteLength()); }
@Test public void testArrayReusedWhenLargerThanRequestedSize() { byte[] bs = "55555".getBytes(StandardCharsets.UTF_8); Utf8 u = new Utf8(bs); assertEquals(5, u.getByteLength()); byte[] content = u.getBytes(); u.setByteLength(3); assertEquals(3, u.getByteLength()); assertSame(content, u.getBytes()); u.setByteLength(4); assertEquals(4, u.getByteLength()); assertSame(content, u.getBytes()); } }
@Override public void writeString(Utf8 utf8) throws IOException { out.write(utf8.getBytes(), 0, utf8.getByteLength()); }
/** * Strings are encoded by fetching the bytes of the UTF8 encoding, and using * the writeBytes method of this class. * * @param utf8 * The utf8 string to encode. */ @Override public void writeString(Utf8 utf8) throws IOException { writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
/** * Strings are encoded by fetching the bytes of the UTF8 encoding, and using * the writeBytes method of this class. * * @param utf8 * The utf8 string to encode. */ @Override public void writeString(Utf8 utf8) throws IOException { writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
@Override public void writeString(Utf8 utf8) throws IOException { writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
/** * Strings are encoded by fetching the bytes of the UTF8 encoding, and using * the writeBytes method of this class. * * @param utf8 * The utf8 string to encode. */ @Override public void writeString(Utf8 utf8) throws IOException { writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
@Override public void writeString(Utf8 utf8) throws IOException { writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
@Override public void writeString(Utf8 utf8) throws IOException { writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
@Override public void writeString(Utf8 utf8) throws IOException { this.writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
@Override public void writeString(Utf8 utf8) throws IOException { writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
@Override public void writeString(Utf8 utf8) throws IOException { writeBytes(utf8.getBytes(), 0, utf8.getByteLength()); }
private Binary fromAvroString(Object value) { if (value instanceof Utf8) { Utf8 utf8 = (Utf8) value; return Binary.fromReusedByteArray(utf8.getBytes(), 0, utf8.getByteLength()); } return Binary.fromCharSequence((CharSequence) value); }
@Override public ByteBuffer readBytes(ByteBuffer old) throws IOException { Symbol actual = parser.advance(Symbol.BYTES); if (actual == Symbol.STRING) { Utf8 s = in.readString(null); return ByteBuffer.wrap(s.getBytes(), 0, s.getByteLength()); } else { assert actual == Symbol.BYTES; return in.readBytes(old); } }
@Override public void write(int repetitionLevel, CharSequence value) { if (value instanceof Utf8) { Utf8 utf8 = (Utf8) value; column.writeBinary(repetitionLevel, Binary.fromReusedByteArray(utf8.getBytes(), 0, utf8.getByteLength())); } else { column.writeBinary(repetitionLevel, Binary.fromString(value.toString())); } } }