hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jerry Lam <chiling...@gmail.com>
Subject Re: How to specify empty value in HBase shell
Date Fri, 21 Sep 2012 14:33:02 GMT
Hi St.Ack:

I made some dirty changes to the script yesterday to work for me.
Basically, I changed the parse_column_name(column) function to:

def parse_column_name(column)
      split =
org.apache.hadoop.hbase.KeyValue.parseColumn(column.to_java_bytes)
      return split[0], (split.length > 1) ? split[1] :
(org.apache.hadoop.hbase.KeyValue.getDelimiter(column.to_java_bytes, 0,
column.to_java_bytes.length(), 58) > 0) ? ''.to_java_bytes : nil
end

Not sure if it makes sense as the general solution to the problem but at
least it seems to do the job.

The end result is that, if user specify COLUMNS without the delimiter, it
is treated as column family without qualifier. If there is delimiter but
the split has only 1 element, then the column qualifier is set to empty
value.

Best Regards,

Jerry


On Fri, Sep 21, 2012 at 12:42 AM, Stack <stack@duboce.net> wrote:

> On Thu, Sep 20, 2012 at 7:31 AM, Jerry Lam <chilinglam@gmail.com> wrote:
> > Hi HBase Community:
> >
> > I have been struggling to find a way to specify empty value/empty column
> > qualifier in the hbase shell, but unsuccessful.
> >
> > I google it, nothing comes up. I don't know JRuby so that might be why.
> Do
> > you know how?
> >
> > Example:
> >
> > scan 'Table',  {COLUMNS => 'cf:'} // note that the column family is cf
> and
> > the column qualifier is empty (i.e. new byte[0])
> >
> > The above query will return all columns instead of the empty one.
> >
>
> Sounds like no qualifier means all columns to shell.
>
> Do you have to use the 'empty qualifier'?  Thats a bit odd.  You
> really need it in your model?
>
> In the shell we are doing this:
>
>
>         columns.each do |c|
>           family, qualifier = parse_column_name(c.to_s)
>           if qualifier
>             scan.addColumn(family, qualifier)
>           else
>             scan.addFamily(family)
>           end
>         end
>
>
> If no qualifier, we think its a scan of the family.
>
> I don't really have a good answer for you.  In shell, what would you
> suggest we add so we do addColumn rather than addFamily if qualifier
> is empty?
>
> St.Ack
>

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