public int serialize()

in tajo-storage/src/main/java/org/apache/tajo/storage/BinarySerializerDeserializer.java [35:95]


  public int serialize(Column col, Datum datum, OutputStream out, byte[] nullCharacters)
      throws IOException {
    byte[] bytes;
    int length = 0;
    if (datum == null || datum instanceof NullDatum) {
      return 0;
    }

    switch (col.getDataType().getType()) {
      case BOOLEAN:
      case BIT:
      case CHAR:
        bytes = datum.asByteArray();
        length = bytes.length;
        out.write(bytes, 0, length);
        break;
      case INT2:
        length = writeShort(out, datum.asInt2());
        break;
      case INT4:
        length = writeVLong(out, datum.asInt4());
        break;
      case INT8:
        length = writeVLong(out, datum.asInt8());
        break;
      case FLOAT4:
        length = writeFloat(out, datum.asFloat4());
        break;
      case FLOAT8:
        length = writeDouble(out, datum.asFloat8());
        break;
      case TEXT: {
        bytes = datum.asTextBytes();
        length = datum.size();
        if (length == 0) {
          bytes = INVALID_UTF__SINGLE_BYTE;
          length = INVALID_UTF__SINGLE_BYTE.length;
        }
        out.write(bytes, 0, bytes.length);
        break;
      }
      case BLOB:
      case INET4:
      case INET6:
        bytes = datum.asByteArray();
        length = bytes.length;
        out.write(bytes, 0, length);
        break;
      case PROTOBUF:
        ProtobufDatum protobufDatum = (ProtobufDatum) datum;
        bytes = protobufDatum.asByteArray();
        length = bytes.length;
        out.write(bytes, 0, length);
        break;
      case NULL_TYPE:
        break;
      default:
        throw new IOException("Does not support type");
    }
    return length;
  }