Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6D7DF30A0 for ; Fri, 6 May 2011 04:24:56 +0000 (UTC) Received: (qmail 57703 invoked by uid 500); 6 May 2011 04:24:56 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 57590 invoked by uid 500); 6 May 2011 04:24:55 -0000 Mailing-List: contact commits-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 commits@hbase.apache.org Received: (qmail 57582 invoked by uid 99); 6 May 2011 04:24:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 May 2011 04:24:53 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 May 2011 04:24:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0AC87238890A; Fri, 6 May 2011 04:24:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1100043 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/client/coprocessor/AggregationClient.java Date: Fri, 06 May 2011 04:24:28 -0000 To: commits@hbase.apache.org From: stack@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110506042429.0AC87238890A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: stack Date: Fri May 6 04:24:28 2011 New Revision: 1100043 URL: http://svn.apache.org/viewvc?rev=1100043&view=rev Log: HBASE-3862 Race conditions in aggregate calculation Modified: hbase/trunk/CHANGES.txt hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/coprocessor/AggregationClient.java Modified: hbase/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1100043&r1=1100042&r2=1100043&view=diff ============================================================================== --- hbase/trunk/CHANGES.txt (original) +++ hbase/trunk/CHANGES.txt Fri May 6 04:24:28 2011 @@ -99,6 +99,7 @@ Release 0.91.0 - Unreleased HBASE-3777 Redefine Identity Of HBase Configuration (Karthick Sankarachary) HBASE-3849 Fix master ui; hbase-1502 broke requests/second HBASE-3853 Fix TestInfoServers to pass after HBASE-3835 (todd) + HBASE-3862 Race conditions in aggregate calculation (John Heitmann) IMPROVEMENTS HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/coprocessor/AggregationClient.java URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/coprocessor/AggregationClient.java?rev=1100043&r1=1100042&r2=1100043&view=diff ============================================================================== --- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/coprocessor/AggregationClient.java (original) +++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/coprocessor/AggregationClient.java Fri May 6 04:24:28 2011 @@ -23,6 +23,7 @@ package org.apache.hadoop.hbase.client.c import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -92,7 +93,7 @@ public class AggregationClient { } @Override - public void update(byte[] region, byte[] row, R result) { + public synchronized void update(byte[] region, byte[] row, R result) { max = ci.compare(max, result) < 0 ? result : max; } } @@ -141,7 +142,7 @@ public class AggregationClient { } @Override - public void update(byte[] region, byte[] row, R result) { + public synchronized void update(byte[] region, byte[] row, R result) { min = (min == null || ci.compare(result, min) < 0) ? result : min; } } @@ -176,15 +177,15 @@ public class AggregationClient { final ColumnInterpreter ci, final Scan scan) throws Throwable { validateParameters(scan); class RowNumCallback implements Batch.Callback { - private long rowCountL = 0l; + private final AtomicLong rowCountL = new AtomicLong(0); public long getRowNumCount() { - return rowCountL; + return rowCountL.get(); } @Override public void update(byte[] region, byte[] row, Long result) { - rowCountL += result.longValue(); + rowCountL.addAndGet(result.longValue()); } } RowNumCallback rowNum = new RowNumCallback(); @@ -219,7 +220,7 @@ public class AggregationClient { } @Override - public void update(byte[] region, byte[] row, S result) { + public synchronized void update(byte[] region, byte[] row, S result) { sumVal = ci.add(sumVal, result); } } @@ -255,7 +256,7 @@ public class AggregationClient { } @Override - public void update(byte[] region, byte[] row, Pair result) { + public synchronized void update(byte[] region, byte[] row, Pair result) { sum = ci.add(sum, result.getFirst()); rowCount += result.getSecond(); } @@ -317,7 +318,7 @@ public class AggregationClient { } @Override - public void update(byte[] region, byte[] row, Pair, Long> result) { + public synchronized void update(byte[] region, byte[] row, Pair, Long> result) { sumVal = ci.add(sumVal, result.getFirst().get(0)); sumSqVal = ci.add(sumSqVal, result.getFirst().get(1)); rowCountVal += result.getSecond();