Examples of FunctionSpec


Examples of com.cloudera.flume.conf.FlumeBuilder.FunctionSpec

    return trigger.getTagger().getTag();
  }

  public static RollTrigger createRollTrigger(Context ctx, long rollmillis) {
    RollTrigger rt = null;
    FunctionSpec fs = ctx.getObj(C_TRIGGER, FunctionSpec.class);
    if (fs == null) {
      rt = new TimeTrigger(new ProcessTagger(), rollmillis);
    } else {
      if ("time".equals(fs.getName())) {
        rt = new TimeTrigger(new ProcessTagger(), rollmillis);
      } else if ("size".equals(fs.getName())) {
        Tagger t = new ProcessTagger();
        Preconditions.checkArgument(fs.getArgs().length == 1,
            "size trigger requires argument");
        long sz = Long.parseLong(fs.getArgs()[0].toString());
        rt = new OrTrigger(t, new TimeTrigger(t, rollmillis), new SizeTrigger(
            sz, t));
      } else {
        throw new IllegalArgumentException("Illegal trigger type specified: "
            + fs.getName());
      }
    }
    return rt;
  }
View Full Code Here

Examples of sizzle.functions.FunctionSpec

    return aggregators;
  }

  private void importFunction(final Method m) {
    final FunctionSpec annotation = m.getAnnotation(FunctionSpec.class);

    final String[] formalParameters = annotation.formalParameters();
    final SizzleType[] formalParameterTypes = new SizzleType[formalParameters.length];

    for (int i = 0; i < formalParameters.length; i++) {
      final String id = formalParameters[i];

      // check for varargs
      if (id.endsWith("..."))
        formalParameterTypes[i] = new SizzleVarargs(this.getType(id.substring(0, id.indexOf('.'))));
      else
        formalParameterTypes[i] = this.getType(id);
    }

    for (final String dep : annotation.typeDependencies())
      if (dep.endsWith(".proto"))
        this.importProto(dep);
      else if (dep.endsWith(".avro"))
        this.importAvro(dep);
      else
        throw new TypeException("unknown dependency in " + dep);

    this.setFunction(annotation.name(),
        new SizzleFunction(m.getDeclaringClass().getCanonicalName() + '.' + m.getName(), this.getType(annotation.returnType()), formalParameterTypes));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.