@Test public void testBinary() { BinaryArray array = new BinaryArray(); BinaryArrayWriter writer = new BinaryArrayWriter(array, 2, 8); byte[] bytes1 = new byte[] {1, -1, 5}; byte[] bytes2 = new byte[] {1, -1, 5, 5, 1, 5, 1, 5}; writer.writeBinary(0, bytes1); writer.writeBinary(1, bytes2); writer.complete(); Assert.assertArrayEquals(bytes1, array.getBinary(0)); Assert.assertArrayEquals(bytes2, array.getBinary(1)); }
@Override public byte[] getBinary(int pos) { assertIndexIsValid(pos); int fieldOffset = getElementOffset(pos, 8); final long offsetAndSize = SegmentsUtil.getLong(segments, fieldOffset); return readBinaryFieldFromSegments( segments, offset, fieldOffset, offsetAndSize); }
BinaryArray extends BinaryFormat implements BaseArray { @Override public byte[] getBinary(int pos) { assertIndexIsValid(pos); int fieldOffset = getElementOffset(pos, 8); final long offsetAndSize = SegmentsUtil.getLong(segments, fieldOffset); return readBinaryFieldFromSegments( segments, offset, fieldOffset, offsetAndSize); } }
BinaryArray extends BinaryFormat implements BaseArray { @Override public byte[] getBinary(int pos) { assertIndexIsValid(pos); int fieldOffset = getElementOffset(pos, 8); final long offsetAndSize = SegmentsUtil.getLong(segments, fieldOffset); return readBinaryFieldFromSegments( segments, offset, fieldOffset, offsetAndSize); } BinaryArray(); }
BinaryArray extends BinaryFormat implements BaseArray { @Override public byte[] getBinary(int pos) { assertIndexIsValid(pos); int fieldOffset = getElementOffset(pos, 8); final long offsetAndSize = SegmentsUtil.getLong(segments, fieldOffset); return readBinaryFieldFromSegments( segments, offset, fieldOffset, offsetAndSize); } BinaryArray(); static int calculateHeaderInBytes(int numFields); static int calculateFixLengthPartSize(LogicalType type); @Override int numElements(); @Override void pointTo(MemorySegment[] segments, int offset, int sizeInBytes); @Override boolean isNullAt(int pos); @Override void setNullAt(int pos); @Override void setNotNullAt(int pos); @Override long getLong(int pos); @Override void setLong(int pos, long value); @Override void setNullLong(int pos); @Override int getInt(int pos); @Override void setInt(int pos, int value); @Override void setNullInt(int pos); @Override BinaryString getString(int pos); @Override Decimal getDecimal(int pos, int precision, int scale); @Override BinaryGeneric<T> getGeneric(int pos); @Override byte[] getBinary(int pos); @Override BaseArray getArray(int pos); @Override BaseMap getMap(int pos); @Override BaseRow getRow(int pos, int numFields); @Override boolean getBoolean(int pos); @Override void setBoolean(int pos, boolean value); @Override void setNullBoolean(int pos); @Override byte getByte(int pos); @Override void setByte(int pos, byte value); @Override void setNullByte(int pos); @Override short getShort(int pos); @Override void setShort(int pos, short value); @Override void setNullShort(int pos); @Override float getFloat(int pos); @Override void setFloat(int pos, float value); @Override void setNullFloat(int pos); @Override double getDouble(int pos); @Override void setDouble(int pos, double value); @Override void setNullDouble(int pos); @Override void setDecimal(int pos, Decimal value, int precision); boolean anyNull(); @Override boolean[] toBooleanArray(); @Override byte[] toByteArray(); @Override short[] toShortArray(); @Override int[] toIntArray(); @Override long[] toLongArray(); @Override float[] toFloatArray(); @Override double[] toDoubleArray(); T[] toClassArray(LogicalType elementType, Class<T> elementClass); BinaryArray copy(); BinaryArray copy(BinaryArray reuse); @Override int hashCode(); static BinaryArray fromPrimitiveArray(boolean[] arr); static BinaryArray fromPrimitiveArray(byte[] arr); static BinaryArray fromPrimitiveArray(short[] arr); static BinaryArray fromPrimitiveArray(int[] arr); static BinaryArray fromPrimitiveArray(long[] arr); static BinaryArray fromPrimitiveArray(float[] arr); static BinaryArray fromPrimitiveArray(double[] arr); }
BinaryArray extends BinaryFormat implements BaseArray { @Override public byte[] getBinary(int pos) { assertIndexIsValid(pos); int fieldOffset = getElementOffset(pos, 8); final long offsetAndSize = SegmentsUtil.getLong(segments, fieldOffset); return readBinaryFieldFromSegments( segments, offset, fieldOffset, offsetAndSize); } BinaryArray(); static int calculateHeaderInBytes(int numFields); static int calculateFixLengthPartSize(LogicalType type); @Override int numElements(); @Override void pointTo(MemorySegment[] segments, int offset, int sizeInBytes); @Override boolean isNullAt(int pos); @Override void setNullAt(int pos); @Override void setNotNullAt(int pos); @Override long getLong(int pos); @Override void setLong(int pos, long value); @Override void setNullLong(int pos); @Override int getInt(int pos); @Override void setInt(int pos, int value); @Override void setNullInt(int pos); @Override BinaryString getString(int pos); @Override Decimal getDecimal(int pos, int precision, int scale); @Override BinaryGeneric<T> getGeneric(int pos); @Override byte[] getBinary(int pos); @Override BaseArray getArray(int pos); @Override BaseMap getMap(int pos); @Override BaseRow getRow(int pos, int numFields); @Override boolean getBoolean(int pos); @Override void setBoolean(int pos, boolean value); @Override void setNullBoolean(int pos); @Override byte getByte(int pos); @Override void setByte(int pos, byte value); @Override void setNullByte(int pos); @Override short getShort(int pos); @Override void setShort(int pos, short value); @Override void setNullShort(int pos); @Override float getFloat(int pos); @Override void setFloat(int pos, float value); @Override void setNullFloat(int pos); @Override double getDouble(int pos); @Override void setDouble(int pos, double value); @Override void setNullDouble(int pos); @Override void setDecimal(int pos, Decimal value, int precision); boolean anyNull(); @Override boolean[] toBooleanArray(); @Override byte[] toByteArray(); @Override short[] toShortArray(); @Override int[] toIntArray(); @Override long[] toLongArray(); @Override float[] toFloatArray(); @Override double[] toDoubleArray(); T[] toClassArray(LogicalType elementType, Class<T> elementClass); BinaryArray copy(); BinaryArray copy(BinaryArray reuse); @Override int hashCode(); static BinaryArray fromPrimitiveArray(boolean[] arr); static BinaryArray fromPrimitiveArray(byte[] arr); static BinaryArray fromPrimitiveArray(short[] arr); static BinaryArray fromPrimitiveArray(int[] arr); static BinaryArray fromPrimitiveArray(long[] arr); static BinaryArray fromPrimitiveArray(float[] arr); static BinaryArray fromPrimitiveArray(double[] arr);  }