public static Timestamp getTimestamp(Object o, PrimitiveObjectInspector oi) { return getTimestamp(o, oi, false); }
public Object convert(Object input) { if (input == null) { return null; } return outputOI.set(r, PrimitiveObjectInspectorUtils.getTimestamp(input, inputOI, intToTimestampInSeconds)); } }
@Override public boolean isEqual(Object v1, Object v2) { if (v1 != null && v2 != null) { Timestamp l1 = PrimitiveObjectInspectorUtils.getTimestamp(v1, (PrimitiveObjectInspector) expressionDef.getOI()); Timestamp l2 = PrimitiveObjectInspectorUtils.getTimestamp(v2, (PrimitiveObjectInspector) expressionDef.getOI()); return l1.equals(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.getTimestamp(v1, (PrimitiveObjectInspector) expressionDef.getOI()).toEpochMilli(); long l2 = PrimitiveObjectInspectorUtils.getTimestamp(v2, (PrimitiveObjectInspector) expressionDef.getOI()).toEpochMilli(); return (double)(l1-l2)/1000 > amt; // TODO: lossy conversion, distance is considered in seconds } return v1 != null || v2 != null; // True if only one value is null }
} else { PrimitiveObjectInspector primitive = (PrimitiveObjectInspector) inspector; timestamp = PrimitiveObjectInspectorUtils.getTimestamp(value, primitive).toEpochMilli();
static long getTimestampVal(IndexSearchCondition sc) throws IOException { long timestamp; try { ExprNodeConstantEvaluator eval = new ExprNodeConstantEvaluator(sc.getConstantDesc()); ObjectInspector inspector = eval.initialize(null); Object value = eval.evaluate(null); if (inspector instanceof LongObjectInspector) { timestamp = ((LongObjectInspector) inspector).get(value); } else { PrimitiveObjectInspector primitive = (PrimitiveObjectInspector) inspector; timestamp = PrimitiveObjectInspectorUtils.getTimestamp(value, primitive).toEpochMilli(); } } catch (HiveException e) { throw new IOException(e); } return timestamp; }
/** * Evaluate the GenericUDF with the arguments. * * @param arguments timestamp and interval. * * @return The truncated timestamp to the beginning of tumbled window interval. */ @Override public Object evaluate(DeferredObject[] arguments) throws HiveException { if (arguments[0] == null) { return null; } Timestamp ts = PrimitiveObjectInspectorUtils.getTimestamp(arguments[0].get(), timestampOI); HiveIntervalDayTime idt = PrimitiveObjectInspectorUtils.getHiveIntervalDayTime(arguments[1].get(), intervalOI); Timestamp origin = originTsOI == null ? Timestamp.ofEpochMilli(0) : PrimitiveObjectInspectorUtils.getTimestamp(arguments[2].get(), originTsOI); timestampResult.set(Timestamp.ofEpochMilli(truncate(ts, idt, origin))); return timestampResult; }
@Override public void evaluate(VectorizedRowBatch batch) { if (!initialized) { Object lVal = leftDynamicValue.getValue(); Object rVal = rightDynamicValue.getValue(); if (lVal == null || rVal == null) { isLeftOrRightNull = true; } else { Timestamp min = (PrimitiveObjectInspectorUtils.getTimestamp( lVal, leftDynamicValue.getObjectInspector())); setLeftValue(min); Timestamp max = (PrimitiveObjectInspectorUtils.getTimestamp( 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 void evaluate(VectorizedRowBatch batch) throws HiveException { if (!initialized) { Object lVal = leftDynamicValue.getValue(); Object rVal = rightDynamicValue.getValue(); if (lVal == null || rVal == null) { isLeftOrRightNull = true; } else { Timestamp min = (PrimitiveObjectInspectorUtils.getTimestamp( lVal, leftDynamicValue.getObjectInspector()).toSqlTimestamp()); setLeftValue(min); Timestamp max = (PrimitiveObjectInspectorUtils.getTimestamp( rVal, rightDynamicValue.getObjectInspector()).toSqlTimestamp()); 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); } }
longValue = DateWritableV2.dateToDays(PrimitiveObjectInspectorUtils.getDate(val, poi)); case TIMESTAMP: timestampValue = PrimitiveObjectInspectorUtils.getTimestamp(val, poi).toSqlTimestamp(); break; case INTERVAL_YEAR_MONTH:
HiveIntervalYearMonth iym1 = PrimitiveObjectInspectorUtils.getHiveIntervalYearMonth( arguments[intervalArg1Idx].get(), inputOIs[intervalArg1Idx]); Timestamp ts1 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArg1Idx].get(), inputOIs[dtArg1Idx]); return handleTimestampResult(dtm.subtract(ts1, iym1)); HiveIntervalDayTime idt1 = PrimitiveObjectInspectorUtils.getHiveIntervalDayTime( arguments[intervalArg1Idx].get(), inputOIs[intervalArg1Idx]); Timestamp ts1 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArg1Idx].get(), inputOIs[dtArg1Idx]); return handleTimestampResult(dtm.subtract(ts1, idt1)); Timestamp ts1 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArg1Idx].get(), inputOIs[dtArg1Idx]); Timestamp ts2 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArg2Idx].get(), inputOIs[dtArg2Idx]); return handleIntervalDayTimeResult(dtm.subtract(ts1, ts2));
HiveIntervalYearMonth iym1 = PrimitiveObjectInspectorUtils.getHiveIntervalYearMonth( arguments[intervalArg1Idx].get(), inputOIs[intervalArg1Idx]); Timestamp ts1 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArg1Idx].get(), inputOIs[dtArg1Idx]); return handleTimestampResult(dtm.subtract(ts1, iym1)); HiveIntervalDayTime idt1 = PrimitiveObjectInspectorUtils.getHiveIntervalDayTime( arguments[intervalArg1Idx].get(), inputOIs[intervalArg1Idx]); Timestamp ts1 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArg1Idx].get(), inputOIs[dtArg1Idx]); return handleTimestampResult(dtm.subtract(ts1, idt1)); Timestamp ts1 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArg1Idx].get(), inputOIs[dtArg1Idx]); Timestamp ts2 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArg2Idx].get(), inputOIs[dtArg2Idx]); return handleIntervalDayTimeResult(dtm.subtract(ts1, ts2));
longValue = DateWritable.dateToDays(PrimitiveObjectInspectorUtils.getDate(val, poi)); case TIMESTAMP: timestampValue = PrimitiveObjectInspectorUtils.getTimestamp(val, poi); break; case INTERVAL_YEAR_MONTH:
return PrimitiveObjectInspectorUtils.getDate(input, (DateObjectInspector) argumentOI); case TIMESTAMP: return PrimitiveObjectInspectorUtils.getTimestamp(input, (TimestampObjectInspector) argumentOI); case DECIMAL:
PrimitiveObjectInspectorUtils.getTimestamp( object, sourcePrimitiveOI); if (timestamp == null) {
PrimitiveObjectInspectorUtils.getTimestamp( object, convertSourcePrimitiveObjectInspectors[logicalColumnIndex]); if (timestamp == null) {
HiveIntervalYearMonth iym1 = PrimitiveObjectInspectorUtils.getHiveIntervalYearMonth( arguments[intervalArg1Idx].get(), inputOIs[intervalArg1Idx]); Timestamp ts1 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArgIdx].get(), inputOIs[dtArgIdx]); return handleTimestampResult(dtm.add(ts1, iym1)); HiveIntervalDayTime idt1 = PrimitiveObjectInspectorUtils.getHiveIntervalDayTime( arguments[intervalArg1Idx].get(), inputOIs[intervalArg1Idx]); Timestamp ts1 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArgIdx].get(), inputOIs[dtArgIdx]); return handleTimestampResult(dtm.add(ts1, idt1));
HiveIntervalYearMonth iym1 = PrimitiveObjectInspectorUtils.getHiveIntervalYearMonth( arguments[intervalArg1Idx].get(), inputOIs[intervalArg1Idx]); Timestamp ts1 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArgIdx].get(), inputOIs[dtArgIdx]); return handleTimestampResult(dtm.add(ts1, iym1)); HiveIntervalDayTime idt1 = PrimitiveObjectInspectorUtils.getHiveIntervalDayTime( arguments[intervalArg1Idx].get(), inputOIs[intervalArg1Idx]); Timestamp ts1 = PrimitiveObjectInspectorUtils.getTimestamp( arguments[dtArgIdx].get(), inputOIs[dtArgIdx]); return handleTimestampResult(dtm.add(ts1, idt1));
public Object convert(Object input) { if (input == null) { return null; } return outputOI.set(r, PrimitiveObjectInspectorUtils.getTimestamp(input, inputOI, intToTimestampInSeconds)); } }
public Object convert(Object input) { if (input == null) { return null; } Object r = outputOI.create(new Timestamp(0)); return outputOI.set(r, PrimitiveObjectInspectorUtils.getTimestamp(input, inputOI)); } }