Return-Path: X-Original-To: apmail-accumulo-dev-archive@www.apache.org Delivered-To: apmail-accumulo-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 2F7EE105DE for ; Wed, 18 Sep 2013 13:56:16 +0000 (UTC) Received: (qmail 36734 invoked by uid 500); 18 Sep 2013 13:56:14 -0000 Delivered-To: apmail-accumulo-dev-archive@accumulo.apache.org Received: (qmail 36508 invoked by uid 500); 18 Sep 2013 13:56:14 -0000 Mailing-List: contact dev-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list dev@accumulo.apache.org Received: (qmail 36493 invoked by uid 99); 18 Sep 2013 13:56:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Sep 2013 13:56:13 +0000 X-ASF-Spam-Status: No, hits=1.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of miguelapereira1@gmail.com designates 209.85.217.170 as permitted sender) Received: from [209.85.217.170] (HELO mail-lb0-f170.google.com) (209.85.217.170) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Sep 2013 13:56:06 +0000 Received: by mail-lb0-f170.google.com with SMTP id w7so6659685lbi.15 for ; Wed, 18 Sep 2013 06:55:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Pyaf3TCtnKiRG3RqUAGhgWIzDnXCaBjrOGjqmoj2wSM=; b=YRExKGdWPtM8KeneFqOKsLZC4EdHID5xzoxkV1SLCGQHaMsHlFb2++TZPnAeHarpad ZyKwpMMiAkE+D1FR80MFFzJBucR+rqtVy3MoC7D4CYxxf5z/sIJDebZgYgtlsxxPyMOJ eIV5aarCDItbuwjv9mafDkJ1/hxEYIz797ulyF/JbfE/DhMyeHIabG1OizCldA89VvlO BIbVUqO0rPu6153ie49Y4bGYKhq4HM1JQzifsda+lM9ij/XkZdl2SfHRiO9+i2eLbP3T kDl+3x0jl7gLU3x9ZcL/N1iyf+V4QStno6QKbWghCGUbBthte63y9gsI7EoNNUUVfqft ho8A== MIME-Version: 1.0 X-Received: by 10.152.120.37 with SMTP id kz5mr16569870lab.21.1379512546273; Wed, 18 Sep 2013 06:55:46 -0700 (PDT) Received: by 10.112.144.38 with HTTP; Wed, 18 Sep 2013 06:55:46 -0700 (PDT) In-Reply-To: <1379510630.15394.5.camel@debian> References: <1379510630.15394.5.camel@debian> Date: Wed, 18 Sep 2013 09:55:46 -0400 Message-ID: Subject: Re: Combiner Iterator From: Miguel Pereira To: dev@accumulo.apache.org Content-Type: multipart/alternative; boundary=089e0122814848ae0604e6a8cb77 X-Virus-Checked: Checked by ClamAV on apache.org --089e0122814848ae0604e6a8cb77 Content-Type: text/plain; charset=ISO-8859-1 So, the value iterator is in the abstract class combiner. The super class of the statscombiner. It automatically passes in the valueiterator to the reduce method. in the findTop() method > Iterator viter = new ValueIterator(getSource()); > topValue = reduce(topKey, viter); > this is accomplished by loosening the equality check on the row to exclude timestamp. meaning rows with similar keys minus the timestamp will be considered equal. So, I think, all you need to do is attach your combiner to the table / column family. Have you run the statscombiner example on the shell ? Cheers, Miguel On Wed, Sep 18, 2013 at 9:23 AM, Devin Pinkston wrote: > Hello, > > I am trying to work with the example combiner iterator through java code > instead of the jar or shell. My question is how do I pass in the > Iterator to the reduce method? Usually I would create a Key > Value Iterator, but this requires an Iterator just over the Value, and > then the key to be passed in separately. The reducer method comes from > the StatsCombiner class under examples/simple/combiner. What I have > right now: > > Iterator> iterator = scan.iterator(); > Iterator iter; > > > while (iterator.hasNext()) { > Map.Entry entry = iterator.next(); > iter = iterator.next().getValue(); > Key key = entry.getKey(); > Value value = entry.getValue(); > reduce(key, iter); > } > > How would I create the Iterator? Every way I have tried has > led me to dead end or error at runtime. > > Thanks! > > Here is the reduce method from StatsCombiner.java: > > @Override > public Value reduce(Key key, Iterator iter) { > > long min = Long.MAX_VALUE; > long max = Long.MIN_VALUE; > long sum = 0; > long count = 0; > > while (iter.hasNext()) { > String stats[] = iter.next().toString().split(","); > > if (stats.length == 1) { > long val = Long.parseLong(stats[0], radix); > min = Math.min(val, min); > max = Math.max(val, max); > sum += val; > count += 1; > } else { > min = Math.min(Long.parseLong(stats[0], radix), min); > max = Math.max(Long.parseLong(stats[1], radix), max); > sum += Long.parseLong(stats[2], radix); > count += Long.parseLong(stats[3], radix); > } > } > > String ret = Long.toString(min, radix) + "," + Long.toString(max, > radix) + "," + Long.toString(sum, radix) + "," + Long.toString(count, > radix); > return new Value(ret.getBytes()); > } > > > > --089e0122814848ae0604e6a8cb77--