Reputation: 1065
I have Randonnee Table with 2 family columns
Info: Name, region, suite
Tech: distance, denivele
I have this Data on my Table Randonnee
(id, Name, region, distance, denivele, suite)
(1, 'Monts du Djurdjura', 'Tizi Ouzou', 35, 1000, NULL);
(2, 'Circuit de Misserghin', 'Oran', 25 , 514, NULL);
(3, 'Montagne de Murdjadju', 'Oran', 31, 1100, NULL);
(4, 'Canastel', 'Oran', 18, 890, 3);
(5, 'Yama Gouraya', 'Bejaia', 19, 900, NULL);
(6, 'Sidi Makhlouf', 'Blida', 8, 165, 8);
(7, 'Tikjda', 'Tizi Ouzou', 10, 1900, NULL);
(8, 'Feroukha', 'Blida', 14.18, 454, NULL);
(9, 'Chrea Azzazga', 'Tizi Ouzou', 6.23, 1548, 11);
I want to get the distance of randonne where Name is 'Montagne de Murdjadu'
I tryed this query :
scan 'randonnee',{COLUMN=>'info:Name',FILTER=>"ValueFilter(=, 'binary:Montagne de Murdjadju')"}
but the problem that she gives me the id in return, not the distance
ROW COLUMN+CELL
3 column=info:nom, timestamp=1509960875652, value=Montagne de Murdjadju
How I get the distance?
Upvotes: 2
Views: 5791
Reputation: 1065
this Query give me the distance fo randonnee where Name is 'Montagne de Murdjadu'
scan 'randonnee',{FILTER=>"SingleColumnValueFilter('info', 'Name', =,'binary:Montagne de Murdjadju') AND ColumnPrefixFilter ('distance')"}
or
scan 'randonnee',{FILTER=>"SingleColumnValueFilter('info', 'Name', =,'binary:Montagne de Murdjadju') AND QualifierFilter(=,'binary:distance') "}
result :
ROW COLUMN+CELL
3 column=tech:dist, timestamp=1509961960359, value=31
Upvotes: 0
Reputation: 690
You can use the SingleColumnValueFilter
. In hbase shell you can do the following to get the distance
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
import org.apache.hadoop.hbase.util.Bytes
scan 'randonnee', {COLUMNS=>['tech:distance'], FILTER=>SingleColumnValueFilter.new(Bytes.toBytes('info'),Bytes.toBytes('name'),CompareFilter::CompareOp.valueOf('EQUAL'),Bytes.toBytes('Montagne de Murdjadju'))}
Upvotes: 2