public void writeVInt(int value) { LazyBinaryUtils.writeVInt(this, value); }
@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); } }
protected static void serializeText( RandomAccessOutput byteStream, Text t, boolean skipLengthPrefix) { /* write byte size of the string which is a vint */ int length = t.getLength(); if (!skipLengthPrefix) { LazyBinaryUtils.writeVInt(byteStream, length); } /* write string itself */ byte[] data = t.getBytes(); byteStream.write(data, 0, length); }
public void writeToByteStream(RandomAccessOutput byteStream) { LazyBinaryUtils.writeVInt(byteStream, intervalValue.getTotalMonths()); }
public static void writeDateToByteStream(RandomAccessOutput byteStream, DateWritableV2 date) { LazyBinaryUtils.writeVInt(byteStream, date.getDays()); }
public static void writeToByteStream(RandomAccessOutput byteStream, HiveDecimalWritable decWritable) { LazyBinaryUtils.writeVInt(byteStream, decWritable.scale()); // NOTE: This writes into a scratch buffer within HiveDecimalWritable. // int byteLength = decWritable.bigIntegerBytesInternalScratch(); LazyBinaryUtils.writeVInt(byteStream, byteLength); byteStream.write(decWritable.bigIntegerBytesInternalScratchBuffer(), 0, byteLength); }
/** * * Allocate scratchLongs with HiveDecimal.SCRATCH_LONGS_LEN longs. * And, allocate scratch buffer with HiveDecimal.SCRATCH_BUFFER_LEN_BIG_INTEGER_BYTES bytes. * * @param byteStream * @param decWritable * @param scratchLongs * @param scratchBytes */ public static void writeToByteStream( RandomAccessOutput byteStream, HiveDecimalWritable decWritable, long[] scratchLongs, byte[] scratchBytes) { LazyBinaryUtils.writeVInt(byteStream, decWritable.scale()); int byteLength = decWritable.bigIntegerBytes( scratchLongs, scratchBytes); LazyBinaryUtils.writeVInt(byteStream, byteLength); byteStream.write(scratchBytes, 0, byteLength); }
/** * * Allocate scratchLongs with HiveDecimal.SCRATCH_LONGS_LEN longs. * And, allocate scratch buffer with HiveDecimal.SCRATCH_BUFFER_LEN_BIG_INTEGER_BYTES bytes. * * @param byteStream * @param dec * @param scratchLongs * @param scratchBytes */ public static void writeToByteStream( RandomAccessOutput byteStream, HiveDecimal dec, long[] scratchLongs, byte[] scratchBytes) { LazyBinaryUtils.writeVInt(byteStream, dec.scale()); // Convert decimal into the scratch buffer without allocating a byte[] each time // for better performance. int byteLength = dec.bigIntegerBytes( scratchLongs, scratchBytes); if (byteLength == 0) { throw new RuntimeException("Decimal to binary conversion failed"); } LazyBinaryUtils.writeVInt(byteStream, byteLength); byteStream.write(scratchBytes, 0, byteLength); }
@Override void serialize(RandomAccessOutput byteStream, Object obj, ObjectInspector objInspector, boolean skipLengthPrefix, BooleanRef warnedOnceNullMapKey) { BinaryObjectInspector baoi = (BinaryObjectInspector) objInspector; BytesWritable bw = baoi.getPrimitiveWritableObject(obj); int length = bw.getLength(); if(!skipLengthPrefix){ LazyBinaryUtils.writeVInt(byteStream, length); } else { if (length == 0){ throw new RuntimeException("LazyBinaryColumnarSerde cannot serialize a non-null zero " + "length binary field. Consider using either LazyBinarySerde or ColumnarSerde."); } } byteStream.write(bw.getBytes(),0,length); } }
public void writeToByteStream(RandomAccessOutput byteStream) { LazyBinaryUtils.writeVLong(byteStream, intervalValue.getTotalSeconds()); LazyBinaryUtils.writeVInt(byteStream, intervalValue.getNanos()); }
LazyBinaryUtils.writeVInt(output, size);
@Override public void beginList(List list) { final Field current = new Field(LIST); beginComplex(current); final int size = list.size(); current.fieldCount = size; if (!skipLengthPrefix) { // 1/ reserve spaces for the byte size of the list // which is a integer and takes four bytes current.byteSizeStart = output.getLength(); output.reserve(4); current.start = output.getLength(); } // 2/ write the size of the list as a VInt LazyBinaryUtils.writeVInt(output, size); // 3/ write the null bytes byte nullByte = 0; for (int eid = 0; eid < size; eid++) { // set the bit to 1 if an element is not null if (null != list.get(eid)) { nullByte |= 1 << (eid % 8); } // store the byte every eight elements or // if this is the last element if (7 == eid % 8 || eid == size - 1) { output.write(nullByte); nullByte = 0; } } }
LazyBinaryUtils.writeVInt(byteStream, size);
LazyBinaryUtils.writeVInt(byteStream, size);
IntObjectInspector ioi = (IntObjectInspector) poi; int v = ioi.get(obj); LazyBinaryUtils.writeVInt(byteStream, v); return; int length = bw.getLength(); if(!skipLengthPrefix){ LazyBinaryUtils.writeVInt(byteStream, length); } else { if (length == 0){ LazyBinaryUtils.writeVInt(byteStream, size); LazyBinaryUtils.writeVInt(byteStream, size);
protected static void serializeText( RandomAccessOutput byteStream, Text t, boolean skipLengthPrefix) { /* write byte size of the string which is a vint */ int length = t.getLength(); if (!skipLengthPrefix) { LazyBinaryUtils.writeVInt(byteStream, length); } /* write string itself */ byte[] data = t.getBytes(); byteStream.write(data, 0, length); }
private static void serializeText( RandomAccessOutput byteStream, Text t, boolean skipLengthPrefix) { /* write byte size of the string which is a vint */ int length = t.getLength(); if (!skipLengthPrefix) { LazyBinaryUtils.writeVInt(byteStream, length); } /* write string itself */ byte[] data = t.getBytes(); byteStream.write(data, 0, length); }
public static void writeToByteStream(Decimal128 dec, Output byteStream) { HiveDecimal hd = HiveDecimal.create(dec.toBigDecimal()); LazyBinaryUtils.writeVInt(byteStream, hd.scale()); byte[] bytes = hd.unscaledValue().toByteArray(); LazyBinaryUtils.writeVInt(byteStream, bytes.length); byteStream.write(bytes, 0, bytes.length); }
public static void writeToByteStream(Decimal128 dec, Output byteStream) { HiveDecimal hd = HiveDecimal.create(dec.toBigDecimal()); LazyBinaryUtils.writeVInt(byteStream, hd.scale()); byte[] bytes = hd.unscaledValue().toByteArray(); LazyBinaryUtils.writeVInt(byteStream, bytes.length); byteStream.write(bytes, 0, bytes.length); }