Package org.apache.tajo.storage

Examples of org.apache.tajo.storage.VTuple


    }
  }

  @Override
  public Tuple next() throws IOException {
    Tuple tuple = new VTuple(schema.size());

    if (!columns[0].hasNext()) {
      return null;
    }

    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;
        }

        case BLOB:
          tuple.put(tid,
              new BlobDatum(((ByteBuffer) columns[i].nextValue())));
          break;

        case NULL_TYPE:
          tuple.put(tid, NullDatum.get());
          break;

        default:
          throw new IOException("Unsupport data type");
      }
View Full Code Here

TOP

Related Classes of org.apache.tajo.storage.VTuple

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.