简体   繁体   中英

how to get multiple columns using HBase shell

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?

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'))}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM