コード例 #1
0
ファイル: BNLJoinExec.java プロジェクト: niumowm/tajo
  public BNLJoinExec(
      final TaskAttemptContext context,
      final JoinNode join,
      final PhysicalExec outer,
      PhysicalExec inner) {
    super(
        context,
        SchemaUtil.merge(outer.getSchema(), inner.getSchema()),
        SchemaUtil.merge(outer.getSchema(), inner.getSchema()),
        outer,
        inner);
    this.joinQual = join.getJoinQual();
    this.qualCtx = this.joinQual.newContext();
    this.outerTupleSlots = new ArrayList<Tuple>(TUPLE_SLOT_SIZE);
    this.innerTupleSlots = new ArrayList<Tuple>(TUPLE_SLOT_SIZE);
    this.outerIterator = outerTupleSlots.iterator();
    this.innerIterator = innerTupleSlots.iterator();
    this.innerEnd = false;
    this.outerEnd = false;

    // for projection
    targetIds = RowStoreUtil.getTargetIds(inSchema, outSchema);

    // for join
    frameTuple = new FrameTuple();
    outputTuple = new VTuple(outSchema.getColumnNum());
  }
コード例 #2
0
ファイル: LikeEval.java プロジェクト: niumowm/tajo
public class LikeEval extends BinaryEval {
  @Expose private boolean not;
  @Expose private Column column;
  @Expose private String pattern;
  private static final DataType[] RES_TYPE = SchemaUtil.newNoNameSchema(DataType.BOOLEAN);

  // temporal variables
  private Integer fieldId = null;
  private Pattern compiled;
  private BoolDatum result;

  public LikeEval(boolean not, FieldEval field, ConstEval pattern) {
    super(Type.LIKE, field, pattern);
    this.not = not;
    this.column = field.getColumnRef();
    this.pattern = pattern.getValue().asChars();
  }

  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 DataType[] getValueType() {
    return RES_TYPE;
  }

  @Override
  public String getName() {
    return "?";
  }

  @Override
  public void eval(EvalContext ctx, Schema schema, Tuple tuple) {
    if (fieldId == null) {
      fieldId = schema.getColumnId(column.getQualifiedName());
      compile(this.pattern);
    }
    StringDatum str = tuple.getString(fieldId);
    if (not) {
      result.setValue(!compiled.matcher(str.asChars()).matches());
    } else {
      result.setValue(compiled.matcher(str.asChars()).matches());
    }
  }

  public Datum terminate(EvalContext ctx) {
    return result;
  }

  @Override
  public String toString() {
    return this.column + " like '" + pattern + "'";
  }
}