@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { Date date = getDateValue(arguments, 0, inputTypes, converters); if (date == null) { return null; } lastDay(date); Date newDate = calendar.getTime(); output.set(DateUtils.getDateFormat().format(newDate)); return output; }
@Override public String vectorExpressionParameters() { if (field == -1) { return "col " + colNum; } else { return "col " + colNum + ", field " + DateUtils.getFieldName(field); } }
DateUtils.parseNumericValueWithRange("year", patternMatcher.group(2), 0, Integer.MAX_VALUE); byte months = (byte) (sign * DateUtils.parseNumericValueWithRange("month", patternMatcher.group(3), 0, 11)); result = new HiveIntervalYearMonth(years, months); } catch (Exception err) {
@Override public void writeHiveIntervalDayTime(long totalNanos) throws IOException { final boolean invert = columnSortOrderIsDesc[++index]; // This field is not a null. BinarySortableSerDe.writeByte(output, (byte) 1, invert); long totalSecs = DateUtils.getIntervalDayTimeTotalSecondsFromTotalNanos(totalNanos); int nanos = DateUtils.getIntervalDayTimeNanosFromTotalNanos(totalNanos); BinarySortableSerDe.serializeLong(output, totalSecs, invert); BinarySortableSerDe.serializeInt(output, nanos, invert); }
@Override public Object writeValue(long value) { DateUtils.setIntervalDayTimeTotalNanos(interval, value); ((SettableHiveIntervalDayTimeObjectInspector) this.objectInspector).set(obj, interval); return obj; }
private void evaluate(LongColumnVector outV, BytesColumnVector inV, int i) { try { HiveIntervalDayTime interval = HiveIntervalDayTime.valueOf( new String(inV.vector[i], inV.start[i], inV.length[i], "UTF-8")); outV.vector[i] = DateUtils.getIntervalDayTimeTotalNanos(interval); } catch (Exception e) { outV.vector[i] = 1; outV.isNull[i] = true; outV.noNulls = false; } }
@Override public void writeHiveIntervalDayTime(long totalNanos) throws IOException { final boolean invert = columnSortOrderIsDesc[++index]; // This field is not a null. BinarySortableSerDe.writeByte(output, (byte) 1, invert); long totalSecs = DateUtils.getIntervalDayTimeTotalSecondsFromTotalNanos(totalNanos); int nanos = DateUtils.getIntervalDayTimeNanosFromTotalNanos(totalNanos); BinarySortableSerDe.serializeLong(output, totalSecs, invert); BinarySortableSerDe.serializeInt(output, nanos, invert); }
@Override Object extract(int batchIndex) { int adjustedIndex = (colVector.isRepeating ? 0 : batchIndex); if (colVector.noNulls || !colVector.isNull[adjustedIndex]) { long value = vector[adjustedIndex]; DateUtils.setIntervalDayTimeTotalNanos(hiveIntervalDayTime, value); PrimitiveObjectInspectorFactory.writableHiveIntervalDayTimeObjectInspector.set(object, hiveIntervalDayTime); return object; } else { return null; } } }
@Override void assign(int batchIndex, Object object) { if (object == null) { VectorizedBatchUtil.setNullColIsNullValue(colVector, batchIndex); } else { HiveIntervalDayTimeWritable idtw = (HiveIntervalDayTimeWritable) object; HiveIntervalDayTime idt = idtw.getHiveIntervalDayTime(); vector[batchIndex] = DateUtils.getIntervalDayTimeTotalNanos(idt); } } }
@Override public void writeHiveIntervalDayTime(long totalNanos) throws IOException { final boolean invert = columnSortOrderIsDesc[++index]; // This field is not a null. BinarySortableSerDe.writeByte(output, (byte) 1, invert); long totalSecs = DateUtils.getIntervalDayTimeTotalSecondsFromTotalNanos(totalNanos); int nanos = DateUtils.getIntervalDayTimeNanosFromTotalNanos(totalNanos); BinarySortableSerDe.serializeLong(output, totalSecs, invert); BinarySortableSerDe.serializeInt(output, nanos, invert); }
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { Integer numMonthV; if (isNumMonthsConst) { numMonthV = numMonthsConst; } else { numMonthV = getIntValue(arguments, 1, converters); } if (numMonthV == null) { return null; } int numMonthInt = numMonthV.intValue(); Date date = getDateValue(arguments, 0, inputTypes, converters); if (date == null) { return null; } addMonth(date, numMonthInt); Date newDate = calendar.getTime(); output.set(DateUtils.getDateFormat().format(newDate)); return output; }
@Override public Object setValue(Object field, long value) { if (null == field) { field = initValue(null); } DateUtils.setIntervalDayTimeTotalNanos(interval, value); ((SettableHiveIntervalDayTimeObjectInspector) this.objectInspector).set(field, interval); return field; }
public String vectorExpressionParameters() { if (field == -1) { return "col " + colNum; } else { return "col " + colNum + ", field " + DateUtils.getFieldName(field); } }
DateUtils.parseNumericValueWithRange("year", patternMatcher.group(2), 0, Integer.MAX_VALUE); byte months = (byte) (sign * DateUtils.parseNumericValueWithRange("month", patternMatcher.group(3), 0, 11)); result = new HiveIntervalYearMonth(years, months); } catch (Exception err) {
@Override public void assignObjectValue(Object val, int destIndex) throws HiveException { if (val == null) { assignNull(destIndex); } else { HiveIntervalDayTimeWritable bw = (HiveIntervalDayTimeWritable) val; assignLong( DateUtils.getIntervalDayTimeTotalNanos(bw.getHiveIntervalDayTime()), destIndex); } } }.init(outputBatch, (LongColumnVector) destCol);
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { int dayOfWeekInt; if (isDayOfWeekConst) { dayOfWeekInt = dayOfWeekIntConst; } else { String dayOfWeek = getStringValue(arguments, 1, converters); dayOfWeekInt = getIntDayOfWeek(dayOfWeek); } if (dayOfWeekInt == -1) { return null; } Date date = getDateValue(arguments, 0, inputTypes, converters); if (date == null) { return null; } nextDay(date, dayOfWeekInt); Date newDate = calendar.getTime(); output.set(DateUtils.getDateFormat().format(newDate)); return output; }
@Override public void writeHiveIntervalDayTime(long totalNanos) throws IOException { if (index > 0) { output.write(separator); } if (hiveIntervalDayTime == null) { hiveIntervalDayTime = new HiveIntervalDayTime(); } if (hiveIntervalDayTimeWritable == null) { hiveIntervalDayTimeWritable = new HiveIntervalDayTimeWritable(); } DateUtils.setIntervalDayTimeTotalNanos(hiveIntervalDayTime, totalNanos); hiveIntervalDayTimeWritable.set(hiveIntervalDayTime); LazyHiveIntervalDayTime.writeUTF8(output, hiveIntervalDayTimeWritable); index++; }
@Override public String vectorExpressionParameters() { if (field == -1) { return "col " + colNum; } else { return "col " + colNum + ", field " + DateUtils.getFieldName(field); } }
DateUtils.parseNumericValueWithRange("year", patternMatcher.group(2), 0, Integer.MAX_VALUE); byte months = (byte) (sign * DateUtils.parseNumericValueWithRange("month", patternMatcher.group(3), 0, 11)); result = new HiveIntervalYearMonth(years, months); } catch (Exception err) {
@Override void apply(VectorizedRowBatch batch, int batchIndex) throws IOException { LongColumnVector colVector = (LongColumnVector) batch.cols[columnIndex]; if (deserializeRead.readCheckNull()) { VectorizedBatchUtil.setNullColIsNullValue(colVector, batchIndex); } else { deserializeRead.readIntervalDayTime(readIntervalDayTimeResults); HiveIntervalDayTime hidt = readIntervalDayTimeResults.getHiveIntervalDayTime(); colVector.vector[batchIndex] = DateUtils.getIntervalDayTimeTotalNanos(hidt); } } }