hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Artyom Shvedchikov <sho...@gmail.com>
Subject Re: Help using partial-key lookup and compound keys.
Date Thu, 05 Nov 2009 20:27:34 GMT
Hallo, Kevin
Thanks a lot for your help. Today we tried to use row key prefixes for
searching and it works fine for us :-)
-------------------------------------------------
Best wishes, Artyom Shvedchikov


On Thu, Nov 5, 2009 at 12:51 AM, Kevin Peterson <kpeterson@biz360.com>wrote:

> On Tue, Nov 3, 2009 at 2:13 PM, Artyom Shvedchikov <shoolc@gmail.com>
> wrote:
>
> > Hallo, folks.
> >
> > We want to use partial-key lookup and compound keys (search using them)
> > with
> > Java API.
> > Can someone to provide info and example on using such keys and lookups.
> >
> >
> I'm not sure I understand you correctly, but partial key is fine as long as
> you are using a prefix.
>
> For example, if your key consists of account:timestamp:event_id, you would
> need to make sure that all these values are fixed width -- make account id
> an int, not a string, same thing with timestamp. To build your keys do
> something like
>
> byte[] row = Bytes.add(Bytes.toBytes(acctId), Bytes.toBytes(time),
> Bytes.toBytes(eventId))
>
> Then to get all rows matching a given account and timestamp, do
>
> byte[] startRow = Bytes.add(Bytes.toBytes(acctId), Bytes.toBytes(time));
> byte[] endRow = Bytes.add(Bytes.toBytes(acctId), Bytes.toBytes(time + 1));
> ResultScanner scanner = table.getScanner(new Scan(startRow, endRow));
>
> If you want to search by something that isn't a prefix of your row key,
> then
> you will need to either user a scanner filter or look into table indexed.
>

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