Refine search
/** * gets a byte[] with copy of data from source BytesWritable * @param sourceBw - source BytesWritable */ public static byte[] createByteArray(BytesWritable sourceBw){ //TODO should replace with BytesWritable.copyData() once Hive //removes support for the Hadoop 0.20 series. return Arrays.copyOf(sourceBw.getBytes(), sourceBw.getLength()); }
/** * Stores the value for the key in the heap. * @param index The index, either from tryStoreKey or from tryStoreVectorizedKey result. * @param hasCode hashCode of key, used by ptfTopNHash. * @param value The value to store. * @param keyHash The key hash to store. * @param vectorized Whether the result is coming from a vectorized batch. */ public void storeValue(int index, int hashCode, BytesWritable value, boolean vectorized) { values[index] = Arrays.copyOf(value.getBytes(), value.getLength()); // Vectorized doesn't adjust usage for the keys while processing the batch usage += values[index].length + (vectorized ? keys[index].length : 0); }
LazyBinaryBinary(LazyBinaryPrimitive<WritableBinaryObjectInspector, BytesWritable> copy) { super(copy); BytesWritable incoming = copy.getWritableObject(); byte[] outgoing = new byte[incoming.getLength()]; System.arraycopy(incoming.getBytes(), 0, outgoing, 0, incoming.getLength()); data = new BytesWritable(outgoing); }
@Override public List<InputRow> parseBatch(Object input) { if (input instanceof Text) { return ImmutableList.of(parser.parse(((Text) input).toString())); } else if (input instanceof BytesWritable) { BytesWritable valueBytes = (BytesWritable) input; return parser.parseBatch(ByteBuffer.wrap(valueBytes.getBytes(), 0, valueBytes.getLength())); } else { throw new IAE("can't convert type [%s] to InputRow", input.getClass().getName()); } }
@Override public void putRow(BytesWritable currentKey, BytesWritable currentValue) throws HiveException, IOException { // No deserialization of key(s) here -- just get reference to bytes. byte[] keyBytes = currentKey.getBytes(); int keyLength = currentKey.getLength(); add(keyBytes, 0, keyLength, currentValue); }
public BytesWritable evaluate(BytesWritable bw, IntWritable pos, IntWritable len) { if ((bw == null) || (pos == null) || (len == null)) { return null; } if ((len.get() <= 0)) { return new BytesWritable(); } int[] index = makeIndex(pos.get(), len.get(), bw.getLength()); if (index == null) { return new BytesWritable(); } return new BytesWritable(Arrays.copyOfRange(bw.getBytes(), index[0], index[1])); }