public final int appendByteArray(byte[] value, int offset, int length) { int copiedOffset = arrayData().appendBytes(length, value, offset); reserve(elementsAppended + 1); putArray(elementsAppended, copiedOffset, length); return elementsAppended++; }
/** * Appends a NULL struct. This *has* to be used for structs instead of appendNull() as this * recursively appends a NULL to its children. * We don't have this logic as the general appendNull implementation to optimize the more * common non-struct case. */ public final int appendStruct(boolean isNull) { if (isNull) { appendNull(); for (WritableColumnVector c: childColumns) { if (c.type instanceof StructType) { c.appendStruct(true); } else { c.appendNull(); } } } else { appendNotNull(); } return elementsAppended; }
private static void appendValue(WritableColumnVector dst, DataType t, Object o) { if (o == null) { if (t instanceof CalendarIntervalType) { dst.appendStruct(true); } else { dst.appendNull(); dst.appendBoolean((Boolean) o); } else if (t == DataTypes.ByteType) { dst.appendByte((Byte) o); } else if (t == DataTypes.ShortType) { dst.appendShort((Short) o); } else if (t == DataTypes.IntegerType) { dst.appendInt((Integer) o); } else if (t == DataTypes.LongType) { dst.appendLong((Long) o); } else if (t == DataTypes.FloatType) { dst.appendFloat((Float) o); } else if (t == DataTypes.DoubleType) { dst.appendDouble((Double) o); } else if (t == DataTypes.StringType) { byte[] b =((String)o).getBytes(StandardCharsets.UTF_8); dst.appendByteArray(b, 0, b.length); } else if (t instanceof DecimalType) { DecimalType dt = (DecimalType) t; Decimal d = Decimal.apply((BigDecimal) o, dt.precision(), dt.scale()); if (dt.precision() <= Decimal.MAX_INT_DIGITS()) { dst.appendInt((int) d.toUnscaledLong()); } else if (dt.precision() <= Decimal.MAX_LONG_DIGITS()) { dst.appendLong(d.toUnscaledLong());
private static void appendValue(WritableColumnVector dst, DataType t, Row src, int fieldIdx) { if (t instanceof ArrayType) { ArrayType at = (ArrayType)t; if (src.isNullAt(fieldIdx)) { dst.appendNull(); } else { List<Object> values = src.getList(fieldIdx); dst.appendArray(values.size()); for (Object o : values) { appendValue(dst.arrayData(), at.elementType(), o); } } } else if (t instanceof StructType) { StructType st = (StructType)t; if (src.isNullAt(fieldIdx)) { dst.appendStruct(true); } else { dst.appendStruct(false); Row c = src.getStruct(fieldIdx); for (int i = 0; i < st.fields().length; i++) { appendValue(dst.getChild(i), st.fields()[i].dataType(), c, i); } } } else { appendValue(dst, t, src.get(fieldIdx)); } }
@Override public int putByteArray(int rowId, byte[] value, int offset, int length) { int result = arrayData().appendBytes(length, value, offset); arrayOffsets[rowId] = result; arrayLengths[rowId] = length; return result; }
private static void appendValue(WritableColumnVector dst, DataType t, Object o) { if (o == null) { if (t instanceof CalendarIntervalType) { dst.appendStruct(true); } else { dst.appendNull(); dst.appendBoolean((Boolean) o); } else if (t == DataTypes.ByteType) { dst.appendByte((Byte) o); } else if (t == DataTypes.ShortType) { dst.appendShort((Short) o); } else if (t == DataTypes.IntegerType) { dst.appendInt((Integer) o); } else if (t == DataTypes.LongType) { dst.appendLong((Long) o); } else if (t == DataTypes.FloatType) { dst.appendFloat((Float) o); } else if (t == DataTypes.DoubleType) { dst.appendDouble((Double) o); } else if (t == DataTypes.StringType) { byte[] b =((String)o).getBytes(StandardCharsets.UTF_8); dst.appendByteArray(b, 0, b.length); } else if (t instanceof DecimalType) { DecimalType dt = (DecimalType) t; Decimal d = Decimal.apply((BigDecimal) o, dt.precision(), dt.scale()); if (dt.precision() <= Decimal.MAX_INT_DIGITS()) { dst.appendInt((int) d.toUnscaledLong()); } else if (dt.precision() <= Decimal.MAX_LONG_DIGITS()) { dst.appendLong(d.toUnscaledLong());
private static void appendValue(WritableColumnVector dst, DataType t, Row src, int fieldIdx) { if (t instanceof ArrayType) { ArrayType at = (ArrayType)t; if (src.isNullAt(fieldIdx)) { dst.appendNull(); } else { List<Object> values = src.getList(fieldIdx); dst.appendArray(values.size()); for (Object o : values) { appendValue(dst.arrayData(), at.elementType(), o); } } } else if (t instanceof StructType) { StructType st = (StructType)t; if (src.isNullAt(fieldIdx)) { dst.appendStruct(true); } else { dst.appendStruct(false); Row c = src.getStruct(fieldIdx); for (int i = 0; i < st.fields().length; i++) { appendValue(dst.getChild(i), st.fields()[i].dataType(), c, i); } } } else { appendValue(dst, t, src.get(fieldIdx)); } }
@Override public int putByteArray(int rowId, byte[] value, int offset, int length) { int result = arrayData().appendBytes(length, value, offset); arrayOffsets[rowId] = result; arrayLengths[rowId] = length; return result; }
public final int appendByteArray(byte[] value, int offset, int length) { int copiedOffset = arrayData().appendBytes(length, value, offset); reserve(elementsAppended + 1); putArray(elementsAppended, copiedOffset, length); return elementsAppended++; }
/** * Appends a NULL struct. This *has* to be used for structs instead of appendNull() as this * recursively appends a NULL to its children. * We don't have this logic as the general appendNull implementation to optimize the more * common non-struct case. */ public final int appendStruct(boolean isNull) { if (isNull) { appendNull(); for (WritableColumnVector c: childColumns) { if (c.type instanceof StructType) { c.appendStruct(true); } else { c.appendNull(); } } } else { appendNotNull(); } return elementsAppended; }
@Override public int putByteArray(int rowId, byte[] value, int offset, int length) { int result = arrayData().appendBytes(length, value, offset); Platform.putInt(null, lengthData + 4L * rowId, length); Platform.putInt(null, offsetData + 4L * rowId, result); return result; }
@Override public int putByteArray(int rowId, byte[] value, int offset, int length) { int result = arrayData().appendBytes(length, value, offset); Platform.putInt(null, lengthData + 4L * rowId, length); Platform.putInt(null, offsetData + 4L * rowId, result); return result; }