Package org.apache.tajo.catalog

Examples of org.apache.tajo.catalog.Column


    public Tuple toTuple(byte [] bytes) {
      nullFlags.clear();
      ByteBuffer bb = ByteBuffer.wrap(bytes);
      Tuple tuple = new VTuple(schema.size());
      Column col;
      TajoDataTypes.DataType type;

      bb.limit(headerSize);
      nullFlags.fromByteBuffer(bb);
      bb.limit(bytes.length);

      for (int i =0; i < schema.size(); i++) {
        if (nullFlags.get(i)) {
          tuple.put(i, DatumFactory.createNullDatum());
          continue;
        }

        col = schema.getColumn(i);
        type = col.getDataType();
        switch (type.getType()) {
          case BOOLEAN: tuple.put(i, DatumFactory.createBool(bb.get())); break;
          case BIT:
            byte b = bb.get();
            tuple.put(i, DatumFactory.createBit(b));
View Full Code Here


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

    for(int i = 0; i < desc.getSchema().size(); i++) {
      Column col = desc.getSchema().getColumn(i);
      sb.append(col.getSimpleName()).append("\t").append(col.getDataType().getType());
      if (col.getDataType().hasLength()) {
        sb.append("(").append(col.getDataType().getLength()).append(")");
      }
      sb.append("\n");
    }

    sb.append("\n");
View Full Code Here

    public byte [] toBytes(Tuple tuple) {
      nullFlags.clear();
      int size = 4096; // 4kb
      ByteBuffer bb = ByteBuffer.allocate(size + headerSize);
      bb.position(headerSize);
      Column col;
      for (int i = 0; i < schema.size(); i++) {
        if (tuple.isNull(i)) {
          nullFlags.set(i);
        }

        col = schema.getColumn(i);
        switch (col.getDataType().getType()) {
          case NULL_TYPE: nullFlags.set(i); break;
          case BOOLEAN: bb.put(tuple.get(i).asByte()); break;
          case BIT: bb.put(tuple.get(i).asByte()); break;
          case CHAR: bb.put(tuple.get(i).asByte()); break;
          case INT2: bb.putShort(tuple.get(i).asInt2()); break;
View Full Code Here

    throw new SQLFeatureNotSupportedException("unwrap not supported");
  }

  @Override
  public String getCatalogName(int column) throws SQLException {
    Column c = schema.getColumn(column - 1);
    if (CatalogUtil.isFQColumnName(c.getQualifiedName())) {
      return CatalogUtil.splitFQTableName(c.getQualifier())[0];
    }
    return "";
  }
View Full Code Here

          return null;
        }
      }

      Datum datum;
      Column col;
      for (i = 0; i < schema.size(); i++) {
        if (!nullFlags.get(i)) {
          col = schema.getColumn(i);
          switch (col.getDataType().getType()) {
            case BOOLEAN :
              datum = DatumFactory.createBool(buffer.get());
              tuple.put(i, datum);
              break;

            case BIT:
              datum = DatumFactory.createBit(buffer.get());
              tuple.put(i, datum );
              break;

            case CHAR :
              int realLen = buffer.getInt();
              byte[] buf = new byte[col.getDataType().getLength()];
              buffer.get(buf);
              byte[] charBuf = Arrays.copyOf(buf, realLen);
              tuple.put(i, DatumFactory.createChar(charBuf));
              break;
View Full Code Here

    }

    @Override
    public void addTuple(Tuple t) throws IOException {
      checkAndWriteSync();
      Column col;

      buffer.clear();
      nullFlags.clear();

      for (int i = 0; i < schema.size(); i++) {
        if (enabledStats) {
          stats.analyzeField(i, t.get(i));
        }

        if (t.isNull(i)) {
          nullFlags.set(i);
        } else {
          col = schema.getColumn(i);
          switch (col.getDataType().getType()) {
            case BOOLEAN:
              buffer.put(t.get(i).asByte());
              break;
            case BIT:
              buffer.put(t.get(i).asByte());
              break;
            case CHAR:
              byte[] src = t.get(i).asByteArray();
              byte[] dst = Arrays.copyOf(src, col.getDataType().getLength());
              buffer.putInt(src.length);
              buffer.put(dst);
              break;
            case TEXT:
              byte [] strbytes = t.get(i).asByteArray();
View Full Code Here

    numDistVals = 0l;
    numNulls = 0l;
  }

  public ColumnStats(CatalogProtos.ColumnStatsProto proto) {
    this.column = new Column(proto.getColumn());

    if (proto.hasNumDistVal()) {
      this.numDistVals = proto.getNumDistVal();
    }
    if (proto.hasNumNulls()) {
View Full Code Here

  public static class RowStoreDecoder {

    public static Tuple toTuple(Schema schema, byte [] bytes) {
      ByteBuffer bb = ByteBuffer.wrap(bytes);
      Tuple tuple = new VTuple(schema.getColumnNum());
      Column col;
      for (int i =0; i < schema.getColumnNum(); i++) {
        col = schema.getColumn(i);

        switch (col.getDataType().getType()) {
          case BOOLEAN: tuple.put(i, DatumFactory.createBool(bb.get())); break;
          case BIT:
            byte b = bb.get();
            if(b == 0) {
              tuple.put(i, DatumFactory.createNullDatum());
View Full Code Here

  public static class RowStoreEncoder {

    public static byte [] toBytes(Schema schema, Tuple tuple) {
      int size = StorageUtil.getRowByteSize(schema);
      ByteBuffer bb = ByteBuffer.allocate(size);
      Column col;
      for (int i = 0; i < schema.getColumnNum(); i++) {
        col = schema.getColumn(i);
        switch (col.getDataType().getType()) {
          case BOOLEAN: bb.put(tuple.get(i).asByte()); break;
          case BIT: bb.put(tuple.get(i).asByte()); break;
          case CHAR: bb.put(tuple.get(i).asByte()); break;
          case INT2: bb.putShort(tuple.get(i).asInt2()); break;
          case INT4: bb.putInt(tuple.get(i).asInt4()); break;
View Full Code Here

          return null;
        }
      }

      Datum datum;
      Column col;
      for (i = 0; i < schema.getColumnNum(); i++) {
        if (!nullFlags.get(i)) {
          col = schema.getColumn(i);
          switch (col.getDataType().getType()) {
            case BOOLEAN :
              datum = DatumFactory.createBool(buffer.get());
              tuple.put(i, datum);
              break;

            case BIT:
              datum = DatumFactory.createBit(buffer.get());
              tuple.put(i, datum );
              break;

            case CHAR :
              int realLen = buffer.getInt();
              byte[] buf = new byte[col.getDataType().getLength()];
              buffer.get(buf);
              byte[] charBuf = Arrays.copyOf(buf, realLen);
              tuple.put(i, DatumFactory.createChar(charBuf));
              break;
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.