You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Vamshi Krishna <va...@gmail.com> on 2012/04/25 06:35:53 UTC

Integrity constraints

Hi all ,  here i am having one basic doubt about constraints on hbase
table, after knowing there is no concept of data types in hbase and
everything is stored in the bytes.
 Suppose a table in hbase has 3 columns,(under same column family)
1st column is 'Name' which accepts only character strings not numbers and
special symbols.
2nd column 'phoneNumber', which is numerals that too exactly 10 digits, and
3rd column 'city' which should accept only upper case character strings. If
such is the situation, how to enforce the constraints on each of the
columns of hbase table?

Also Can anybody please tell how to write the equivalent  query in hbase
shell and Java to do so?
-- 
*Regards*
*
Vamshi Krishna
*

Re: Integrity constraints

Posted by Vamshi Krishna <va...@gmail.com>.
Thank you Gary..! Now i understood the actual method.

On Wed, Apr 25, 2012 at 11:36 AM, Gary Helmling <gh...@gmail.com> wrote:

> Hi Vamshi,
>
> See the ConstraintProcessor coprocessor that was added for just this
> kind of case:
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/constraint/package-summary.html
>
> You would need to implement the Constraint interface and apply the
> configuration to your tables via the Constraints utility.
>
> Assuming the fields are being handled as strings on the client end,
> your Constraint implementation could simply call Bytes.toString() and
> apply some basic regexs for validation.  Or you could consider using a
> more structured serialization format like protobufs.
>
> --gh
>
> On Tue, Apr 24, 2012 at 9:35 PM, Vamshi Krishna <va...@gmail.com>
> wrote:
> > Hi all ,  here i am having one basic doubt about constraints on hbase
> > table, after knowing there is no concept of data types in hbase and
> > everything is stored in the bytes.
> >  Suppose a table in hbase has 3 columns,(under same column family)
> > 1st column is 'Name' which accepts only character strings not numbers and
> > special symbols.
> > 2nd column 'phoneNumber', which is numerals that too exactly 10 digits,
> and
> > 3rd column 'city' which should accept only upper case character strings.
> If
> > such is the situation, how to enforce the constraints on each of the
> > columns of hbase table?
> >
> > Also Can anybody please tell how to write the equivalent  query in hbase
> > shell and Java to do so?
> > --
> > *Regards*
> > *
> > Vamshi Krishna
> > *
>



-- 
*Regards*
*
Vamshi Krishna
*

Re: Integrity constraints

Posted by Gary Helmling <gh...@gmail.com>.
Hi Vamshi,

See the ConstraintProcessor coprocessor that was added for just this
kind of case: http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/constraint/package-summary.html

You would need to implement the Constraint interface and apply the
configuration to your tables via the Constraints utility.

Assuming the fields are being handled as strings on the client end,
your Constraint implementation could simply call Bytes.toString() and
apply some basic regexs for validation.  Or you could consider using a
more structured serialization format like protobufs.

--gh

On Tue, Apr 24, 2012 at 9:35 PM, Vamshi Krishna <va...@gmail.com> wrote:
> Hi all ,  here i am having one basic doubt about constraints on hbase
> table, after knowing there is no concept of data types in hbase and
> everything is stored in the bytes.
>  Suppose a table in hbase has 3 columns,(under same column family)
> 1st column is 'Name' which accepts only character strings not numbers and
> special symbols.
> 2nd column 'phoneNumber', which is numerals that too exactly 10 digits, and
> 3rd column 'city' which should accept only upper case character strings. If
> such is the situation, how to enforce the constraints on each of the
> columns of hbase table?
>
> Also Can anybody please tell how to write the equivalent  query in hbase
> shell and Java to do so?
> --
> *Regards*
> *
> Vamshi Krishna
> *