@Override public int readInt() throws IOException { if (bufferIter.hasNext()) { LongObjectInspector loi = PrimitiveObjectInspectorFactory.writableLongObjectInspector; Long l = PrimitiveObjectInspectorUtils.getLong(bufferIter.next(), loi); return l.intValue(); //return bufferIter.next().intValue(); } else { throw new IOException(); } }
@Override public long readLong() throws IOException { //LongObjectInspector loi = PrimitiveObjectInspectorFactory.writableLongObjectInspector; if (bufferIter.hasNext()) { LongObjectInspector loi = PrimitiveObjectInspectorFactory.writableLongObjectInspector; return PrimitiveObjectInspectorUtils.getLong(bufferIter.next(), loi); //return bufferIter.next(); } else { throw new IOException(); } }
@Override public boolean isEqual(Object v1, Object v2) { if (v1 != null && v2 != null) { long l1 = PrimitiveObjectInspectorUtils.getLong(v1, (PrimitiveObjectInspector) expressionDef.getOI()); long l2 = PrimitiveObjectInspectorUtils.getLong(v2, (PrimitiveObjectInspector) expressionDef.getOI()); return l1 == l2; } return v1 == null && v2 == null; // True if both are null } }
@Override public boolean isDistanceGreater(Object v1, Object v2, int amt) { if (v1 != null && v2 != null) { long l1 = PrimitiveObjectInspectorUtils.getLong(v1, (PrimitiveObjectInspector) expressionDef.getOI()); long l2 = PrimitiveObjectInspectorUtils.getLong(v2, (PrimitiveObjectInspector) expressionDef.getOI()); return (l1 -l2) > amt; } return v1 != null || v2 != null; // True if only one value is null }
@Override public Object convert(Object input) { if (input == null) { return null; } try { return outputOI.set(r, PrimitiveObjectInspectorUtils.getLong(input, inputOI)); } catch (NumberFormatException e) { return null; } } }
@Override public boolean isEqual(Object v1, Object v2) { if (v1 != null && v2 != null) { long l1 = PrimitiveObjectInspectorUtils.getLong(v1, (PrimitiveObjectInspector) expressionDef.getOI()); long l2 = PrimitiveObjectInspectorUtils.getLong(v2, (PrimitiveObjectInspector) expressionDef.getOI()); return l1 == l2; } return v1 == null && v2 == null; // True if both are null } }
@Override protected void update(Object p, PrimitiveObjectInspector inputOI) { long v = PrimitiveObjectInspectorUtils.getLong(p, inputOI); //Update min counter if new value is less than min seen so far if (min == null || v < min) { min = v; } //Update max counter if new value is greater than max seen so far if (max == null || v > max) { max = v; } // Add value to NumDistinctValue Estimator numDV.addToEstimator(v); }
@Override public boolean isDistanceGreater(Object v1, Object v2, int amt) { if (v1 != null && v2 != null) { long l1 = PrimitiveObjectInspectorUtils.getLong(v1, (PrimitiveObjectInspector) expressionDef.getOI()); long l2 = PrimitiveObjectInspectorUtils.getLong(v2, (PrimitiveObjectInspector) expressionDef.getOI()); return (l1 -l2) > amt; } return v1 != null || v2 != null; // True if only one value is null }
@Override protected void update(Object p, PrimitiveObjectInspector inputOI) { long v = PrimitiveObjectInspectorUtils.getLong(p, inputOI); //Update min counter if new value is less than min seen so far if (min == null || v < min) { min = v; } //Update max counter if new value is greater than max seen so far if (max == null || v > max) { max = v; } // Add value to NumDistinctValue Estimator numDV.addToEstimator(v); }
@Override public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException { assert (parameters.length == 1); try { if (isEligibleValue((SumLongAgg) agg, parameters[0])) { ((SumLongAgg)agg).empty = false; ((SumLongAgg)agg).sum += PrimitiveObjectInspectorUtils.getLong(parameters[0], inputOI); } } catch (NumberFormatException e) { if (!warned) { warned = true; LOG.warn(getClass().getSimpleName() + " " + StringUtils.stringifyException(e)); } } }
@Override public void merge(AggregationBuffer agg, Object partial) throws HiveException { if (partial != null) { SumLongAgg myagg = (SumLongAgg) agg; myagg.empty = false; if (isWindowingDistinct()) { throw new HiveException("Distinct windowing UDAF doesn't support merge and terminatePartial"); } else { myagg.sum += PrimitiveObjectInspectorUtils.getLong(partial, inputOI); } } }
@Override public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException { assert (parameters.length == 1); try { if (isEligibleValue((SumLongAgg) agg, parameters[0])) { ((SumLongAgg)agg).empty = false; ((SumLongAgg)agg).sum += PrimitiveObjectInspectorUtils.getLong(parameters[0], inputOI); } } catch (NumberFormatException e) { if (!warned) { warned = true; LOG.warn(getClass().getSimpleName() + " " + StringUtils.stringifyException(e)); } } }
@Override public void merge(AggregationBuffer agg, Object partial) throws HiveException { if (partial != null) { SumLongAgg myagg = (SumLongAgg) agg; myagg.empty = false; if (isWindowingDistinct()) { throw new HiveException("Distinct windowing UDAF doesn't support merge and terminatePartial"); } else { myagg.sum += PrimitiveObjectInspectorUtils.getLong(partial, inputOI); } } }
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { // groupingId = PrimitiveObjectInspectorUtils.getInt(arguments[0].get(), groupingIdOI); // Check that the bit at the given index is '1' or '0' long result = 0; // grouping(c1, c2, c3) // is equivalent to // 4 * grouping(c1) + 2 * grouping(c2) + grouping(c3) for (int a = 1; a < arguments.length; a++) { result += LongMath.pow(2, indices.length - a) * ((PrimitiveObjectInspectorUtils.getLong(arguments[0].get(), groupingIdOI) >> indices[a - 1]) & 1); } longWritable.set(result); return longWritable; }
protected EWAHCompressedBitmap wordArrayToBitmap(Object b) { ListObjectInspector lloi = (ListObjectInspector) b1OI; int length = lloi.getListLength(b); ArrayList<LongWritable> bitmapArray = new ArrayList<LongWritable>(); for (int i = 0; i < length; i++) { long l = PrimitiveObjectInspectorUtils.getLong( lloi.getListElement(b, i), (PrimitiveObjectInspector) lloi.getListElementObjectInspector()); bitmapArray.add(new LongWritable(l)); } BitmapObjectInput bitmapObjIn = new BitmapObjectInput(bitmapArray); EWAHCompressedBitmap bitmap = new EWAHCompressedBitmap(); try { bitmap.readExternal(bitmapObjIn); } catch (IOException e) { throw new RuntimeException(e); } return bitmap; }
Object timestamp = data.get(firstMetadataColumnIndex + 3); if (PrimitiveObjectInspectorUtils.getLong(offset, MetadataColumn.OFFSET.getObjectInspector()) != -1) { LOG.error("Can not insert values into `__offset` column, has to be [-1]"); throw new SerDeException("Can not insert values into `__offset` column, has to be [-1]"); timestamp == null ? -1 : PrimitiveObjectInspectorUtils.getLong(timestamp, MetadataColumn.TIMESTAMP.getObjectInspector()); final int recordPartition =
@Override public void evaluate(VectorizedRowBatch batch) throws HiveException { if (!initialized) { Object lVal = leftDynamicValue.getValue(); Object rVal = rightDynamicValue.getValue(); if (lVal == null || rVal == null) { isLeftOrRightNull = true; } else { long min = (PrimitiveObjectInspectorUtils.getLong( lVal, leftDynamicValue.getObjectInspector())); setLeftValue(min); long max = (PrimitiveObjectInspectorUtils.getLong( rVal, rightDynamicValue.getObjectInspector())); setRightValue(max); } initialized = true; } // Special case for dynamic values - min/max can be null if (isLeftOrRightNull) { // Entire batch is filtered out batch.size = 0; } super.evaluate(batch); } }
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { assert (arguments.length == 1); Object b = arguments[0].get(); ListObjectInspector lloi = (ListObjectInspector) bitmapOI; int length = lloi.getListLength(b); ArrayList<LongWritable> bitmapArray = new ArrayList<LongWritable>(); for (int i = 0; i < length; i++) { long l = PrimitiveObjectInspectorUtils.getLong( lloi.getListElement(b, i), (PrimitiveObjectInspector) lloi.getListElementObjectInspector()); bitmapArray.add(new LongWritable(l)); } BitmapObjectInput bitmapObjIn = new BitmapObjectInput(bitmapArray); EWAHCompressedBitmap bitmap = new EWAHCompressedBitmap(); try { bitmap.readExternal(bitmapObjIn); } catch (IOException e) { throw new RuntimeException(e); } // Add return true only if bitmap is all zeros. return new BooleanWritable(!bitmap.iterator().hasNext()); }
@Override public void evaluate(VectorizedRowBatch batch) { if (!initialized) { Object lVal = leftDynamicValue.getValue(); Object rVal = rightDynamicValue.getValue(); if (lVal == null || rVal == null) { isLeftOrRightNull = true; } else { long min = (PrimitiveObjectInspectorUtils.getLong( lVal, leftDynamicValue.getObjectInspector())); setLeftValue(min); long max = (PrimitiveObjectInspectorUtils.getLong( rVal, rightDynamicValue.getObjectInspector())); setRightValue(max); } initialized = true; } // Special case for dynamic values - min/max can be null if (isLeftOrRightNull) { // Entire batch is filtered out batch.size = 0; } super.evaluate(batch); } }
case INT: case LONG: longValue = PrimitiveObjectInspectorUtils.getLong(val, poi); break; case FLOAT: