You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by fx_bull <ja...@gmail.com> on 2013/06/13 10:16:13 UTC

some problem about HBase index

hello 

     If I have a table called 'student',  I want to  use both of  student number and student' name as  rowkey  to mark a student, 

    I want to verify can HBase support it  ,  and  if  it can, how should I do,

                    Thanks!

Re: some problem about HBase index

Posted by Nick Dimiduk <nd...@gmail.com>.
Please help us understand. My read of your question is that you want to
query for students in two ways:
 - "get the student with name 'jean'"
 - "get the student with id 12"

With the rowkey as student name, only the first query is possible with a
simple GET. Likewise, with the rowkey as student id, only the second query
is possible with a simple GET.

As Rajeshbabu pointed out, you would need to use a SCAN with a filter to
query by the attribute for which your schema is not defined. Your
alternative is to maintain a second table whose rowkey provides for the
second query. That second table can contain an entire copy of the student
record (this is denomralization at its worst) or it can contain only a
single cell pointing to the rowkey value of the source table. In HBase, we
call this a "secondary index".

Using a compound rowkey, you could ask a more complex question with a
single GET, for instance "get the student with name 'jean' and whose age is
189". This kind of question is implemented as a compound rowkey and your
schema would look something like this:

rowkey    cf:info
name/age  {name, id, height, weight, age, ...}

You can use this same schema to answer "get me all students whose name is
'jean'" by using a SCAN with a PrefixFilter.

Thanks,
Nick

On Thu, Jun 13, 2013 at 7:21 PM, fx_bull <ja...@gmail.com> wrote:

>
> Thanks
>
> What's I mean is that both of the name of a student  and student_id  as a
> rowkey
>
> As below
>
> table's structure
>
>                                          family: col
> rowkey     rowkey         student:info
>
> jean            12
> {'age':'189','name':'jean','id':'12','height':'76'…...}
>
> ….              …..               ……..
>
>
>
> pic
>
>
>
>
>
>
>
> 在 2013-6-13,下午6:33,Michel Segel <mi...@hotmail.com> 写道:
>
> comprised
>
>
>

Re: some problem about HBase index

Posted by fx_bull <ja...@gmail.com>.
Thanks

What's I mean is that both of the name of a student  and student_id  as a rowkey

As below 

table's structure

                                         family: col
rowkey     rowkey         student:info

jean            12               {'age':'189','name':'jean','id':'12','height':'76'…...}

….              …..               ……..



pic





 


在 2013-6-13,下午6:33,Michel Segel <mi...@hotmail.com> 写道:

> comprised


Re: some problem about HBase index

Posted by Michel Segel <mi...@hotmail.com>.
Huh?

Sorry but HBase *DOES* support composite keys.

The OP's question is can you create a row key that is comprised of both 'student' and 'student_id'.

I'm not going in to more detail because this sounds like a homework problem.

Composite rowkey and composite index are two different things, yet still related because the row key has an implied index.


Sent from a remote device. Please excuse any typos...

Mike Segel

On Jun 13, 2013, at 5:22 AM, rajeshbabu chintaguntla <ra...@huawei.com> wrote:

> 
> HBase does not fully support composite keys.
> But you can use PrefixFilter and FuzzyRowFilter with some limitations if your query involves part of key.
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/PrefixFilter.html
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/FuzzyRowFilter.html
> 
> Thanks,
> Rajeshbabu.
> ________________________________________
> From: fx_bull [javacniu@gmail.com]
> Sent: Thursday, June 13, 2013 1:46 PM
> To: user@hbase.apache.org
> Cc: dev@hbase.apache.org
> Subject: some problem about HBase index
> 
> hello
> 
>     If I have a table called 'student',  I want to  use both of  student number and student' name as  rowkey  to mark a student,
> 
>    I want to verify can HBase support it  ,  and  if  it can, how should I do,
> 
>                    Thanks!

RE: some problem about HBase index

Posted by rajeshbabu chintaguntla <ra...@huawei.com>.
HBase does not fully support composite keys.
But you can use PrefixFilter and FuzzyRowFilter with some limitations if your query involves part of key.
http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/PrefixFilter.html
http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/FuzzyRowFilter.html

Thanks,
Rajeshbabu.
________________________________________
From: fx_bull [javacniu@gmail.com]
Sent: Thursday, June 13, 2013 1:46 PM
To: user@hbase.apache.org
Cc: dev@hbase.apache.org
Subject: some problem about HBase index

hello

     If I have a table called 'student',  I want to  use both of  student number and student' name as  rowkey  to mark a student,

    I want to verify can HBase support it  ,  and  if  it can, how should I do,

                    Thanks!

Re: some problem about HBase index

Posted by fx_bull <ja...@gmail.com>.
For  we need  several different indexes  to retrieval  an object   in many scenarios.  


在 2013-6-13,下午4:16,fx_bull <ja...@gmail.com> 写道:

> hello 
> 
>     If I have a table called 'student',  I want to  use both of  student number and student' name as  rowkey  to mark a student, 
> 
>    I want to verify can HBase support it  ,  and  if  it can, how should I do,
> 
>                    Thanks!


Re: some problem about HBase index

Posted by fx_bull <ja...@gmail.com>.
For  we need  several different indexes  to retrieval  an object   in many scenarios.  


在 2013-6-13,下午4:16,fx_bull <ja...@gmail.com> 写道:

> hello 
> 
>     If I have a table called 'student',  I want to  use both of  student number and student' name as  rowkey  to mark a student, 
> 
>    I want to verify can HBase support it  ,  and  if  it can, how should I do,
> 
>                    Thanks!