@Override public void writeBoolean(boolean v) throws IOException { write(v ? 1 : 0); }
@Override public void writeShort(int v) throws IOException { if (this.position >= this.buffer.length - 1) { resize(2); } this.buffer[this.position++] = (byte) ((v >>> 8) & 0xff); this.buffer[this.position++] = (byte) ((v >>> 0) & 0xff); }
int numElements = 100; TestDataOutputSerializer target = new TestDataOutputSerializer(5*numElements, 5*numElements); KryoSerializer<Integer> serializer = new KryoSerializer<>(Integer.class, new ExecutionConfig()); ComparatorTestBase.TestInputView source = new ComparatorTestBase.TestInputView(target.copyByteBuffer());
@Override public void writeDouble(double v) throws IOException { writeLong(Double.doubleToLongBits(v)); }
@Override public void writeFloat(float v) throws IOException { writeInt(Float.floatToIntBits(v)); }
TestDataOutputSerializer target = new TestDataOutputSerializer(10000, 30000); KryoSerializer<String> serializer = new KryoSerializer<String>(String.class, new ExecutionConfig());
@Override public void write(int b) throws IOException { if (this.position >= this.buffer.length) { resize(1); } this.buffer[this.position++] = (byte) (b & 0xff); }
@Override public void writeChar(int v) throws IOException { if (this.position >= this.buffer.length - 1) { resize(2); } this.buffer[this.position++] = (byte) (v >> 8); this.buffer[this.position++] = (byte) v; }
@Override public void write(byte[] b) throws IOException { write(b, 0, b.length); }
@SuppressWarnings("restriction") @Override public void writeLong(long v) throws IOException { if (this.position >= this.buffer.length - 7) { resize(8); } if (LITTLE_ENDIAN) { v = Long.reverseBytes(v); } UNSAFE.putLong(this.buffer, BASE_OFFSET + this.position, v); this.position += 8; }
@Override public void writeByte(int v) throws IOException { write(v); }
@Override public void write(byte[] b, int off, int len) throws IOException { if (len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } if (this.position > this.buffer.length - len) { resize(len); } System.arraycopy(b, off, this.buffer, this.position, len); this.position += len; }
@SuppressWarnings("restriction") @Override public void writeInt(int v) throws IOException { if (this.position >= this.buffer.length - 3) { resize(4); } if (LITTLE_ENDIAN) { v = Integer.reverseBytes(v); } UNSAFE.putInt(this.buffer, BASE_OFFSET + this.position, v); this.position += 4; }
resize(utflen + 2);