0

Is it possible to get only a limited number of columns for a column family from a row? Lets say I just want to fetch the first 10 values for ['cf1': 'col1'] for a particular row.

Smern
  • 18,746
  • 21
  • 72
  • 90

2 Answers2

3

This is the same question as https://github.com/wbolster/happybase/issues/93

The answer is:

I think the only way to do this is a scan with a server side filter. I think the one you're after is the ColumnCountGetFilter:

ColumnCountGetFilter - takes one argument, a limit. It returns the first limit number of columns in the table. Syntax: ColumnCountGetFilter (‘’) Example: ColumnCountGetFilter (4)

Source: http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/admin_hbase_filtering.html

With Happybase that would look like this (untested):

for row_key, data in table.scan(columns=['cf1'], filter='ColumnCountGetFilter(10)'):
    print(row_key, data)
wouter bolsterlee
  • 3,879
  • 22
  • 30
0

use limit to get specific row in hbase

table.scan(limit=int(limit)