public static ObjectInspector createColumnarStructInspector(List<String> columnNames, List<TypeInfo> columnTypes) { ArrayList<ObjectInspector> columnObjectInspectors = new ArrayList<ObjectInspector>( columnTypes.size()); for (int i = 0; i < columnTypes.size(); i++) { columnObjectInspectors .add(LazyBinaryUtils.getLazyBinaryObjectInspectorFromTypeInfo(columnTypes.get(i))); } return ObjectInspectorFactory.getColumnarStructObjectInspector(columnNames, columnObjectInspectors); } }
@Override public void init(ByteArrayRef bytes, int start, int length) { assert (4 == length); data.set(Float.intBitsToFloat(LazyBinaryUtils.byteArrayToInt(bytes .getData(), start))); } }
@Override public void init(ByteArrayRef bytes, int start, int length) { assert (8 == length); data.set(Double.longBitsToDouble(LazyBinaryUtils.byteArrayToLong(bytes .getData(), start))); } }
public void writeToByteStream(RandomAccessOutput byteStream) { LazyBinaryUtils.writeVLong(byteStream, intervalValue.getTotalSeconds()); LazyBinaryUtils.writeVInt(byteStream, intervalValue.getNanos()); }
final int length = LazyBinaryUtils.byteArrayToInt(bytes, offset); offset += 4; field.end = offset + length; case MAP: LazyBinaryUtils.readVInt(bytes, offset, tempVInt); if (field.category == Category.LIST) { field.count = tempVInt.value;
currentShort = LazyBinaryUtils.byteArrayToShort(bytes, offset); offset += 2; break; LazyBinaryUtils.readVInt(bytes, offset, tempVInt); offset += tempVInt.length; currentInt = tempVInt.value; LazyBinaryUtils.readVLong(bytes, offset, tempVLong); offset += tempVLong.length; currentLong = tempVLong.value; currentFloat = Float.intBitsToFloat(LazyBinaryUtils.byteArrayToInt(bytes, offset)); offset += 4; break; currentDouble = Double.longBitsToDouble(LazyBinaryUtils.byteArrayToLong(bytes, offset)); offset += 8; break; LazyBinaryUtils.readVInt(bytes, offset, tempVInt); offset += tempVInt.length; LazyBinaryUtils.readVInt(bytes, offset, tempVInt); offset += tempVInt.length; LazyBinaryUtils.readVInt(bytes, offset, tempVInt); offset += tempVInt.length;
/** * Write a zero-compressed encoded long to a byte array. * * @param bytes * the byte array/stream * @param l * the long */ public static int writeVLongToByteArray(byte[] bytes, long l) { return LazyBinaryUtils.writeVLongToByteArray(bytes, 0, l); }
public void writeVInt(int value) { LazyBinaryUtils.writeVInt(this, value); }
public short getShort() { assert (2 == fieldLength); return LazyBinaryUtils.byteArrayToShort(fieldBytes, fieldStart); } }
/** * Writes a zero-compressed encoded int to a byte array. * * @param byteStream * the byte array/stream * @param i * the int */ public static void writeVInt(RandomAccessOutput byteStream, int i) { writeVLong(byteStream, i); }
field = LazyBinaryFactory.createLazyBinaryObject(uoi.getObjectInspectors().get(tag)); LazyBinaryUtils.checkObjectByteInfo(uoi.getObjectInspectors().get(tag), byteArr, tagEnd, recordInfo, vInt); fieldStart = tagEnd + recordInfo.elementOffset;
IntObjectInspector ioi = (IntObjectInspector) poi; int v = ioi.get(obj); LazyBinaryUtils.writeVInt(byteStream, v); return; LongObjectInspector loi = (LongObjectInspector) poi; long v = loi.get(obj); LazyBinaryUtils.writeVLong(byteStream, v); return; LazyBinaryUtils.writeDouble(byteStream, doi.get(obj)); return; int length = bw.getLength(); if(!skipLengthPrefix){ LazyBinaryUtils.writeVInt(byteStream, length); } else { if (length == 0){ LazyBinaryUtils.writeVInt(byteStream, size); LazyBinaryUtils.writeVInt(byteStream, size);
LazyBinaryUtils.readVInt(bytes, start, vInt); arraySize = vInt.value; if (0 == arraySize) { if ((bytes[nullByteCur] & (1 << (i % 8))) != 0) { elementIsNull[i] = false; LazyBinaryUtils.checkObjectByteInfo(listEleObjectInspector, bytes, lastElementByteEnd, recordInfo, vInt); elementStart[i] = lastElementByteEnd + recordInfo.elementOffset;
public static void setFromBigIntegerBytesAndScale(byte[] bytes, int offset, int length, HiveDecimalWritable dec) { LazyBinaryUtils.VInt vInt = new LazyBinaryUtils.VInt(); LazyBinaryUtils.readVInt(bytes, offset, vInt); int scale = vInt.value; offset += vInt.length; LazyBinaryUtils.readVInt(bytes, offset, vInt); offset += vInt.length; dec.setFromBigIntegerBytesAndScale(bytes, offset, vInt.value, scale); }
@Override public void init(ByteArrayRef bytes, int start, int length) { LazyBinaryUtils.readVLong(bytes.getData(), start, vLong); assert (length == vLong.length); data.set(vLong.value); } }
currentShort = LazyBinaryUtils.byteArrayToShort(bytes, offset); offset += 2; break; LazyBinaryUtils.readVInt(bytes, offset, tempVInt); offset += tempVInt.length; currentInt = tempVInt.value; LazyBinaryUtils.readVLong(bytes, offset, tempVLong); offset += tempVLong.length; currentLong = tempVLong.value; currentFloat = Float.intBitsToFloat(LazyBinaryUtils.byteArrayToInt(bytes, offset)); offset += 4; break; currentDouble = Double.longBitsToDouble(LazyBinaryUtils.byteArrayToLong(bytes, offset)); offset += 8; break; LazyBinaryUtils.readVInt(bytes, offset, tempVInt); offset += tempVInt.length; LazyBinaryUtils.readVInt(bytes, offset, tempVInt); offset += tempVInt.length; LazyBinaryUtils.readVInt(bytes, offset, tempVInt); offset += tempVInt.length;
/** * Given an integer representing nanoseconds, write its serialized * value to the byte array b at offset * * @param nanos * @param b * @param offset * @return */ private static boolean setNanosBytes(int nanos, byte[] b, int offset, boolean hasSecondVInt) { int decimal = 0; if (nanos != 0) { int counter = 0; while (counter < 9) { decimal *= 10; decimal += nanos % 10; nanos /= 10; counter++; } } if (hasSecondVInt || decimal != 0) { // We use the sign of the reversed-nanoseconds field to indicate that there is a second VInt // present. LazyBinaryUtils.writeVLongToByteArray(b, offset, hasSecondVInt ? (-decimal - 1) : decimal); } return decimal != 0; }
@Override void serialize(RandomAccessOutput byteStream, Object obj, ObjectInspector objInspector, boolean skipLengthPrefix, BooleanRef warnedOnceNullMapKey) { IntObjectInspector ioi = (IntObjectInspector) objInspector; int v = ioi.get(obj); LazyBinaryUtils.writeVInt(byteStream, v); } }