mapreduce实现writable接口自定义输出格式

来源:互联网 发布:php 返回上个页面 编辑:程序博客网 时间:2024/05/21 09:47
static class UserAndPostWritable implements Writable    {        /**         * 类型 U表示用户,P表示帖子         */        private String type;        private String data;        public UserAndPostWritable()        {        }        public UserAndPostWritable(String type, String data)        {            super();            this.type = type;            this.data = data;        }        public String getType()        {            return type;        }        public void setType(String type)        {            this.type = type;        }        public String getData()        {            return data;        }        public void setData(String data)        {            this.data = data;        }        @Override        public void readFields(DataInput input) throws IOException        {            type = input.readUTF();            data = input.readUTF();        }        @Override        public void write(DataOutput output) throws IOException        {            output.writeUTF(type);            output.writeUTF(data);        }    }
原创粉丝点击