Return-Path: X-Original-To: apmail-hbase-user-archive@www.apache.org Delivered-To: apmail-hbase-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1A19F10CFE for ; Wed, 19 Mar 2014 11:20:20 +0000 (UTC) Received: (qmail 97664 invoked by uid 500); 19 Mar 2014 11:20:16 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 97297 invoked by uid 500); 19 Mar 2014 11:20:14 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 97273 invoked by uid 99); 19 Mar 2014 11:20:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Mar 2014 11:20:10 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,SPF_SOFTFAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: softfail (nike.apache.org: transitioning domain of chaitanya.ck100@gmail.com does not designate 216.139.236.26 as permitted sender) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Mar 2014 11:20:04 +0000 Received: from ben.nabble.com ([192.168.236.152]) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WQEX9-0007i8-AB for user@hbase.apache.org; Wed, 19 Mar 2014 04:19:43 -0700 Date: Wed, 19 Mar 2014 04:19:43 -0700 (PDT) From: Chaitanya To: user@hbase.apache.org Message-ID: <1395227983265-4057268.post@n3.nabble.com> Subject: Filters failing to compare negative numbers (int,float,double or long) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi All, I have come across an issue while using filters to get a result. For eg. I have created a table and its specifications are as follows : table name --> test column family --> cf row keys --> rowKey1 - rowKey10 (10 different row keys) column qualifier --> integerData For different rowkeys, the qualifier 'integerData' contains either positive or negative integer values (data loaded randomly). Now, while I am trying to retrieve the data from the table based on a filter condition, its failing to give the desired result. For eg. say, My table contains following data : [-50,-40,-30,-20,-10,10,20,30,40,50] I want to get only those values which are greater than or equal to 40. Following is the code for the filter set on scan : ******************************************** Scan scan = new Scan(); scan.addColumn(Bytes.toBytes("cf"), Bytes.toBytes(" integerData")); int i = 40; Filter filter = new ValueFilter(CompareOp.GREATER_OR_EQUAL,new BinaryComparator(Bytes.toBytes(i))); scan.setFilter(filter); ********************************************* The result should be : 40 and 50 BUT, the actual result is : -50, -40, -30, -20, -10, 40, 50 I have read few posts which addressed this issue, and few people provided the solution as: 1) write a custom comparator, as BinaryComparator is not meant for number comparison OR 2) retrieve all the values as integer and then compare BUT, I want to know if there is any other way to achieve this. Because this seems to be a very basic need, i.e. comparing numbers, and I feel HBase should have something straight forward to deal with this. This comparison fails only when the negative numbers are involved. I am not able to get the right way to do it. Can anyone help me on this ? ----- Regards, Chaitanya -- View this message in context: http://apache-hbase.679495.n3.nabble.com/Filters-failing-to-compare-negative-numbers-int-float-double-or-long-tp4057268.html Sent from the HBase User mailing list archive at Nabble.com.