HBase shell value conversion with a binary column qualifier

25 Views Asked by At

Using :toLong does not work when selecting a column whose qualifier is binary, the value is still printed in hex. If the qualifier is printable it works.

I have a table, let's call it data, which has columns with a family d and a qualifier that consists of one single byte. The values in that family are always a single long.

I want to find all rows where the value for column d:a is < 0 and list columns d:a and d:\x02, no big deal:

> scan 'data', { COLUMNS => [ 'd:a', "d:\x02" ], FILTER => SingleColumnValueFilter.new(Bytes.toBytes('d'), Bytes.toBytes('a'), CompareFilter::CompareOp.valueOf('LESS'), LongComparator.new(0)) }

Results:

ROW        COLUMN+CELL
 \x00\x00  column=d:a, timestamp=…, value=\xFF\xFF\xFF\xFF\xFF\xFF\xF5\x0A
 \x00\x00  column=d:\x02, timestamp=…, value=value=\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF
 \x00\x01  column=d:a, timestamp=…, value=\xFF\xFF\xFF\xFF\xFF\xFF\xFC\x95
 \x00\x01  column=d:\x02, timestamp=…, value=\xFF\xFF\xFF\xFF\xFF\xFF\xF42

The last one is a little bit awkward with that printable "2" at the end, but never mind, it does what I asked for.

However, now I want to show the values as long instead, so I try this:

> scan 'data', { COLUMNS => [ 'd:a:toLong', "d:\x02:toLong" ], FILTER => SingleColumnValueFilter.new(Bytes.toBytes('d'), Bytes.toBytes('a'), CompareFilter::CompareOp.valueOf('LESS'), LongComparator.new(0)) }

Results:

ROW        COLUMN+CELL
 \x00\x00  column=d:a, timestamp=…, value=-2806
 \x00\x00  column=d:\x02, timestamp=…, value=value=\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF
 \x00\x01  column=d:a, timestamp=…, value=-875
 \x00\x01  column=d:\x02, timestamp=…, value=\xFF\xFF\xFF\xFF\xFF\xFF\xF42

Well, the d:a are shown as long, but the others?

I put the second column name in double quotes hoping that would work, and it does select those columns. If I use single quotes it does not, so I must be doing something right? The conversion to long does not work though.

What is going on? What am I doing wrong here?

0

There are 0 best solutions below