Closed colorant closed 11 years ago
use_id is a primary key or index?
part of primary key, and I create index for it too.
And it doesn't matter that it is PK or not. I think it is just relate to the negative number 's format. same on time filed which is not PK but index
wasp(main):004:0> query "select * from Photo where time=-20130728" +----------+-----------+------------+-----------+----------------+-------+ | user_id | photo_id | time | full_url | thumbnail_url | tag | +----------+-----------+------------+-----------+----------------+-------+ | -2 | -502 | -20130728 | fullurl2 | thumburl2 | tag2 | +----------+-----------+------------+-----------+----------------+-------+
wasp(main):002:0> query "select * from Photo where time<5" +--+ | | +--+ +--+
You can see that on Phoenix https://github.com/forcedotcom/phoenix, the number is stored in a format that the flag bit is flipped in order to do sort correctly.
OK. it's a bug.... thx for your great report. :+1:
the bug fixed. please pull the newest code
I can see that when stored in index table, the negative number is stored as it is. (say with the flip flag solution, thus the bytes representation of negative number is large than the positive number)
Thus, hbase will sort the row - key with positive number ahead of negative number
And I not yet read code to find out how you fetch index out of index table, but assuming that you will use hbase's row order directly, under this condition, the condition clause won't work right. e.g.
wasp(main):055:0> query "select * from Photo where user_id=-2" +----------+-----------+------------+-----------+----------------+-------+ | user_id | photo_id | time | full_url | thumbnail_url | tag | +----------+-----------+------------+-----------+----------------+-------+ | -2 | -502 | -20130728 | fullurl2 | thumburl2 | tag2 | +----------+-----------+------------+-----------+----------------+-------+
wasp(main):054:0> query "select * from Photo where user_id<5" +--+ | | +--+ +--+