Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7E3DC200D2E for ; Tue, 31 Oct 2017 21:55:07 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 7CDC31609EF; Tue, 31 Oct 2017 20:55:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C533D1609E6 for ; Tue, 31 Oct 2017 21:55:06 +0100 (CET) Received: (qmail 71519 invoked by uid 500); 31 Oct 2017 20:55:05 -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 71507 invoked by uid 99); 31 Oct 2017 20:55:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Oct 2017 20:55:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id F316E1A3A3D for ; Tue, 31 Oct 2017 20:55:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 0Z_9WJdXXdDm for ; Tue, 31 Oct 2017 20:55:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id DC8C860F68 for ; Tue, 31 Oct 2017 20:55:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 179E5E2583 for ; Tue, 31 Oct 2017 20:55:02 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 75B3A21301 for ; Tue, 31 Oct 2017 20:55:01 +0000 (UTC) Date: Tue, 31 Oct 2017 20:55:01 +0000 (UTC) From: "Jan Hentschel (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-19103) Add BigDecimalComparator for filter MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 31 Oct 2017 20:55:07 -0000 [ https://issues.apache.org/jira/browse/HBASE-19103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16227534#comment-16227534 ] Jan Hentschel commented on HBASE-19103: --------------------------------------- Your implementation of hashCode and equals look a little bit off. Why do you include hashCode and toString in the equals implementation? I'm currently doing something similar in HBASE-19008 and the template looks similar to the following (taken from ColumnCountGetFilter) {code:java} @Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof ColumnCountGetFilter)) { return false; } final ColumnCountGetFilter that = (ColumnCountGetFilter) o; return Objects.equals(limit, that.limit); } @Override public int hashCode() { return Objects.hash(limit); } {code} A test case covering this looks like the following {code:java} @Test public void testEquals() { // Check that equals returns true for identical objects final ColumnCountGetFilter filter = new ColumnCountGetFilter(5); assertTrue(filter.equals(filter)); assertEquals(filter.hashCode(), filter.hashCode()); // Check that equals returns true for the same object final ColumnCountGetFilter filter1 = new ColumnCountGetFilter(5); final ColumnCountGetFilter filter2 = new ColumnCountGetFilter(5); assertTrue(filter1.equals(filter2)); assertEquals(filter1.hashCode(), filter2.hashCode()); // Check that equals returns false for different objects final ColumnCountGetFilter filter3 = new ColumnCountGetFilter(4); final ColumnCountGetFilter filter4 = new ColumnCountGetFilter(5); assertFalse(filter3.equals(filter4)); assertNotEquals(filter3.hashCode(), filter4.hashCode()); // Check that equals returns false for a different type final ColumnCountGetFilter filter5 = new ColumnCountGetFilter(5); assertFalse(filter5.equals(0)); } {code} This also eliminates the need of a hashCode field in the class. > Add BigDecimalComparator for filter > ----------------------------------- > > Key: HBASE-19103 > URL: https://issues.apache.org/jira/browse/HBASE-19103 > Project: HBase > Issue Type: New Feature > Components: Client > Reporter: Qilin Cao > Assignee: Qilin Cao > Priority: Minor > Fix For: 1.2.0, 3.0.0 > > Attachments: HBASE-19103-1.2.0-v1.patch, HBASE-19103-1.2.0-v2.patch, HBASE-19103-trunk-v1.patch, HBASE-19103-trunk-v2.patch > > > Should I add BigDecimalComparator for filter? Some scenarios need to calculate the data accurately may use it. -- This message was sent by Atlassian JIRA (v6.4.14#64029)