Created 08-04-2017 09:37 AM
I created a table through phoenix as:
CREATE TABLE MyTab (
Feature varchar(10),
ts DATE NOT NULL,
val INTEGER,
avg varchar(10)
CONSTRAINT pk PRIMARY KEY (tag, ts)
)COLUMN_ENCODED_BYTES=0;
Inserted 100 row to it.
The Hbase scan for MyTab shows this( Just copied only 1 row-key data):
Temp\x00\x80\x00\x01]\x9Fh@\xE2 column=0:VAL, timestamp=1501598196006, value=\x80\x00\x00\x16 Temp\x00\x80\x00\x01]\x9Fh@\xE2 column=0:_0, timestamp=1501598196006, value=x
this means Temp\x00\x80\x00\x01]\x9Fh@\xE2 is the row- key,
So, when I do a get like : get 'MyTab', 'Temp\x00\x80\x00\x01]\x9Fh@\xE2', '0:VAL'
I get no results. How would I get the value of column VAL
TS value inserted to Phoenix is 2017-08-01 20:06:35.998 and Feature is Temp.
Created 08-04-2017 10:15 AM
You can't execute "get" on a non-string row key from a shell. You need to do it through HBase Java API.
Get get = new Get(toBytes("row1"));
In Phoenix case, it would be difficult you to form an exact row key from the primary key values as it involves the usage of low level APIs( PTable.newKey(),PDataType.toBytes(value, column.getSortOrder) etc).
However , if you are really looking for look ups, you can still do it from sql.
SELECT * FROM MyTab WHERE feature='Temp' and TS=to_time('<ts_value>')
Created 08-04-2017 11:06 AM
Thanks, but actually, I want to do scanning in hbase coprocessor for which I require the row-key.
The scan should be for a specific feature and time stamp to do some aggregations. So I need to use scan.setStartRow() and scan.setStoprow() with appropriate row-keys formed by feature and TS.
Created 08-04-2017 02:35 PM
You would still use the HBase Java API within a coprocessor. Ankit was saying that it did not work because you did not specify the binary data correctly in the HBase shell.