in tajo-storage/src/main/java/org/apache/tajo/storage/TextSerializerDeserializer.java [40:103]
public int serialize(Column col, Datum datum, OutputStream out, byte[] nullCharacters) throws IOException {
byte[] bytes;
int length = 0;
TajoDataTypes.DataType dataType = col.getDataType();
if (datum == null || datum instanceof NullDatum) {
switch (dataType.getType()) {
case CHAR:
case TEXT:
length = nullCharacters.length;
out.write(nullCharacters);
break;
default:
break;
}
return length;
}
switch (dataType.getType()) {
case BOOLEAN:
out.write(datum.asBool() ? trueBytes : falseBytes);
length = trueBytes.length;
break;
case CHAR:
byte[] pad = new byte[dataType.getLength() - datum.size()];
bytes = datum.asTextBytes();
out.write(bytes);
out.write(pad);
length = bytes.length + pad.length;
break;
case TEXT:
case BIT:
case INT2:
case INT4:
case INT8:
case FLOAT4:
case FLOAT8:
case INET4:
case DATE:
case TIME:
case TIMESTAMP:
bytes = datum.asTextBytes();
length = bytes.length;
out.write(bytes);
break;
case INET6:
case BLOB:
bytes = Base64.encodeBase64(datum.asByteArray(), false);
length = bytes.length;
out.write(bytes, 0, length);
break;
case PROTOBUF:
ProtobufDatum protobuf = (ProtobufDatum) datum;
byte[] protoBytes = protobufJsonFormat.printToString(protobuf.get()).getBytes();
length = protoBytes.length;
out.write(protoBytes, 0, protoBytes.length);
break;
case NULL_TYPE:
default:
break;
}
return length;
}