Support Questions

Find answers, ask questions, and share your expertise

versioning question in hbase

Master Collaborator

I can select a particular version from a table , but how can I select a range of versions ? e.g say I want to select all the rows from timestamp 1551108073557 to 1551108018724 ?


hbase(main):005:0> scan 'PERSON',{NAME => 'student',VERSIONS => 5}
ROW COLUMN+CELL
r1 column=student:student_name, timestamp=1551108086986, value=John
r1 column=student:student_name, timestamp=1551108073557, value=Mary
r1 column=student:student_name, timestamp=1551108037609, value=Nancy
r1 column=student:student_name, timestamp=1551108018724, value=Ram
r1 column=student:student_name, timestamp=1551108002231, value=Sam
1 row(s) in 0.0190 seconds

hbase(main):006:0>
hbase(main):007:0*
hbase(main):008:0* get 'PERSON','r1',{COLUMN => 'student', TIMESTAMP => 1551108018724}
COLUMN CELL
student:student_name timestamp=1551108018724, value=Ram

1 ACCEPTED SOLUTION

hbase(main):001:0> help 'scan'
Scan a table; pass table name and optionally a dictionary of scanner
specifications.  Scanner specifications may include one or more of:
TIMERANGE, FILTER, LIMIT, STARTROW, STOPROW, ROWPREFIXFILTER, TIMESTAMP,
MAXLENGTH or COLUMNS, CACHE or RAW, VERSIONS, ALL_METRICS or METRICS

...

Some examples:

  ...
  hbase> scan 't1', {COLUMNS => 'c1', TIMERANGE => [1303668804000, 1303668904000]}

View solution in original post

4 REPLIES 4

hbase(main):001:0> help 'scan'
Scan a table; pass table name and optionally a dictionary of scanner
specifications.  Scanner specifications may include one or more of:
TIMERANGE, FILTER, LIMIT, STARTROW, STOPROW, ROWPREFIXFILTER, TIMESTAMP,
MAXLENGTH or COLUMNS, CACHE or RAW, VERSIONS, ALL_METRICS or METRICS

...

Some examples:

  ...
  hbase> scan 't1', {COLUMNS => 'c1', TIMERANGE => [1303668804000, 1303668904000]}

Master Collaborator

hi Josh how can I do it via 'get' command ? since we will be using java to get these rows

Use a Scanner. You can't use Gets, as a Get requires you to know a rowKey.

Master Collaborator

and can "scan" command be called from a java code ?