Return-Path: X-Original-To: apmail-hbase-issues-archive@www.apache.org Delivered-To: apmail-hbase-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5BE77104B9 for ; Wed, 26 Mar 2014 17:55:36 +0000 (UTC) Received: (qmail 68856 invoked by uid 500); 26 Mar 2014 17:55:27 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 68659 invoked by uid 500); 26 Mar 2014 17:55:25 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 68582 invoked by uid 99); 26 Mar 2014 17:55:23 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2014 17:55:23 +0000 Date: Wed, 26 Mar 2014 17:55:23 +0000 (UTC) From: "Nick Dimiduk (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (HBASE-10837) Filters failing to compare negative numbers (int,float,double or long) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HBASE-10837?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Nick Dimiduk resolved HBASE-10837. ---------------------------------- Resolution: Duplicate Looks like the create issue button double-posted. > Filters failing to compare negative numbers (int,float,double or long) > ----------------------------------------------------------------------- > > Key: HBASE-10837 > URL: https://issues.apache.org/jira/browse/HBASE-10837 > Project: HBase > Issue Type: Improvement > Components: Filters > Affects Versions: 0.94.2 > Environment: Pseudo Mode > Reporter: Chandraprakash Sahu > Priority: Blocker > Labels: features > > 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. > My Hbase version is 0.94.2 and I am running it in pseudo mode. > Can anyone help me on this ? -- This message was sent by Atlassian JIRA (v6.2#6252)