Return-Path: X-Original-To: apmail-hbase-dev-archive@www.apache.org Delivered-To: apmail-hbase-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9877810DDC for ; Sat, 1 Mar 2014 23:30:32 +0000 (UTC) Received: (qmail 50283 invoked by uid 500); 1 Mar 2014 23:30:31 -0000 Delivered-To: apmail-hbase-dev-archive@hbase.apache.org Received: (qmail 50156 invoked by uid 500); 1 Mar 2014 23:30:30 -0000 Mailing-List: contact dev-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list dev@hbase.apache.org Received: (qmail 50147 invoked by uid 99); 1 Mar 2014 23:30:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Mar 2014 23:30:30 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FRT_ADOBE2,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mcorgan@hotpads.com designates 74.125.82.174 as permitted sender) Received: from [74.125.82.174] (HELO mail-we0-f174.google.com) (74.125.82.174) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Mar 2014 23:30:26 +0000 Received: by mail-we0-f174.google.com with SMTP id t60so1795286wes.33 for ; Sat, 01 Mar 2014 15:30:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=gIY02F4dKQpTbLtddlTr2ncd/SdjO21AxL1v7SlNNvo=; b=KEarok6tK45axJBa8e9W5GVa8q82gAujkrGd7xtqim40YqRVkiqu0XPz88HLWmnJhW St04GJ+WzLIxidDAoJkMeF8Aug8cC1TyIQSSbgZQznCW5ILjhPqSdMdQJpuehuEcJRB6 TI7xc0d/gs1pZodpjgHO8uebf0LpDnqYYq8U/MMGUezgDG75FblVai2G3dPIZzxHBF/W UxDKzLCeOWqRCpBJrKlLktuiX7BVZrw0s601c/TtjoLBRHjm/Kj1ou2FKpDbJFPNiKPy CUC0RWviYDt6lXjfBE1UonIrx9b9IODE31YktwN1tkr7I5wJGfz7Q6IBuW8d8I2eMwtR QRnQ== X-Gm-Message-State: ALoCoQmttj74u79i9xkUp1dn09A2yELJCth6LjwCmSGSB6Zj+UhVAscVwbFu8omSFKfqr1wos57V MIME-Version: 1.0 X-Received: by 10.194.110.135 with SMTP id ia7mr8864624wjb.5.1393716604632; Sat, 01 Mar 2014 15:30:04 -0800 (PST) Received: by 10.216.163.199 with HTTP; Sat, 1 Mar 2014 15:30:04 -0800 (PST) In-Reply-To: References: Date: Sat, 1 Mar 2014 15:30:04 -0800 Message-ID: Subject: Re: Why doesn't KeyValue.equals/CellComparator compare the values? From: Matt Corgan To: dev Content-Type: multipart/alternative; boundary=047d7bf10a8423357504f393efce X-Virus-Checked: Checked by ClamAV on apache.org --047d7bf10a8423357504f393efce Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hmm, I don't think KeyValue.hashCode should be including the value. I'm surprised it hasn't turned up a bug, but maybe that's because there's barely any code relying on it. Looks like KeyValue.equals now farms out the work to CellComparator, and maybe KeyValue.hashCode should do the same. Note that CellComparator.hashCode does not include the value. On Fri, Feb 28, 2014 at 10:20 AM, Cosmin Lehene wrote: > Thanks Matt, Stack, > > My question/comment was biased by the perspective of a co-processor > implementation, but I guess it may well apply for HBase development. > From that perspective you're both in HBase-land and Java-land. > > A collection of cells needs to be compared to another collection of cells > (I=C2=B9m doing a diff). > Java collections will end up comparing individual objects for equality so > it boils down to a Cell object being equal to another Cell object. So fro= m > a java/oo perspective the question is: are two cells with different value= s > equal (I.e. Can I swap them?) > > The HBase answer is indeed yes they are equal as long as row, family, > qualifier, timestamp and type are the same. > > The Java answer, however may be different (and hence the expectations of = a > developer) as, in general it will be based on the known contract. > > And the general hashCode contract is > > * If two objects are equal according to the equals(Object) method, then > calling the hashCode method on each of the two objects must produce the > same integer result. > > > > And the equals javadoc > > * Note that it is generally necessary to override the {@code hashCode} > * method whenever this method is overridden, so as to maintain the > * general contract for the {@code hashCode} method, which states > * that equal objects must have equal hash codes. > > > But in our case, the object equality will pass but hash codes will be > different (https://gist.github.com/clehene/9276434) > > It=C2=B9s obvious why the behavior is as is in Hbase, so rather than > nitpicking, I wonder whether this could be made obvious as it may help > avoid some unexpected behaviors :) > > Thanks, > Cosmin > > On 2/27/14, 10:22 AM, "Stack" wrote: > > >On Wed, Feb 26, 2014 at 8:31 PM, Matt Corgan wrote= : > >.... > > > >> But maybe one of the committers could add a sentence to emphasize that > >> value is excluded. > >> > >> > >We should underline that data is not considered comparing Cells > >(KeyValues). Apart from the fact that it could make for some interestin= g > >performance issues, the system isn't plumbed for dealing with coordinate= s > >that differ in their value only. Rather, the mvcc/sequenceid is used > >splitting Cells whose coordinates are otherwise the same). > > > >What was your expectation mighty Cosmin? What you think HBase should do > >with values that differ in value only? > > > >Thanks, > >St.Ack > > --047d7bf10a8423357504f393efce--