Package org.apache.tajo.common.TajoDataTypes

Examples of org.apache.tajo.common.TajoDataTypes.DataType


  }

  public static String dataTypesToStr(List<DataType> parameterTypesList) {
    StringBuilder result = new StringBuilder();
    for (int i = 0; i < parameterTypesList.size(); i++) {
      DataType eachType = parameterTypesList.get(i);

      if (i > 0) {
        result.append(",");
      }
      result.append(eachType.getType().toString());

    }

    return result.toString();
  }
View Full Code Here


    return schema.getColumn(column - 1).getSimpleName();
  }

  @Override
  public int getColumnType(int column) throws SQLException {
    DataType type = schema.getColumn(column - 1).getDataType();

    return ResultSetUtil.tajoTypeToSqlType(type);
  }
View Full Code Here

    return ResultSetUtil.tajoTypeToSqlType(type);
  }

  @Override
  public String getColumnTypeName(int column) throws SQLException {
    DataType type = schema.getColumn(column - 1).getDataType();

    return ResultSetUtil.toSqlType(type);
  }
View Full Code Here

    maxValues = new VTuple(schema.getColumnNum());

    numNulls = new long[schema.getColumnNum()];
    comparable = new boolean[schema.getColumnNum()];

    DataType type;
    for (int i = 0; i < schema.getColumnNum(); i++) {
      type = schema.getColumn(i).getDataType();
      if (type.getType() == Type.PROTOBUF) {
        comparable[i] = false;
      } else {
        comparable[i] = true;
      }
    }
View Full Code Here

   * @see java.sql.ResultSetMetaData#getColumnType(int)
   */
  @Override
  public int getColumnType(int column) throws SQLException {
    // TODO
    DataType type = meta.getSchema().getColumn(column - 1).getDataType();
    switch (type.getType()) {
      case BOOLEAN:
        return Types.BOOLEAN;
      case INT1:
        return Types.TINYINT;
      case INT2:
View Full Code Here

    int tid; // column id of the original input schema
    for (int i = 0; i < projectionMap.length; i++) {
      tid = projectionMap[i];
      columns[i].startRow();
      DataType dataType = schema.getColumn(tid).getDataType();
      switch (dataType.getType()) {
        case BOOLEAN:
          tuple.put(tid,
              DatumFactory.createBool(((Integer)columns[i].nextValue()).byteValue()));
          break;
        case BIT:
          tuple.put(tid,
              DatumFactory.createBit(((Integer) columns[i].nextValue()).byteValue()));
          break;
        case CHAR:
          String str = (String) columns[i].nextValue();
          tuple.put(tid,
              DatumFactory.createChar(str));
          break;

        case INT2:
          tuple.put(tid,
              DatumFactory.createInt2(((Integer) columns[i].nextValue()).shortValue()));
          break;
        case INT4:
          tuple.put(tid,
              DatumFactory.createInt4((Integer) columns[i].nextValue()));
          break;

        case INT8:
          tuple.put(tid,
              DatumFactory.createInt8((Long) columns[i].nextValue()));
          break;

        case FLOAT4:
          tuple.put(tid,
              DatumFactory.createFloat4((Float) columns[i].nextValue()));
          break;

        case FLOAT8:
          tuple.put(tid,
              DatumFactory.createFloat8((Double) columns[i].nextValue()));
          break;

        case INET4:
          tuple.put(tid,
              DatumFactory.createInet4(((ByteBuffer) columns[i].nextValue()).array()));
          break;

        case TEXT:
          tuple.put(tid,
              DatumFactory.createText((String) columns[i].nextValue()));
          break;

        case PROTOBUF: {
          ProtobufDatumFactory factory = ProtobufDatumFactory.get(dataType.getCode());
          Message.Builder builder = factory.newBuilder();
          builder.mergeFrom(((ByteBuffer)columns[i].nextValue()).array());
          tuple.put(tid, factory.createDatum(builder));
          break;
        }
View Full Code Here

   * It transforms a list of targets to schema. If it contains anonymous targets, it names them.
   */
  static Schema getProjectedSchema(LogicalPlan plan, Target[] targets) {
    Schema projected = new Schema();
    for(Target t : targets) {
      DataType type = t.getEvalTree().getValueType();
      String name;
      if (t.hasAlias() || t.getEvalTree().getType() == EvalType.FIELD) {
        name = t.getCanonicalName();
      } else { // if an alias is not given or this target is an expression
        t.setAlias(plan.newNonameColumnName(t.getEvalTree().getName()));
View Full Code Here

  }

  public static Schema targetToSchema(Target[] targets) {
    Schema schema = new Schema();
    for(Target t : targets) {
      DataType type = t.getEvalTree().getValueType();
      String name;
      if (t.hasAlias()) {
        name = t.getAlias();
      } else {
        name = t.getEvalTree().getName();
View Full Code Here

        tid = projectionMap[i];
        // if the column is byte[0], it presents a NULL value.
        if (column.get(tid).getLength() == 0) {
          tuple.put(tid, DatumFactory.createNullDatum());
        } else {
          DataType dataType = targets[i].getDataType();
          switch (dataType.getType()) {
            case BOOLEAN:
              tuple.put(tid,
                  DatumFactory.createBool(column.get(tid).getBytesCopy()[0]));
              break;
            case BIT:
              tuple.put(tid,
                  DatumFactory.createBit(column.get(tid).getBytesCopy()[0]));
              break;
            case CHAR:
              byte[] buf = column.get(tid).getBytesCopy();
              tuple.put(tid,
                  DatumFactory.createChar(buf));
              break;

            case INT2:
              tuple.put(tid,
                  DatumFactory.createInt2(Bytes.toShort(
                      column.get(tid).getBytesCopy())));
              break;
            case INT4:
              tuple.put(tid,
                  DatumFactory.createInt4(Bytes.toInt(
                      column.get(tid).getBytesCopy())));
              break;

            case INT8:
              tuple.put(tid,
                  DatumFactory.createInt8(Bytes.toLong(
                      column.get(tid).getBytesCopy())));
              break;

            case FLOAT4:
              tuple.put(tid,
                  DatumFactory.createFloat4(Bytes.toFloat(
                      column.get(tid).getBytesCopy())));
              break;

            case FLOAT8:
              tuple.put(tid,
                  DatumFactory.createFloat8(Bytes.toDouble(
                      column.get(tid).getBytesCopy())));
              break;

            case TEXT:
              tuple.put(tid,
                  DatumFactory.createText(
                      column.get(tid).getBytesCopy()));
              break;

            case PROTOBUF: {
              ProtobufDatumFactory factory = ProtobufDatumFactory.get(dataType.getCode());
              Message.Builder builder = factory.newBuilder();
              builder.mergeFrom(column.get(tid).getBytesCopy());
              tuple.put(tid, factory.createDatum(builder));
              break;
            }
View Full Code Here

    return false;
  }

  private static void verifyComparisonOperator(VerificationState state, BinaryEval expr) {
    DataType leftType = expr.getLeftExpr().getValueType();
    DataType rightType = expr.getRightExpr().getValueType();
    if (!isCompatibleType(leftType, rightType)) {
      state.addVerification("No operator matches the given name and argument type(s): " + expr.toString());
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.tajo.common.TajoDataTypes.DataType

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.