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 50AFFFEE0 for ; Mon, 1 Apr 2013 14:54:50 +0000 (UTC) Received: (qmail 94063 invoked by uid 500); 1 Apr 2013 14:54:48 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 93801 invoked by uid 500); 1 Apr 2013 14:54:46 -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 93788 invoked by uid 99); 1 Apr 2013 14:54:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Apr 2013 14:54:46 +0000 X-ASF-Spam-Status: No, hits=0.8 required=5.0 tests=FROM_12LTRDOM,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.192.176] (HELO mail-pd0-f176.google.com) (209.85.192.176) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Apr 2013 14:54:38 +0000 Received: by mail-pd0-f176.google.com with SMTP id r11so1250586pdi.35 for ; Mon, 01 Apr 2013 07:54:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=JF9W+RODoMckxfPBsNPMY/cY+t9RJhqnQY/lNBe3J3I=; b=MjJim61yWh5UcOy2jnryWNPyKrfwtPmerCF5ZBlbL/06ELhhqkr0CzYQsv5QZPiN/L 3hXEQll8dMVdqah0ksf+g6tluOfEl4gus0QuX9e/fMhiD09P5WuRtTZTSebFW7K5aNtz /IV10MNox2NZgwK0GppiU5K1Yd3VqK1xjX/pQzRC+e1pROAX/FuRkq7KkEzhFNAfZXe7 om/bMm3wK/vKJJ5mN4MAa51ao74cVcNkcYl1FP9bNtlI5PRKoBrQhNM4xBJcrCNY0yI9 vV7XbdxgL0R0cHB53PbTYSVQhSA0E8KeevM/T/Q8UW/mWIdjLgc5wglsHvnqKrJ9zRPH jPcw== X-Received: by 10.68.170.193 with SMTP id ao1mr17965421pbc.129.1364828056966; Mon, 01 Apr 2013 07:54:16 -0700 (PDT) Received: from [127.0.0.1] (cpe-75-82-180-219.socal.res.rr.com. [75.82.180.219]) by mx.google.com with ESMTPS id rt13sm15603039pac.14.2013.04.01.07.54.15 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Apr 2013 07:54:16 -0700 (PDT) Message-ID: <51599F8A.60306@mechnicality.com> Date: Mon, 01 Apr 2013 07:54:02 -0700 From: Alan Chaney User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: "user@hbase.apache.org" Subject: Inconsistencies in comparisons using KeyComparator Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnla/OxtV6bjGvJq81OpGBJJJhyNLDKahqp0JqfYoh2JnpMjKLEw5obsZ94ToVhIJ4UzVu7 X-Virus-Checked: Checked by ClamAV on apache.org Hi I need to write some code that sorts row keys identically to HBase. I looked at the KeyValue.KeyComparator code, and it seems that, by default, HBase elects to use the 'Unsafe' comparator as the basis of its comparison, with a fall-back to to the PureJavaComparer should Unsafe not be available (for example, in tests.) However, I'm finding that the sort order from a call to KeyValue.KeyComparator appears to be inconsistent between the two forms. As an example, comparing: (first param) (second param) 0000000000000000ffffffffffffffffffffffffffffffff616c1b to 0000000000000000ffffffffffffffffffffffffffffffff61741b gives 1 for the default (presumably, Unsafe) call, and -1 using the PureJavaComparator. I would actually expect it to be a -ve number, based on the difference of 6c to 74 in the 3rd from last byte above. Similarly 000000000000000000000000000000000000000000000000616c1b to 0000000000000000000000000000000000000000000000061741b gives > 0 instead of < 0. The PureJavaComparator does a byte-by-byte comparison by Is this expected? From the definition of lexicographical compare that I found, I don't think so. There's no issue of signed comparison here, because 0x6c and 0x74 are still +ve byte values. Regards Alan