Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of Order By operation in HBase

Tags:

sql

hbase

Am working on a project which uses HBase. Even though I formed the rowkey as good as possible, still in some scenarios I need to get the results in either ascending or descending order. Is there anything in HBase which is equivalent to "order by" operation in MySQL? Or is Order By on a specific column qualifier possible in HBase?

like image 534
Jayan Kuttagupthan Avatar asked May 12 '12 02:05

Jayan Kuttagupthan


2 Answers

No; you need to read the data in the order it's sorted in the row key, then do your own sort (e.g. in java or whatever language you're using).

like image 200
Ian Varley Avatar answered Sep 21 '22 02:09

Ian Varley


I know post is old but for future reference. Scan (Hbase 0.98+) now supports setReversed

public Scan setReversed(boolean reversed)
  Set whether this scan is a reversed one
  This is false by default which means forward(normal) scan.

Parameters:
 reversed - if true, scan will be backward order
Returns:

Ref:- Hbase Scan Tutorial

like image 38
Jack Daniel's Avatar answered Sep 20 '22 02:09

Jack Daniel's