private TimeValue parseTime(String timePart) { // e.g., 12:01:50.399 String[] parts = timePart.split(":"); TimeValue time; boolean hasFractionOfSeconds = (parts.length > 2 && parts[2].indexOf('.') > 0); if (hasFractionOfSeconds) { String[] secondsParts = parts[2].split("\\."); time = new TimeValue(parts[0], parts[1], secondsParts[0]); if (secondsParts.length == 2) { time.setSecondsFraction(secondsParts[1]); } } else { time = new TimeValue(parts[0], (parts.length > 1 ? parts[1] : "0"), (parts.length > 2 ? parts[2] : "0")); } return time; }
public String toString() { if (hasSecondsFraction()) { return String.format("%s:%s:%s.%s", hours, minutes, seconds, secondsFraction); } else { return String.format("%s:%s:%s", hours, minutes, seconds); } }
public String toString() { return time.toString(); }
@Override public Expr visitTimeLiteral(Object ctx, Stack<Expr> stack, TimeLiteral expr) throws TajoException { StringBuilder sb = new StringBuilder(); if (!isHiveCatalog) { TimeValue timeValue = expr.getTime(); int [] times = ExprAnnotator.timeToIntArray(timeValue.getHours(), timeValue.getMinutes(), timeValue.getSeconds(), timeValue.getSecondsFraction()); long time; if (timeValue.hasSecondsFraction()) { time = DateTimeUtil.toTime(times[0], times[1], times[2], times[3] * 1000); } else { time = DateTimeUtil.toTime(times[0], times[1], times[2], 0); } TimeDatum timeDatum = new TimeDatum(time); TimeMeta tm = timeDatum.asTimeMeta(); TimeZone tz = TimeZone.getDefault(); DateTimeUtil.toUTCTimezone(tm, tz); sb.append("?").append(" )"); parameters.add(new Pair(Type.TIME, new Time(DateTimeUtil.toJavaTime(tm.hours, tm.minutes, tm.secs, tm.fsecs)))); } else { sb.append("\"").append(expr.toString()).append("\""); } queries.push(sb.toString()); return expr; }
""+timestampDatum.getMonthOfYear(), ""+timestampDatum.getDayOfMonth()); timeValue = new TimeValue(""+timestampDatum.getHourOfDay() , ""+timestampDatum.getMinuteOfHour(), ""+timestampDatum.getSecondOfMinute()); case TIME: TimeDatum timeDatum = (TimeDatum) datum; timeValue = new TimeValue(""+timeDatum.getHourOfDay() , ""+timeDatum.getMinuteOfHour(), ""+timeDatum.getSecondOfMinute());
@Override boolean equalsTo(Expr expr) { if (expr instanceof TimeLiteral) { TimeLiteral another = (TimeLiteral) expr; return time.equals(another.time); } return false; }
@Override public Object clone() throws CloneNotSupportedException { TimeLiteral timeLiteral = (TimeLiteral) super.clone(); timeLiteral.time = (TimeValue) timeLiteral.time.clone(); return timeLiteral; } }
@Override public EvalNode visitTimeLiteral(Context ctx, Stack<Expr> stack, TimeLiteral expr) throws TajoException { TimeValue timeValue = expr.getTime(); int [] times = timeToIntArray(timeValue.getHours(), timeValue.getMinutes(), timeValue.getSeconds(), timeValue.getSecondsFraction()); long time; if (timeValue.hasSecondsFraction()) { time = DateTimeUtil.toTime(times[0], times[1], times[2], times[3] * 1000); } else { time = DateTimeUtil.toTime(times[0], times[1], times[2], 0); } TimeDatum timeDatum = new TimeDatum(time); TimeMeta tm = timeDatum.asTimeMeta(); return new ConstEval(new TimeDatum(DateTimeUtil.toTime(tm))); }
@Override boolean equalsTo(Expr expr) { if (expr instanceof TimeLiteral) { TimeLiteral another = (TimeLiteral) expr; return time.equals(another.time); } return false; }
@Override public Object clone() throws CloneNotSupportedException { TimeLiteral timeLiteral = (TimeLiteral) super.clone(); timeLiteral.time = (TimeValue) timeLiteral.time.clone(); return timeLiteral; } }
@Override public EvalNode visitTimeLiteral(Context ctx, Stack<Expr> stack, TimeLiteral expr) throws TajoException { TimeValue timeValue = expr.getTime(); int [] times = timeToIntArray(timeValue.getHours(), timeValue.getMinutes(), timeValue.getSeconds(), timeValue.getSecondsFraction()); long time; if (timeValue.hasSecondsFraction()) { time = DateTimeUtil.toTime(times[0], times[1], times[2], times[3] * 1000); } else { time = DateTimeUtil.toTime(times[0], times[1], times[2], 0); } TimeDatum timeDatum = new TimeDatum(time); TimeMeta tm = timeDatum.asTimeMeta(); return new ConstEval(new TimeDatum(DateTimeUtil.toTime(tm))); }
public String toString() { return time.toString(); }
private TimeValue parseTime(String timePart) { // e.g., 12:01:50.399 String[] parts = timePart.split(":"); TimeValue time; boolean hasFractionOfSeconds = (parts.length > 2 && parts[2].indexOf('.') > 0); if (hasFractionOfSeconds) { String[] secondsParts = parts[2].split("\\."); time = new TimeValue(parts[0], parts[1], secondsParts[0]); if (secondsParts.length == 2) { time.setSecondsFraction(secondsParts[1]); } } else { time = new TimeValue(parts[0], (parts.length > 1 ? parts[1] : "0"), (parts.length > 2 ? parts[2] : "0")); } return time; }
public String toString() { if (hasSecondsFraction()) { return String.format("%s:%s:%s.%s", hours, minutes, seconds, secondsFraction); } else { return String.format("%s:%s:%s", hours, minutes, seconds); } }
@Override boolean equalsTo(Expr expr) { if (expr instanceof TimestampLiteral) { TimestampLiteral another = (TimestampLiteral) expr; return date.equals(another.date) && time.equals(another.time); } return false; }
dateValue.getMonths(), dateValue.getDays()); int [] times = ExprAnnotator.timeToIntArray(timeValue.getHours(), timeValue.getMinutes(), timeValue.getSeconds(), timeValue.getSecondsFraction()); if (timeValue.hasSecondsFraction()) { julianTimestamp = DateTimeUtil.toJulianTimestamp(dates[0], dates[1], dates[2], times[0], times[1], times[2], times[3] * 1000);
@Override public Object visitTimeLiteral(Object ctx, Stack<Expr> stack, TimeLiteral expr) throws TajoException { this.append(expr.getTime().toString()); return super.visitTimeLiteral(ctx, stack, expr); } }
@Override boolean equalsTo(Expr expr) { if (expr instanceof TimestampLiteral) { TimestampLiteral another = (TimestampLiteral) expr; return date.equals(another.date) && time.equals(another.time); } return false; }
@Override public EvalNode visitTimestampLiteral(Context ctx, Stack<Expr> stack, TimestampLiteral expr) throws TajoException { DateValue dateValue = expr.getDate(); TimeValue timeValue = expr.getTime(); int [] dates = dateToIntArray(dateValue.getYears(), dateValue.getMonths(), dateValue.getDays()); int [] times = timeToIntArray(timeValue.getHours(), timeValue.getMinutes(), timeValue.getSeconds(), timeValue.getSecondsFraction()); long timestamp; if (timeValue.hasSecondsFraction()) { timestamp = DateTimeUtil.toJulianTimestamp(dates[0], dates[1], dates[2], times[0], times[1], times[2], times[3] * 1000); } else { timestamp = DateTimeUtil.toJulianTimestamp(dates[0], dates[1], dates[2], times[0], times[1], times[2], 0); } TimeMeta tm = new TimeMeta(); DateTimeUtil.toJulianTimeMeta(timestamp, tm); DateTimeUtil.toUTCTimezone(tm, ctx.timeZone); return new ConstEval(new TimestampDatum(DateTimeUtil.toJulianTimestamp(tm))); }
@Override public Object visitTimeLiteral(Object ctx, Stack<Expr> stack, TimeLiteral expr) throws TajoException { this.append(expr.getTime().toString()); return super.visitTimeLiteral(ctx, stack, expr); } }