hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Yu <yuzhih...@gmail.com>
Subject Re: HBase aggregation for sum
Date Thu, 19 Dec 2013 18:26:06 GMT
bq. Could there be a problem with me using a LongColumnInterpreter
when the 'count'
field was an int?

Right. Take a look at the check in the beginning of
LongColumnInterpreter.getValue():

  public Long getValue(byte[] colFamily, byte[] colQualifier, Cell kv)

      throws IOException {

    if (kv == null || kv.getValueLength() != Bytes.SIZEOF_LONG)

      return null;

There is no stock ColumnInterpreter for int in 0.94, please create one.

Cheers



On Thu, Dec 19, 2013 at 1:05 AM, james isaac <jamesisaac21@gmail.com> wrote:

> Hi,
>
> I'm having some trouble doing aggregation on a particular column in HBase.
>
> This is the snippet of code I tried:
>
>  Configuration config = HBaseConfiguration.create();
>  AggregationClient aggregationClient = new AggregationClient(config);
>
>  Scan scan = new Scan();
>  scan.addColumn(Bytes.toBytes("drs"), Bytes.toBytes("count"));
>
>  ColumnInterpreter<Long, Long> ci = new LongColumnInterpreter();
>
>  Long sum = aggregationClient.sum(Bytes.toBytes("DEMO_CALCULATIONS"),
> ci , scan);
>  System.out.println(sum);
>
> sum returns a value of null. The aggregationClient API works fine if I do a
> rowcount.
>
> I was trying to follow the directions in
>
> http://michaelmorello.blogspot.in/2012/01/row-count-hbase-aggregation-example.html
>
> Could there be a problem with me using a LongColumnInterpreter when the
> 'count' field was an int? What am I missing in here?
>
>
> Regards,
>
> James
>

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