|
Michelan Arendse
2010-08-17, 11:51
Andrey Stepachev
2010-08-17, 12:59
Ryan Rawson
2010-08-17, 19:01
Andrey Stepachev
2010-08-18, 05:31
Michelan Arendse
2010-08-23, 10:00
Samuru Jackson
2010-08-23, 14:32
Samuru Jackson
2010-08-23, 18:28
Andrey Stepachev
2010-08-23, 19:06
Andrey Stepachev
2010-08-23, 19:10
Michelan Arendse
2010-08-24, 14:58
Andrey Stepachev
2010-08-24, 20:36
|
-
Scanning half a key or value in HBaseMichelan Arendse 2010-08-17, 11:51
Hi
I am not sure if this is possible in HBase. What I am trying to do is scan on a HBase table with something similar to how SQL would do it. e.g. SELECT * FROM <table> WHERE <primary key> LIKE '<first_half_of_key>%' ; So as you can see from above I want to scan the table with only part of the row key, since the key is a combination of 2 fields in the table. Regards, Michelan Arendse
-
Re: Scanning half a key or value in HBaseAndrey Stepachev 2010-08-17, 12:59
Use scan where start key is <first_half_of_key> itself as bytearray, and
stop key is <first_half_of_key> with last byte in bytearray + 1. example abc% should be scan(abc, abd) 2010/8/17 Michelan Arendse <[EMAIL PROTECTED]>: > Hi > > I am not sure if this is possible in HBase. What I am trying to do is scan on a HBase table with something similar to how SQL would do it. > e.g. SELECT * > FROM <table> > WHERE <primary key> LIKE '<first_half_of_key>%' ; > > So as you can see from above I want to scan the table with only part of the row key, since the key is a combination of 2 fields in the table. > > Regards, > Michelan Arendse > > >
-
Re: Scanning half a key or value in HBaseRyan Rawson 2010-08-17, 19:01
Hey,
One thing to watch out for is ascii with separator variable length keys, you would think if your key structure was: foo:bar starting at 'foo' and ending at 'foo:' might give you only keys which start with 'foo:' but this doesn't work like that. You also get keys like: foo123:bar you must start the scan at 'foo:' but you can't just end it at 'foo;' (since next(:) == ';' in ascii), this has to do with the ordering of ASCII, for a reference look at http://www.asciitable.com/ The bug-free solution is to start your scan at 'foo:' and use a prefix filter set to 'foo:'. If you are scanning fixed-width keys, eg: binary conversions of longs, then the [start,start+1) solution works. On Tue, Aug 17, 2010 at 5:59 AM, Andrey Stepachev <[EMAIL PROTECTED]> wrote: > Use scan where start key is <first_half_of_key> itself as bytearray, and > stop key is <first_half_of_key> with last byte in bytearray + 1. > > example > abc% should be scan(abc, abd) > > 2010/8/17 Michelan Arendse <[EMAIL PROTECTED]>: >> Hi >> >> I am not sure if this is possible in HBase. What I am trying to do is scan on a HBase table with something similar to how SQL would do it. >> e.g. SELECT * >> FROM <table> >> WHERE <primary key> LIKE '<first_half_of_key>%' ; >> >> So as you can see from above I want to scan the table with only part of the row key, since the key is a combination of 2 fields in the table. >> >> Regards, >> Michelan Arendse >> >> >> >
-
Re: Scanning half a key or value in HBaseAndrey Stepachev 2010-08-18, 05:31
2010/8/17 Ryan Rawson <[EMAIL PROTECTED]>:
> Hey, > > > If you are scanning fixed-width keys, eg: binary conversions of longs, > then the [start,start+1) solution works. > Why? It will work for any byte array, if we want to prefix scan. And no matter, what key encoding we use. If we look at first email question, we see '<first_half_of_key>%', so if first_half_of_key = 'foo' we _should_ get all keys foo, foo:, foo1234, because we want this. My solution was to convert requested first_half_of_key to byte[] arr = ... Then do (pseudocode) arr = toBytes(first_half_of_key) arr2 = arr.clone(), arr2[arr2.length-1]++, STARTROW = arr, STOPROW = arr2; This gives us real stop key, which will be greater, then any key, prefixed with given prefix (due of nature of binary comparators, used by hbase). Or I missed something ?
-
RE: Scanning half a key or value in HBaseMichelan Arendse 2010-08-23, 10:00
Hi,
Thanks for the responses but it's still not what I am really looking for. The row id looks something like: number_string so it would be 123_foo, 123_foo2 123_foo3. So now I want to find all the foo's that are related to the first half of the key which is "123". Also I can't add start row if I do not know where 123 starts. And I can't search for the start row, as I need this to be very fast. Thanks. -----Original Message----- From: Ryan Rawson [mailto:[EMAIL PROTECTED]] Sent: 17 August 2010 09:01 PM To: [EMAIL PROTECTED] Subject: Re: Scanning half a key or value in HBase Hey, One thing to watch out for is ascii with separator variable length keys, you would think if your key structure was: foo:bar starting at 'foo' and ending at 'foo:' might give you only keys which start with 'foo:' but this doesn't work like that. You also get keys like: foo123:bar you must start the scan at 'foo:' but you can't just end it at 'foo;' (since next(:) == ';' in ascii), this has to do with the ordering of ASCII, for a reference look at http://www.asciitable.com/ The bug-free solution is to start your scan at 'foo:' and use a prefix filter set to 'foo:'. If you are scanning fixed-width keys, eg: binary conversions of longs, then the [start,start+1) solution works. On Tue, Aug 17, 2010 at 5:59 AM, Andrey Stepachev <[EMAIL PROTECTED]> wrote: > Use scan where start key is <first_half_of_key> itself as bytearray, and > stop key is <first_half_of_key> with last byte in bytearray + 1. > > example > abc% should be scan(abc, abd) > > 2010/8/17 Michelan Arendse <[EMAIL PROTECTED]>: >> Hi >> >> I am not sure if this is possible in HBase. What I am trying to do is scan on a HBase table with something similar to how SQL would do it. >> e.g. SELECT * >> FROM <table> >> WHERE <primary key> LIKE '<first_half_of_key>%' ; >> >> So as you can see from above I want to scan the table with only part of the row key, since the key is a combination of 2 fields in the table. >> >> Regards, >> Michelan Arendse >> >> >> >
-
Re: Scanning half a key or value in HBaseSamuru Jackson 2010-08-23, 14:32
Hi,
I do it this way: The variable searchValue is my Prefix like in your case 123 would be: searchValue = "123"; PrefixFilter prefixFilter = new PrefixFilter(Bytes.toBytes(searchValue)); Scan scan = new Scan(); scan.addFamily(Bytes.toBytes(this.REF_FAM)); scan.setFilter(prefixFilter); ResultScanner resultScanner = hBaseTable.getScanner(scan); Now you can iterate over the resultScanner. Is this what you were looking for? /SJ On Mon, Aug 23, 2010 at 6:00 AM, Michelan Arendse <[EMAIL PROTECTED]> wrote: > Hi, > > Thanks for the responses but it's still not what I am really looking for. > > The row id looks something like: number_string so it would be 123_foo, 123_foo2 123_foo3. > So now I want to find all the foo's that are related to the first half of the key which is "123". > > Also I can't add start row if I do not know where 123 starts. And I can't search for the start row, as I need this to be very fast. > > Thanks. > > > -----Original Message----- > From: Ryan Rawson [mailto:[EMAIL PROTECTED]] > Sent: 17 August 2010 09:01 PM > To: [EMAIL PROTECTED] > Subject: Re: Scanning half a key or value in HBase > > Hey, > > One thing to watch out for is ascii with separator variable length > keys, you would think if your key structure was: > > foo:bar > > starting at 'foo' and ending at 'foo:' might give you only keys which > start with 'foo:' but this doesn't work like that. You also get keys > like: > foo123:bar > > you must start the scan at 'foo:' but you can't just end it at 'foo;' > (since next(:) == ';' in ascii), this has to do with the ordering of > ASCII, for a reference look at http://www.asciitable.com/ > > The bug-free solution is to start your scan at 'foo:' and use a prefix > filter set to 'foo:'. > > If you are scanning fixed-width keys, eg: binary conversions of longs, > then the [start,start+1) solution works. > > On Tue, Aug 17, 2010 at 5:59 AM, Andrey Stepachev <[EMAIL PROTECTED]> wrote: >> Use scan where start key is <first_half_of_key> itself as bytearray, and >> stop key is <first_half_of_key> with last byte in bytearray + 1. >> >> example >> abc% should be scan(abc, abd) >> >> 2010/8/17 Michelan Arendse <[EMAIL PROTECTED]>: >>> Hi >>> >>> I am not sure if this is possible in HBase. What I am trying to do is scan on a HBase table with something similar to how SQL would do it. >>> e.g. SELECT * >>> FROM <table> >>> WHERE <primary key> LIKE '<first_half_of_key>%' ; >>> >>> So as you can see from above I want to scan the table with only part of the row key, since the key is a combination of 2 fields in the table. >>> >>> Regards, >>> Michelan Arendse >>> >>> >>> >> >
-
Re: Scanning half a key or value in HBaseSamuru Jackson 2010-08-23, 18:28
One thing I forgot:
You will need to add the separator to your search value (In your case underscore): searchValue = "123" + "_"; Otherwise you might get unwanted multiple results! /SJ On Mon, Aug 23, 2010 at 10:32 AM, Samuru Jackson < [EMAIL PROTECTED]> wrote: > Hi, > > I do it this way: > > The variable searchValue is my Prefix like in your case 123 would be: > > searchValue = "123"; > > PrefixFilter prefixFilter = new PrefixFilter(Bytes.toBytes(searchValue)); > Scan scan = new Scan(); > scan.addFamily(Bytes.toBytes(this.REF_FAM)); > scan.setFilter(prefixFilter); > ResultScanner resultScanner = hBaseTable.getScanner(scan); > > Now you can iterate over the resultScanner. > > Is this what you were looking for? > > /SJ > > > > > > On Mon, Aug 23, 2010 at 6:00 AM, Michelan Arendse <[EMAIL PROTECTED]> > wrote: > > Hi, > > > > Thanks for the responses but it's still not what I am really looking for. > > > > The row id looks something like: number_string so it would be 123_foo, > 123_foo2 123_foo3. > > So now I want to find all the foo's that are related to the first half of > the key which is "123". > > > > Also I can't add start row if I do not know where 123 starts. And I can't > search for the start row, as I need this to be very fast. > > > > Thanks. > > > > > > -----Original Message----- > > From: Ryan Rawson [mailto:[EMAIL PROTECTED]] > > Sent: 17 August 2010 09:01 PM > > To: [EMAIL PROTECTED] > > Subject: Re: Scanning half a key or value in HBase > > > > Hey, > > > > One thing to watch out for is ascii with separator variable length > > keys, you would think if your key structure was: > > > > foo:bar > > > > starting at 'foo' and ending at 'foo:' might give you only keys which > > start with 'foo:' but this doesn't work like that. You also get keys > > like: > > foo123:bar > > > > you must start the scan at 'foo:' but you can't just end it at 'foo;' > > (since next(:) == ';' in ascii), this has to do with the ordering of > > ASCII, for a reference look at http://www.asciitable.com/ > > > > The bug-free solution is to start your scan at 'foo:' and use a prefix > > filter set to 'foo:'. > > > > If you are scanning fixed-width keys, eg: binary conversions of longs, > > then the [start,start+1) solution works. > > > > On Tue, Aug 17, 2010 at 5:59 AM, Andrey Stepachev <[EMAIL PROTECTED]> > wrote: > >> Use scan where start key is <first_half_of_key> itself as bytearray, and > >> stop key is <first_half_of_key> with last byte in bytearray + 1. > >> > >> example > >> abc% should be scan(abc, abd) > >> > >> 2010/8/17 Michelan Arendse <[EMAIL PROTECTED]>: > >>> Hi > >>> > >>> I am not sure if this is possible in HBase. What I am trying to do is > scan on a HBase table with something similar to how SQL would do it. > >>> e.g. SELECT * > >>> FROM <table> > >>> WHERE <primary key> LIKE '<first_half_of_key>%' ; > >>> > >>> So as you can see from above I want to scan the table with only part of > the row key, since the key is a combination of 2 fields in the table. > >>> > >>> Regards, > >>> Michelan Arendse > >>> > >>> > >>> > >> > > > >
-
Re: Scanning half a key or value in HBaseAndrey Stepachev 2010-08-23, 19:06
Really, solution will be (if I understand correctly), to set start key
to "123".getBytes(). and stop key set to "124".getBytes(). (stop key can be produced by incrementing last byte in start key). And we get exact all keys you mentioned before. really. because if we sort keys by Bytes.BYTES_COMPARATOR we get what we want: keys: "123foo" "123_foo", "123_foo3" ["1", "2", "2", ..... any other byte sequence of any length ! less then start key ["1", "2", "3"] <= start key (exactly 3 bytes is always greater (lexicographical byte order) then any prefixed with 122, and always less then any key prefixed with 123) ["1", "2", "3", "_", "f", "o", "o"] ["1", "2", "3", "_", "f", "o", "o", "3"] ["1", "2", "4"] <= stop key! Similar to start key. We always get stop scanning if we get 124... as prefix. So, you can scan without of any knowledge of exact start/stop keys. In case of separator, start key will be 123_ and stop key will be last byte +1 _before separator_. Try to experiment with Bytes.BYTES_COMPARATOR. With scan like above you can get all rows very fast (because they will be with height probability in one block). Don't forget to set caching on scan to higher values (100?), because by default you get only one row in one round trip to server. 2010/8/23 Michelan Arendse <[EMAIL PROTECTED]>: > Hi, > > Thanks for the responses but it's still not what I am really looking for. > > The row id looks something like: number_string so it would be 123_foo, 123_foo2 123_foo3. > So now I want to find all the foo's that are related to the first half of the key which is "123". > > Also I can't add start row if I do not know where 123 starts. And I can't search for the start row, as I need this to be very fast. > > Thanks. > > > -----Original Message----- > From: Ryan Rawson [mailto:[EMAIL PROTECTED]] > Sent: 17 August 2010 09:01 PM > To: [EMAIL PROTECTED] > Subject: Re: Scanning half a key or value in HBase > > Hey, > > One thing to watch out for is ascii with separator variable length > keys, you would think if your key structure was: > > foo:bar > > starting at 'foo' and ending at 'foo:' might give you only keys which > start with 'foo:' but this doesn't work like that. You also get keys > like: > foo123:bar > > you must start the scan at 'foo:' but you can't just end it at 'foo;' > (since next(:) == ';' in ascii), this has to do with the ordering of > ASCII, for a reference look at http://www.asciitable.com/ > > The bug-free solution is to start your scan at 'foo:' and use a prefix > filter set to 'foo:'. > > If you are scanning fixed-width keys, eg: binary conversions of longs, > then the [start,start+1) solution works. > > On Tue, Aug 17, 2010 at 5:59 AM, Andrey Stepachev <[EMAIL PROTECTED]> wrote: >> Use scan where start key is <first_half_of_key> itself as bytearray, and >> stop key is <first_half_of_key> with last byte in bytearray + 1. >> >> example >> abc% should be scan(abc, abd) >> >> 2010/8/17 Michelan Arendse <[EMAIL PROTECTED]>: >>> Hi >>> >>> I am not sure if this is possible in HBase. What I am trying to do is scan on a HBase table with something similar to how SQL would do it. >>> e.g. SELECT * >>> FROM <table> >>> WHERE <primary key> LIKE '<first_half_of_key>%' ; >>> >>> So as you can see from above I want to scan the table with only part of the row key, since the key is a combination of 2 fields in the table. >>> >>> Regards, >>> Michelan Arendse >>> >>> >>> >> >
-
Re: Scanning half a key or value in HBaseAndrey Stepachev 2010-08-23, 19:10
If my table is huge do i get full scan?
I you want to get good performance on random read you really need start and stop keys. PrefixFIlters are usable in compound filters. If you want only one range (like 123_*), you must use start/stop keys. 2010/8/23 Samuru Jackson <[EMAIL PROTECTED]>: > Hi, > > I do it this way: > > The variable searchValue is my Prefix like in your case 123 would be: > > searchValue = "123"; > > PrefixFilter prefixFilter = new PrefixFilter(Bytes.toBytes(searchValue)); > Scan scan = new Scan(); > scan.addFamily(Bytes.toBytes(this.REF_FAM)); > scan.setFilter(prefixFilter); > ResultScanner resultScanner = hBaseTable.getScanner(scan); > > Now you can iterate over the resultScanner. > > Is this what you were looking for? > > /SJ > > > > > On Mon, Aug 23, 2010 at 6:00 AM, Michelan Arendse <[EMAIL PROTECTED]> > wrote: >> Hi, >> >> Thanks for the responses but it's still not what I am really looking for. >> >> The row id looks something like: number_string so it would be 123_foo, > 123_foo2 123_foo3. >> So now I want to find all the foo's that are related to the first half of > the key which is "123". >> >> Also I can't add start row if I do not know where 123 starts. And I can't > search for the start row, as I need this to be very fast. >> >> Thanks. >> >> >> -----Original Message----- >> From: Ryan Rawson [mailto:[EMAIL PROTECTED]] >> Sent: 17 August 2010 09:01 PM >> To: [EMAIL PROTECTED] >> Subject: Re: Scanning half a key or value in HBase >> >> Hey, >> >> One thing to watch out for is ascii with separator variable length >> keys, you would think if your key structure was: >> >> foo:bar >> >> starting at 'foo' and ending at 'foo:' might give you only keys which >> start with 'foo:' but this doesn't work like that. You also get keys >> like: >> foo123:bar >> >> you must start the scan at 'foo:' but you can't just end it at 'foo;' >> (since next(:) == ';' in ascii), this has to do with the ordering of >> ASCII, for a reference look at http://www.asciitable.com/ >> >> The bug-free solution is to start your scan at 'foo:' and use a prefix >> filter set to 'foo:'. >> >> If you are scanning fixed-width keys, eg: binary conversions of longs, >> then the [start,start+1) solution works. >> >> On Tue, Aug 17, 2010 at 5:59 AM, Andrey Stepachev <[EMAIL PROTECTED]> > wrote: >>> Use scan where start key is <first_half_of_key> itself as bytearray, and >>> stop key is <first_half_of_key> with last byte in bytearray + 1. >>> >>> example >>> abc% should be scan(abc, abd) >>> >>> 2010/8/17 Michelan Arendse <[EMAIL PROTECTED]>: >>>> Hi >>>> >>>> I am not sure if this is possible in HBase. What I am trying to do is > scan on a HBase table with something similar to how SQL would do it. >>>> e.g. SELECT * >>>> FROM <table> >>>> WHERE <primary key> LIKE '<first_half_of_key>%' ; >>>> >>>> So as you can see from above I want to scan the table with only part of > the row key, since the key is a combination of 2 fields in the table. >>>> >>>> Regards, >>>> Michelan Arendse >>>> >>>> >>>> >>> >> >
-
RE: Scanning half a key or value in HBaseMichelan Arendse 2010-08-24, 14:58
This works wonderfully have a look at the code cause it's still a bit slow and I need it to be lighting fast.
SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes("Column_Family"), Bytes.toBytes("column1"),CompareOp.EQUAL, new SubstringComparator(value) ); IndexedTable table = new IndexedTable(_hbManager.getConfiguration(), Bytes.toBytes("Table")); ResultScanner scanner = table.getIndexedScanner("IndexId", null, null, null, filter, new byte[][] {Bytes.toBytes("Colum_Family:column1")}); table.close(); return scanner; If I specify the start row then I might miss values that is not at the start of the values. e.g. column1 contains a value that is "0000 aaaa ffff" and then there is "aaaa bbbb cccc" and "cccc aaaa" but I am looking for "aaaa", if I specify the start row then it will only start from where it finds aaaa at the beginning of that string value. -----Original Message----- From: Andrey Stepachev [mailto:[EMAIL PROTECTED]] Sent: 23 August 2010 09:11 PM To: [EMAIL PROTECTED] Subject: Re: Scanning half a key or value in HBase If my table is huge do i get full scan? I you want to get good performance on random read you really need start and stop keys. PrefixFIlters are usable in compound filters. If you want only one range (like 123_*), you must use start/stop keys. 2010/8/23 Samuru Jackson <[EMAIL PROTECTED]>: > Hi, > > I do it this way: > > The variable searchValue is my Prefix like in your case 123 would be: > > searchValue = "123"; > > PrefixFilter prefixFilter = new PrefixFilter(Bytes.toBytes(searchValue)); > Scan scan = new Scan(); > scan.addFamily(Bytes.toBytes(this.REF_FAM)); > scan.setFilter(prefixFilter); > ResultScanner resultScanner = hBaseTable.getScanner(scan); > > Now you can iterate over the resultScanner. > > Is this what you were looking for? > > /SJ > > > > > On Mon, Aug 23, 2010 at 6:00 AM, Michelan Arendse <[EMAIL PROTECTED]> > wrote: >> Hi, >> >> Thanks for the responses but it's still not what I am really looking for. >> >> The row id looks something like: number_string so it would be 123_foo, > 123_foo2 123_foo3. >> So now I want to find all the foo's that are related to the first half of > the key which is "123". >> >> Also I can't add start row if I do not know where 123 starts. And I can't > search for the start row, as I need this to be very fast. >> >> Thanks. >> >> >> -----Original Message----- >> From: Ryan Rawson [mailto:[EMAIL PROTECTED]] >> Sent: 17 August 2010 09:01 PM >> To: [EMAIL PROTECTED] >> Subject: Re: Scanning half a key or value in HBase >> >> Hey, >> >> One thing to watch out for is ascii with separator variable length >> keys, you would think if your key structure was: >> >> foo:bar >> >> starting at 'foo' and ending at 'foo:' might give you only keys which >> start with 'foo:' but this doesn't work like that. You also get keys >> like: >> foo123:bar >> >> you must start the scan at 'foo:' but you can't just end it at 'foo;' >> (since next(:) == ';' in ascii), this has to do with the ordering of >> ASCII, for a reference look at http://www.asciitable.com/ >> >> The bug-free solution is to start your scan at 'foo:' and use a prefix >> filter set to 'foo:'. >> >> If you are scanning fixed-width keys, eg: binary conversions of longs, >> then the [start,start+1) solution works. >> >> On Tue, Aug 17, 2010 at 5:59 AM, Andrey Stepachev <[EMAIL PROTECTED]> > wrote: >>> Use scan where start key is <first_half_of_key> itself as bytearray, and >>> stop key is <first_half_of_key> with last byte in bytearray + 1. >>> >>> example >>> abc% should be scan(abc, abd) >>> >>> 2010/8/17 Michelan Arendse <[EMAIL PROTECTED]>: >>>> Hi >>>> >>>> I am not sure if this is possible in HBase. What I am trying to do is > scan on a HBase table with something similar to how SQL would do it. >>>> e.g. SELECT * >>>> FROM <table> >>>> WHERE <primary key> LIKE '<first_half_of_key>%' ; >>>> >>>> So as you can see from above I want to scan the table with only part of
-
Re: Scanning half a key or value in HBaseAndrey Stepachev 2010-08-24, 20:36
This is another case, because this is not a prefix scan. This is
inclusive scan. In this case of course you should use some techniques, like indexing or full scan with filter. But this is not a real time solution for any noticeable collections of found keys (you can achive ~4ms per record, and for example for 1000 rows you get 4 sec). 2010/8/24 Michelan Arendse <[EMAIL PROTECTED]>: > This works wonderfully have a look at the code cause it's still a bit slow and I need it to be lighting fast. > IndexedTable table = new IndexedTable(_hbManager.getConfiguration(), Bytes.toBytes("Table")); > ResultScanner scanner = table.getIndexedScanner("IndexId", null, null, null, filter, > new byte[][] {Bytes.toBytes("Colum_Family:column1")}); Under the hood IndexedTable perform Get for each found row in index, so you can't achive very fast index scans. Only denormalization can help. > > -----Original Message----- > From: Andrey Stepachev [mailto:[EMAIL PROTECTED]] > Sent: 23 August 2010 09:11 PM > To: [EMAIL PROTECTED] > Subject: Re: Scanning half a key or value in HBase > > If my table is huge do i get full scan? > I you want to get good performance on random read > you really need start and stop keys. > PrefixFIlters are usable in compound filters. If you want > only one range (like 123_*), you must use start/stop keys. > > 2010/8/23 Samuru Jackson <[EMAIL PROTECTED]>: >> Hi, >> >> I do it this way: >> >> The variable searchValue is my Prefix like in your case 123 would be: >> >> searchValue = "123"; >> >> PrefixFilter prefixFilter = new PrefixFilter(Bytes.toBytes(searchValue)); >> Scan scan = new Scan(); >> scan.addFamily(Bytes.toBytes(this.REF_FAM)); >> scan.setFilter(prefixFilter); >> ResultScanner resultScanner = hBaseTable.getScanner(scan); >> >> Now you can iterate over the resultScanner. >> >> Is this what you were looking for? >> >> /SJ >> >> >> >> >> On Mon, Aug 23, 2010 at 6:00 AM, Michelan Arendse <[EMAIL PROTECTED]> >> wrote: >>> Hi, >>> >>> Thanks for the responses but it's still not what I am really looking for. >>> >>> The row id looks something like: number_string so it would be 123_foo, >> 123_foo2 123_foo3. >>> So now I want to find all the foo's that are related to the first half of >> the key which is "123". >>> >>> Also I can't add start row if I do not know where 123 starts. And I can't >> search for the start row, as I need this to be very fast. >>> >>> Thanks. >>> >>> >>> -----Original Message----- >>> From: Ryan Rawson [mailto:[EMAIL PROTECTED]] >>> Sent: 17 August 2010 09:01 PM >>> To: [EMAIL PROTECTED] >>> Subject: Re: Scanning half a key or value in HBase >>> >>> Hey, >>> >>> One thing to watch out for is ascii with separator variable length >>> keys, you would think if your key structure was: >>> >>> foo:bar >>> >>> starting at 'foo' and ending at 'foo:' might give you only keys which >>> start with 'foo:' but this doesn't work like that. You also get keys >>> like: >>> foo123:bar >>> >>> you must start the scan at 'foo:' but you can't just end it at 'foo;' >>> (since next(:) == ';' in ascii), this has to do with the ordering of >>> ASCII, for a reference look at http://www.asciitable.com/ >>> >>> The bug-free solution is to start your scan at 'foo:' and use a prefix >>> filter set to 'foo:'. >>> >>> If you are scanning fixed-width keys, eg: binary conversions of longs, >>> then the [start,start+1) solution works. >>> >>> On Tue, Aug 17, 2010 at 5:59 AM, Andrey Stepachev <[EMAIL PROTECTED]> >> wrote: >>>> Use scan where start key is <first_half_of_key> itself as bytearray, and >>>> stop key is <first_half_of_key> with last byte in bytearray + 1. >>>> >>>> example >>>> abc% should be scan(abc, abd) >>>> >>>> 2010/8/17 Michelan Arendse <[EMAIL PROTECTED]>: >>>>> Hi >>>>> >>>>> I am not sure if this is possible in HBase. What I am trying to do is >> scan on a HBase table with something similar to how SQL would do it. >>>>> e.g. SELECT * >>>>> FROM <table> > |