hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Yu <yuzhih...@gmail.com>
Subject Re: help for a fee -- using filters to search data in hbase for correct results
Date Fri, 03 Feb 2017 22:26:04 GMT
Dropping dev@

Can you format your code in more readable style such as the following ?

http://pastebin.com/CQMdf4pc

Also separate code and description instead of mixing them together.

Which release of hbase are you using ?

Thanks

On Fri, Feb 3, 2017 at 2:14 PM, Yoom Nguyen <yoom@misoccer.us> wrote:

>
>
> I am having problems using filters to search data in hbase .
> First I am reading some data from one table and storing in a vector or
> arrayList : Is there a better way or different approach to achieve the
> results than what I am heading?
> I am stuck trying to get the correct results with the following approach.
> Wondering if any one know HBASE \ Java well and willing to help out for a
> fee. I need to get over this problem.
> If anyone is willing to help for a fee, send me an email at yoom @
> misoccer .us
>
> for ( Result r : rs ) { for ( KeyValue kv : r . raw ()) { if ( new String
> ( kv . getFamily ()). equals ( "name" )) { temp = new String ( kv .
> getValue ()); x . addElement ( temp ); } } }
> Then, I want to search a different table based on the values of this
> vector. I used filters to do this: (I tried BinaryPrefixComparator and
> BinaryComparator as well) FilterList filterList = new FilterList (
> FilterList . Operator . MUST_PASS_ONE ); for ( int c = 0 ; c < x . size ();
> c ++) { System . out . println ( x . get ( c ). toString ()); filterList .
> addFilter ( new SingleColumnValueFilter ( Bytes . toBytes ( "name" ), null
> , CompareOp . EQUAL , new SubstringComparator ( x . get ( c ). toString ()
> ))); }
> I should get 3 results back, however I only get one result back, the first
> entry in the database. What doesn't make sense is that when I hardcode the
> value that I am looking for into my code, I will get all 3 results back.
> I thought there might be some issue with converting the bytes to String
> and then back to bytes, but that would not explain how it was able to bring
> back the first result. For some reason, it is stopping at the first match
> and doesn't continue to find the other 2 rows that contain matching data.
> If I hardcode it i get the results: x . addElement ( "abc123" ); filterList
> . addFilter ( new SingleColumnValueFilter ( Bytes . toBytes ( "name" ),
> null , CompareOp . EQUAL , new SubstringComparator ( x . get ( 0 ).
> toString () )));
> Does anyone know what the problem is or what I need to do to resolve my
> issue? Your help is much appreciated.
> Thank You
> edit: Here is the contents of the tables:
> TABLE1: ROW COLUMN+CELL
> 0 column= gpnum :, timestamp =1481300288449, value=def123
> 0 column= mpnum :, timestamp =1481300273355, value= abc123
> 0 column=price:, timestamp =1481300255337, value=85.0
> 1 column= gpnum :, timestamp =1481301599999, value=def2244
> 1 column= mpnum :, timestamp =1481301582336, value= 011511607
> 1 column=price:, timestamp =1481301673886, value=0.76
> TABLE2
> ROW COLUMN+CELL
> 0 column=brand:, timestamp =1481300227283, value=x
> 0 column= mpnum :, timestamp =1481300212289, value= abc123
> 0 column=price:, timestamp =1481300110950, value=50.0
> 1 column= mpnum :, timestamp =1481301806687, value= 011511607
> 1 column=price:, timestamp =1481301777345, value=1.81
> 13 column= webtype :, timestamp =1483507543878, value=US
> 3 column=avail:, timestamp =1481306538360, value=avail
> 3 column=brand:, timestamp =1481306538360, value=brand
> 3 column= descr :, timestamp =1481306538360, value=description
> 3 column=dist:, timestamp =1481306538360, value=distributor
> 3 column= mpnum :, timestamp =1481306538360, value= pnum
> 3 column=price:, timestamp =1481306538360, value=price
> 3 column= url :, timestamp =1481306538360, value= url
> 3 column= webtype :, timestamp =1481306538360, value= webtype
> 4 column=avail:, timestamp =1481306538374, value=4
> 4 column=brand:, timestamp =1481306538374, value=x
> 4 column= descr :, timestamp =1481306538374, value=description
> 4 column=dist:, timestamp =1481306538374, value=x
> 4 column= mpnum :, timestamp =1482117383212, value= 011511607
> 4 column=price:, timestamp =1481306538374, value=34.51
> 4 column= url :, timestamp =1481306538374, value=x
> 4 column= webtype :, timestamp =1481306538374, value=US
> 5 column=avail:, timestamp =1481306538378, value=
> 5 column=brand:, timestamp =1481306538378, value=name
> 5 column= descr :, timestamp =1481306538378, value=x
> 5 column=dist:, timestamp =1481306538378, value=x
> 5 column= mpnum :, timestamp =1482117392043, value= 011511607
> 5 column=price:, timestamp =1481306538378, value=321.412
> 5 column= url :, timestamp =1481306538378, value=x.com
> THIRD TABLE (to store result matches)
> 0 column=brand:, timestamp =1481301813849, value=name
> 0 column= cprice :, timestamp =1481301813849, value=1.81
> 0 column= gpnum :, timestamp =1481301813849, value=def2244
> 0 column= gprice :, timestamp =1481301813849, value=0.76
> 0 column= mpnum :, timestamp =1481301813849, value=011511607
> **should be three matches those that are in bold above but only brings
> back one match
> If anyone is willing to help for a fee, send me an email at yoom @
> misoccer .us
>
>
> Thanks,
> Yoom
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message