Hadoop 使用Flume序列化程序生成复合hbase行键

Hadoop 使用Flume序列化程序生成复合hbase行键,hadoop,hbase,interceptor,flume,serialization,Hadoop,Hbase,Interceptor,Flume,Serialization,我有这样的GIS数据- '111, 2011-02-01 20:30:30, 116.50443, 40.00951' '111, 2011-02-01 20:30:31, 116.50443, 40.00951' '112, 2011-02-01 20:30:30, 116.58197, 40.06665' '112, 2011-02-01 20:30:31, 116.58197, 40.06665' 第一列是驾驶员id,第二列是时间戳,第三列是经度,第四列是纬度 我正在使用

我有这样的GIS数据-

'111, 2011-02-01 20:30:30, 116.50443, 40.00951'  
'111, 2011-02-01 20:30:31, 116.50443, 40.00951'  
'112, 2011-02-01 20:30:30, 116.58197, 40.06665'  
'112, 2011-02-01 20:30:31, 116.58197, 40.06665'  
第一列是驾驶员id,第二列是时间戳,第三列是经度,第四列是纬度

我正在使用Flume接收这种类型的数据&我的接收器是HBase(type-
AsyncHBaseSink
)。
默认情况下,HBase将rowkey指定为第一列(如111)。我想创建一个复合行键(如前两列的组合111_2011-02-01 20:30:30)。
我尝试将所需的更改放在“
AsyncHbaseLogEventSerializer.java
”中,但没有反映出来


请建议如何执行相同操作。

复合密钥应在AsyncHbaseSerializer中工作

下面是示例代码片段

在类级别声明
privae List put=null

 /**
     * Method joinRowKeyContent. (with EMPTY string separation)
     * 
      * Joiner is google guava class
     * @param objArray Object...
     * 
     * @return String
     */
    public static String joinRowKeyContent(Object... objArray) {
        return Joiner.on("").appendTo(new StringBuilder(), objArray).toString();
    }

 /**
     * Method preParePutRequestForBody.
     * 
     * @param rowKeyBytes
     * @param timestamp
     */
    private void preParePutRequest(final byte[] rowKeyBytes, final long timestamp) {
        // Process 

            LOG.debug("Processing ..." + Bytes.toString(rowKeyBytes));

        final PutRequest putreq = new PutRequest(table, rowKeyBytes, colFam, Bytes.toBytes("yourcolumn"), yourcolumnasBytearray, timestamp);
        puts.add(putreq);
    }
您的get actions方法看起来像

@覆盖
公共列表getActions(){
//像这样创建行键
最终字符串rowKey=joinRowKeyContent(驱动程序id、时间戳、经度、纬度);
//在此处调用prepare-put-requests方法
最终字节[]rowKeyBytes=字节.toBytes(rowKey);
puts.clear();
preParePutRequest(rowKeyBytes,)
收益看跌期权;
}

composite rowkey应该可以工作,使用这样的键是正常的。你能粘贴你的代码片段吗?请检查示例片段,根据我的经验,这应该是可能的(如果你没有犯过简单的错误):-:我的答案有用吗。
  @Override
        public List<PutRequest> getActions() {
//create rowkey like this
    final String rowKey = joinRowKeyContent(driver_id, timestamp, longitude , latitude);

    // call prepare put requests method here 
    final byte[] rowKeyBytes = Bytes.toBytes(rowKey);
                puts.clear();
     preParePutRequest(rowKeyBytes ,<timestamp>)
            return puts;
        }