Hi Giorgio, Thank you, I will have a look.
Best, -- Jialin Qiao School of Software, Tsinghua University 乔嘉林 清华大学 软件学院 > -----原始邮件----- > 发件人: "Giorgio Zoppi" <[email protected]> > 发送时间: 2020-05-31 04:06:01 (星期日) > 收件人: [email protected] > 抄送: > 主题: Re: Serialization discussion > > Hello Gents, > > Ok I came up with this design: > > package org.apache.iotdb.tsfile.common.serialization; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > import java.nio.ByteBuffer; > > public interface IDataSerializer<T, V> { > int serializeTo(T data, OutputStream outputStream) throws IOException; > int serializeTo(T data, ByteBuffer buffer); > T deserializeFrom(ByteBuffer buffer, V options); > T deserializeFrom(InputStream inputStream, V options); > } > > > And i have for example, something like this: > public class PageHeaderSerializer implements IDataSerializer<PageHeader, > TSDataType> { > > @Override > public int serializeTo(PageHeader data, OutputStream outputStream) throws > IOException { > // code > } > @Override > public int serializeTo(PageHeader data, ByteBuffer buffer) { > /// snip. > } > > @Override > public PageHeader deserializeFrom(ByteBuffer buffer, TSDataType options) { > /// > } > > @Override > public PageHeader deserializeFrom(InputStream inputStream, TSDataType > options) { > // snippet > } > } > In this way we have a class that has the respobility of serialization. We > delegate the serialization to an appropriate class without breaking the > interface. > This is the first step. > > BR, > Giorgio
