@Override public Datum getPartialResult(FunctionContext ctx) { AvgContext avgCtx = (AvgContext) ctx; ArrayDatum part = new ArrayDatum(2); part.put(0, DatumFactory.createDouble(avgCtx.sum)); part.put(1, DatumFactory.createLong(avgCtx.count)); return part; }
public void compile(String pattern) { String regex = pattern.replace("?", "."); regex = regex.replace("%", ".*"); this.compiled = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL); result = DatumFactory.createBool(false); }
@Override public Datum read(ByteBuffer buffer) throws IOException { if (buffer.hasRemaining()) { return DatumFactory.createInt(buffer.getInt()); } else { return null; } }
@Override public Datum eval(Tuple params) { try { return DatumFactory.createInt8( new SimpleDateFormat(dateFormat).parse(params.get(0).asChars()).getTime()); } catch (ParseException e) { LOG.error(e); return null; } }
@Override public Datum terminate(FunctionContext ctx) { return DatumFactory.createInt(((MinContext) ctx).min); }
@Override public Datum getPartialResult(FunctionContext ctx) { return DatumFactory.createInt(((MinContext) ctx).min); }
@Test public void testTarget() throws CloneNotSupportedException { QueryBlock.Target t1 = new QueryBlock.Target(new ConstEval(DatumFactory.createInt(5)), 0); QueryBlock.Target t2 = (QueryBlock.Target) t1.clone(); assertEquals(t1, t2); }
@Override public Datum terminate(FunctionContext ctx) { AvgContext avgCtx = (AvgContext) ctx; return DatumFactory.createDouble(avgCtx.sum / avgCtx.count); }