【问题标题】:Finding rows with a certain column value in another row in a HBase table during mapreduce在mapreduce期间在HBase表的另一行中查找具有特定列值的行
【发布时间】:2023-03-03 15:46:01
【问题描述】:

我正在使用 HBase 表来存储事件,并且我想使用其响应事件的输出来更新请求事件。这两个值都存储在 HBase 表中的两个不同行上。

这是我遇到的两难境地。我想使用一个 mapreduce 作业,它将接收所有响应行,并使用响应行的状态更新请求行。响应和请求都具有匹配的用户 ID,但行由相关 ID 索引。 rowkey 的格式是 (event_corrID_userID)。从现在到那时,相关 ID 可能已更改,但用户 ID 将始终相同。

这就是我的全部情况。如何在 mapreduce 期间在表中(在其他行中)进行搜索?到目前为止,这是我所拥有的:

public class MapReducer {
    public static void main(String[] args){
        Configuration config = HBaseConfiguration.create();
        try{
            String startRow = "response_";
            String endRow = "responsf_";
            Job job = new Job(config, "TestAuditingResponse");
            job.setJarByClass(MapReducer.class);
            Scan scan = new Scan(Bytes.toBytes(startRow), Bytes.toBytes(endRow));
            scan.setCaching(500);
            scan.setCacheBlocks(false);

            TableMapReduceUtil.initTableMapperJob(
                    "test",
                    scan,
                    mapper.class,
                    null,
                    null,
                    job);
            TableMapReduceUtil.initTableReducerJob(
                    "test",
                    null,
                    job);
            job.setNumReduceTasks(0);

            boolean b = job.waitForCompletion(true);
            if(!b){
                throw new IOException("ERROR WITH JOB");
            }
        } catch(IOException e){
            e.printStackTrace();
        } catch(ClassNotFoundException e){
            e.printStackTrace();
        } catch(InterruptedException e){
            e.printStackTrace();
        }
    }
    public static class mapper extends TableMapper<ImmutableBytesWritable, Put> {
        public void map(ImmutableBytesWritable row, Result value, Context context) throws IOException, InterruptedException {
            //TODO find row to put new value into
        }
    }

}

有人知道我该怎么做吗?或者以分布式/易于运行的方式基于表中的其他行更新表的更好/更快的方法?

【问题讨论】:

    标签: hadoop mapreduce hbase


    【解决方案1】:

    似乎您要“加入”内部一张表。你可以看看这个new feature

    【讨论】:

    • 查看它,这似乎允许我提前设置扫描,然后将两者都传入,它将按顺序运行扫描。似乎这不允许您在表格中查看另一行,因为我必须提前通过扫描?当我可以访问当前行的关联 ID 和声明 ID 时,我仍然需要确定要查找的行,所以我不知道我是否真的可以像这样提前设置它?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-02
    • 2016-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多