Package org.apache.tajo.catalog

Examples of org.apache.tajo.catalog.Column


import static org.apache.tajo.common.TajoDataTypes.Type.TEXT;

public class Country extends GeneralFunction {

  public Country() {
    super(new Column[] {new Column("addr", TEXT)});
  }
View Full Code Here


    }
    sb.append("\n");
    sb.append("schema: \n");

    for(int i = 0; i < desc.getMeta().getSchema().getColumnNum(); i++) {
      Column col = desc.getMeta().getSchema().getColumn(i);
      sb.append(col.getColumnName()).append("\t").append(col.getDataType().getType());
      if (col.getDataType().hasLength()) {
        sb.append("(").append(col.getDataType().getLength()).append(")");
      }
      sb.append("\n");
    }
    return sb.toString();
  }
View Full Code Here

    return 0;
  }

  @Override
  public void addTuple(Tuple t) throws IOException {
    Column col;
    writer.startRow();
    for (int i = 0; i < schema.getColumnNum(); i++) {
      if (enabledStats) {
        stats.analyzeField(i, t.get(i));
      }

      if (!t.isNull(i)) {
        col = schema.getColumn(i);
        switch (col.getDataType().getType()) {
          case NULL:
            break;
          case BOOLEAN:
          case BIT:
          case INT2:
View Full Code Here

    this.targetNum = targets != null ? targets.length : 0;

    inMap = new int[outSchema.getColumnNum() - targetNum];
    outMap = new int[outSchema.getColumnNum() - targetNum];
    int mapId = 0;
    Column col;

    if (targetNum > 0) {
      evalOutMap = new int[targetNum];
      evals = new EvalNode[targetNum];
      for (int i = 0; i < targetNum; i++) {
        // TODO - is it always  correct?
        if (targets[i].hasAlias()) {
          evalOutMap[i] = outSchema.getColumnId(targets[i].getAlias());
        } else {
          evalOutMap[i] = outSchema.getColumnId(targets[i].getEvalTree().getName());
        }
        evals[i] = targets[i].getEvalTree();
      }

      outer:
      for (int targetId = 0; targetId < outSchema.getColumnNum(); targetId ++) {
        for (int j = 0; j < evalOutMap.length; j++) {
          if (evalOutMap[j] == targetId)
            continue outer;
        }

        col = inSchema.getColumnByFQN(outSchema.getColumn(targetId).getQualifiedName());
        outMap[mapId] = targetId;
        inMap[mapId] = inSchema.getColumnId(col.getQualifiedName());
        mapId++;
      }
    } else {
      for (int targetId = 0; targetId < outSchema.getColumnNum(); targetId ++) {
        col = inSchema.getColumnByFQN(outSchema.getColumn(targetId).getQualifiedName());
        outMap[mapId] = targetId;
        inMap[mapId] = inSchema.getColumnId(col.getQualifiedName());
        mapId++;
      }
    }
  }
View Full Code Here

  @Expose private Column column;
  @Expose private String alias = null;

  public Target(EvalNode expr) {
    this.expr = expr;
    this.column = new Column(expr.getName(), expr.getValueType());
  }
View Full Code Here

    return !hasAlias() ? column.getQualifiedName() : alias;
  }

  public final void setAlias(String alias) {
    this.alias = alias;
    this.column = new Column(alias, expr.getValueType());
  }
View Full Code Here

   * @return
   */
  public static BigDecimal computeCardinalityForAllColumns(Schema schema, TupleRange range, boolean inclusive) {
    Tuple start = range.getStart();
    Tuple end = range.getEnd();
    Column col;

    BigDecimal cardinality = new BigDecimal(1);
    BigDecimal columnCard;
    for (int i = 0; i < schema.getColumnNum(); i++) {
      col = schema.getColumn(i);
      columnCard = computeCardinality(col.getDataType(), start.get(i), end.get(i), inclusive);

      if (new BigDecimal(0).compareTo(columnCard) < 0) {
        cardinality = cardinality.multiply(columnCard);
      }
    }
View Full Code Here

      if (targets[i] == null) { // if it is not created
        continue;
      }

      if (!exclude.contains(i) && resolvedFlags[i]) { // if this target was evaluated, it becomes a column target.
        Column col = getResolvedTargetToColumn(i);
        updated[i] = new Target(new FieldEval(col));
      } else {
        try {
          updated[i] = (Target) targets[i].clone();
        } catch (CloneNotSupportedException e) {
View Full Code Here

      if (targets[i] == null) { // if it is not created
        continue;
      }

      if (resolvedFlags[i]) { // if this target was evaluated, it becomes a column target.
        Column col = getResolvedTargetToColumn(i);
        updated[i] = new Target(new FieldEval(col));
      } else {
        try {
          updated[i] = (Target) targets[i].clone();
        } catch (CloneNotSupportedException e) {
View Full Code Here

  public Schema getUpdatedSchema() {
    Schema schema = new Schema();
    for (int i = 0; i < resolvedFlags.length; i++) {
      if (resolvedFlags[i]) {
        Column col = getResolvedTargetToColumn(i);
        if (!schema.contains(col.getQualifiedName()))
        schema.addColumn(col);
      } else {
        Collection<Column> cols = getColumnRefs(i);
        for (Column col : cols) {
          if (!schema.contains(col.getQualifiedName())) {
            schema.addColumn(col);
          }
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.tajo.catalog.Column

Copyright © 2018 www.massapicom. 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.