簡體   English   中英

如何通過 Hbase 中的行鍵和單元格掃描特定列值?

[英]How to scan for a particular column value by rowkey and cell in Hbase?

我對 Hbase 很陌生,我有一個包含幾列(hebe_30、hebe_31 等)的 HBase 表,其中code+date是行鍵。

我有如下數據

  ROW                                COLUMN+CELL                                                                                       
 000330-20180131                   column=atune:hebe_30, timestamp=1574324850676, value=3.0                                                
 000330-20180131                   column=atune:hebe_31, timestamp=1574324850676, value=6.0                                                
 000330-20180201                   column=atune:hebe_32, timestamp=1574324849744, value=68.0                                                
 000330-20180201                   column=atune:hebe_33, timestamp=1574324849744, value=88.0                                                
 000330-20180202                   column=atune:hebe_34, timestamp=1574324855557, value=330.0

Python中的code+date+cell如何獲取記錄? 比如000330-20180131-hebe_30 ,不知道用哪個過濾器? 在 Hbase 中是否有任何CASE WHEN, WHERE OR HAVING方法,例如 SQL 查詢? 下面 python 代碼可以通過code+date掃描一條記錄,我必須讓atune:hebe_30為默認參數,但我們需要的是code+date+atune:self.hebe_**

import pandas as pd
from db_connect import impala, hbasecon, ATUNETABLE


class query:
    def __init__(self, code='', date=''):
        self.code = code
        self.date = date
        self.hintltable = hbasecon(table=ATUNETABLE).gettable()

    def atune_hebe(self):
        val_end = ''
        rows_end = self.hintltable.scan(
                row_start=self.code + '-' + self.date,
                row_stop=self.code + '-00000000' ,
                columns=['atune:hebe_30'], reverse=True, limit=1
        )

        for k, v in rows_end:
            val_end = eval(v['atune:hebe_30'])
        return {"val": {"0": val_end}}

非常感謝您的任何建議

您可以使用ColumnPrefixFilter
我猜在 python 中它看起來像:

for k, v in table.scan(filter="ColumnPrefixFilter('your_prsifx_str')"):
    print k

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM