首页 > 代码库 > python thrift 进行filter

python thrift 进行filter

介于我百度的时候发现文档比较少 就写一下防止忘记

SingleColumnValueFilter(‘<family>‘, ‘<qualifier>‘, <compare operator>, ‘<comparator>‘, <filterIfColumnMissing_boolean>, <latest_version_boolean>)
filterStr = "SingleColumnValueFilter(‘entry‘, ‘num‘, =, ‘substring:25‘, true, false)";


note:
comparator需要加binary, 否则可能会抛错误, 我也想想是为什么
rownumber 可以把符合条件的 rownumber 个选出来 而不是选rownumber再进行filter
filter = "SingleColumnValueFilter(‘f1‘, ‘ax‘, =, ‘binary:-1‘, true, false)"
s = t.scannerListWithFilter(table = ‘M_SEED_USER‘,filter = filter, numRows=500)



scan = Hbase.TScan()
#scan = Hbase.TScan()
scan.filterString = filter
scan.startRow = startRow
scan.stopRow = stopRow
scannerId = self.client.scannerOpenWithScan(table, scan, {})

这样就可以把columnfamily为f1的column ax = -1 的值取出来
 



 

python thrift 进行filter