Return-Path: X-Original-To: apmail-accumulo-user-archive@www.apache.org Delivered-To: apmail-accumulo-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 8A752F8D1 for ; Fri, 19 Apr 2013 08:10:12 +0000 (UTC) Received: (qmail 60284 invoked by uid 500); 19 Apr 2013 08:10:11 -0000 Delivered-To: apmail-accumulo-user-archive@accumulo.apache.org Received: (qmail 60193 invoked by uid 500); 19 Apr 2013 08:10:10 -0000 Mailing-List: contact user-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@accumulo.apache.org Delivered-To: mailing list user@accumulo.apache.org Received: (qmail 60147 invoked by uid 99); 19 Apr 2013 08:10:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Apr 2013 08:10:08 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE X-Spam-Check-By: apache.org Received-SPF: error (nike.apache.org: local policy) Received: from [212.82.109.206] (HELO nm25-vm5.bullet.mail.ird.yahoo.com) (212.82.109.206) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 19 Apr 2013 08:09:57 +0000 Received: from [77.238.189.50] by nm25.bullet.mail.ird.yahoo.com with NNFMP; 19 Apr 2013 08:09:16 -0000 Received: from [212.82.108.244] by tm3.bullet.mail.ird.yahoo.com with NNFMP; 19 Apr 2013 08:09:16 -0000 Received: from [127.0.0.1] by omp1009.mail.ird.yahoo.com with NNFMP; 19 Apr 2013 08:09:16 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 783753.20760.bm@omp1009.mail.ird.yahoo.com Received: (qmail 88106 invoked by uid 60001); 19 Apr 2013 08:09:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1366358956; bh=cosemFIaL4/S0cDJOump1VAfoCsdn/5TNLMLkddKZJc=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=BMAz8zihjn9RAaGkICkBN3WuNSwH7vKCnqVrp2msH0MGLTUhy63RzwWuZvvDxJT24JxyYxXQ1KCFp47PdHq0GSrHd7/jVn47+bWiVJv3s6NTRvw2oiv6LC6ZBCTc2drvhrPTh7mTYcska7lsJLz3C8wzEGi8Qhzw0Jr+fiHlqzs= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=05dPofhPCJMEjL1OkgNs802IYu+ae9Qwso2WRYNkp/3NxxE7KCXJP/mtwdykCCXORREJZceiTjiAh0MhNFGB3C4RZ4JCD/ebE4LFbc/l5jQ/sIwb7EYrM5hmVpxMDBqxjyVy1lwuOH1UgYjCfI2YkqqqucW8KlnnmF6wFYVxmhg=; X-YMail-OSG: r_4o.fUVM1lb4.Aj18T_YztIsdwqS5sUS0EmpC9e_1fIkc0 DpLsMvCH.sfC1mhwj.tVd Received: from [86.17.224.85] by web171705.mail.ir2.yahoo.com via HTTP; Fri, 19 Apr 2013 09:09:16 BST X-Rocket-MIMEInfo: 002.001,TWFueSB0aGFua3MgLSB0aGlzIGlzIGV4YWN0bHkgdGhlIGtpbmQgb2Ygc29sdXRpb24gSSB3YXMgbG9va2luZyBmb3IsIEkgdGhpbmsgSSBwcmVmZXIgdGhlIGJ1ZmZlcmVkIHJvdyBhcHByb2FjaCBhcyBJIGNhbiBhZGQgbXkgY29sdW1ucyBhdMKgYXJiaXRyYXJ5IHBvaW50cy7CoAoKSSBsb29rZWQgYXQgdGhlIHdob2xlIHJvdyBpdGVyYXRvciwgYnUgSSdtIG5vdCBrZWVuIG9uIHRoZcKgc2VyaWFsaXphdGlvbiBvdmVyaGVhZC7CoMKgIMKgwqAKCnRueAoKUGV0ZXIKCgpfX19fX19fX19fX19fX19fX19fX18BMAEBAQE- X-Mailer: YahooMailWebService/0.8.141.536 References: <1366302145.10313.YahooMailNeo@web171705.mail.ir2.yahoo.com> <1366302481.91113.YahooMailNeo@web171703.mail.ir2.yahoo.com> Message-ID: <1366358956.85676.YahooMailNeo@web171705.mail.ir2.yahoo.com> Date: Fri, 19 Apr 2013 09:09:16 +0100 (BST) From: Peter Tillotson Reply-To: Peter Tillotson Subject: Re: Using iterators to add columns to a row To: "user@accumulo.apache.org" In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="1253611123-2027089597-1366358956=:85676" X-Virus-Checked: Checked by ClamAV on apache.org --1253611123-2027089597-1366358956=:85676 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Many thanks - this is exactly the kind of solution I was looking for, I thi= nk I prefer the buffered row approach as I can add my columns at=A0arbitrar= y points.=A0=0A=0AI looked at the whole row iterator, bu I'm not keen on th= e=A0serialization overhead.=A0=A0 =A0=A0=0A=0Atnx=0A=0APeter=0A=0A=0A______= __________________________=0A From: Billie Rinaldi =0ATo: "user@accumulo.apache.org" ; Peter Tillo= tson =0ASent: Thursday, 18 April 2013, 18:43=0ASubj= ect: Re: Using iterators to add columns to a row=0A =0A=0A=0AWriting mutati= ons is not necessary in this case.=A0 The iterator has the ability to chang= e how the current row is seen, so you don't have to create a mutation to ch= ange the row -- you just have to create an extra key with the information y= ou want.=0A=0AOne possibility is to write an iterator that passes through e= xisting key/value pairs, counting them, until it gets to the end of the row= , at which point it creates a new key/value pair and passes that along befo= re continuing.=A0 You'd have to make sure the count column name was chosen = to sort at the end of the row.=A0 (If that is not possible you could iterat= e over the entire row first, but that's more work for Accumulo.)=A0 Below i= s an incomplete sketch of an end-of-row counting approach.=0A=0A=A0 public = Key getTopKey() {=0A=A0=A0=A0 if count key is ready=0A=A0=A0=A0=A0=A0 retur= n count key=0A=A0=A0=A0 else=0A=A0=A0=A0=A0=A0 return source's top key=0A= =A0 }=0A=A0 public void next() throws IOException {=0A=A0=A0=A0 if count ke= y is ready=0A=A0=A0=A0=A0=A0 reset count key to null=0A=A0=A0=A0 else {=0A= =A0=A0=A0=A0=A0 call next() on source iterator=0A=A0=A0=A0=A0=A0 if this is= the start of a new row {=0A=A0 =A0 =A0 =A0 prepare count key for previous = row=0A=A0=A0=A0=A0=A0=A0=A0 reset count=0A=0A=A0=A0=A0=A0=A0 }=0A=0A=A0=A0= =A0=A0=A0 increment count=0A=0A=A0=A0=A0 }=0A=0A=A0 }=0A=0A=0ABillie=0A=0A= =0A=0A=0AOn Thu, Apr 18, 2013 at 9:28 AM, Peter Tillotson wrote:=0A=0A=0A>=0A>Apologies in advanced - this is some of my first= Accumulo code, but I suspect there is a much better way to do this.=A0=0A>= =0A>=0A>=0A>Basically I'm trying to add an edge count column to each row of= my table, so I get rows along the following line=0A>=A0- node1 { =A0to:cou= nt:3, to:node2:,=A0to:node3:,=A0to:node3:=A0 }=0A>=0A>=0A>But on the client= side I only need write=A0=0A>=A0- node1 { =A0to:node2:,=A0to:node3:,=A0to:= node3:=A0 }=0A>=0A>=0A>I'd like to use the same approach to add indexes to= =A0separate=A0column families, and combiners to aggregate. =A0=0A>=0A>=0A>A= side from the inefficiency of a BatchWriter for each mutation=A0=0A>=A0- is= this the correct approach? or=0A>=A0- is there a simpler way to achieve th= is?=0A>=0A>=0A>Many thanks in advance=0A>=0A>=0A>Peter T=0A>=A0=0A>--- code= compiles but not tested ---=0A>=0A>=0A>import=A0java.io.IOException;=0A>im= port=A0java.nio.ByteBuffer;=0A>import=A0java.util.Map;=0A>=0A>import=A0org.= apache.accumulo.core.client.BatchWriter;=0A>import=A0org.apache.accumulo.co= re.client.Connector;=0A>import=A0org.apache.accumulo.core.client.MutationsR= ejectedException;=0A>import=A0org.apache.accumulo.core.data.Key;=0A>import= =A0org.apache.accumulo.core.data.Mutation;=0A>import=A0org.apache.accumulo.= core.data.Value;=0A>import=A0org.apache.accumulo.core.iterators.IteratorEnv= ironment;=0A>import=A0org.apache.accumulo.core.iterators.IteratorUtil.Itera= torScope;=0A>import=A0org.apache.accumulo.core.iterators.SortedKeyIterator;= =0A>import=A0org.apache.accumulo.core.iterators.SortedKeyValueIterator;=0A>= import=A0org.apache.accumulo.core.security.thrift.AuthInfo;=0A>import=A0org= .apache.accumulo.server.client.HdfsZooInstance;=0A>import=A0org.apache.hado= op.io.Text;=0A>=0A>public=A0class=A0EdgeCountIterator=A0extends=A0SortedKey= Iterator=0A>{=0A>=A0=A0=A0=A0private=A0boolean=A0isDisabled=A0=3D=A0false;= =0A>=A0=A0=A0=A0private=A0Connector=A0connector;=0A>=A0=A0=A0=A0private=A0K= ey=A0currentRowStart=A0=3D=A0null;=0A>=A0=A0=A0=A0private=A0String=A0tableI= d;=0A>=A0=A0=A0=A0private=A0int=A0count=A0=3D=A00;=0A>=A0=A0=A0=A0=0A>=A0= =A0=A0=A0@Override=0A>=A0=A0=A0=A0public=A0void=A0init(SortedKeyValueIterat= or=A0source,=A0Map=A0options,=A0IteratorEnv= ironment=A0env)=A0throws=A0IOException=0A>=A0=A0=A0=A0{=0A>=A0=A0=A0=A0=A0= =A0=A0=A0super.init(source,=A0options,=A0env);=0A>=A0=A0=A0=A0=A0=A0=A0=A0i= f(env.getIteratorScope()=A0=3D=3D=A0IteratorScope.scan)=0A>=A0=A0=A0=A0=A0= =A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0isDisabled=A0=3D=A0true;= =0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return;=0A>=A0=A0=A0=A0=A0=A0=A0=A0= }=0A>=A0=A0=A0=A0=A0=A0=A0=A0=0A>=A0=A0=A0=A0=A0=A0=A0=A0String=A0user=A0= =3D=A0options.get("username");=0A>=A0=A0=A0=A0=A0=A0=A0=A0String=A0password= =A0=3D=A0options.get("password");=0A>=A0=A0=A0=A0=A0=A0=A0=A0String=A0insta= nceId=A0=3D=A0options.get("instance");=0A>=A0=A0=A0=A0=A0=A0=A0=A0tableId= =A0=3D=A0options.get("tableId");=0A>=A0=A0=A0=A0=A0=A0=A0=A0=0A>=A0=A0=A0= =A0=A0=A0=A0=A0AuthInfo=A0authInfo=A0=3D=A0new=A0AuthInfo();=0A>=A0=A0=A0= =A0=A0=A0=A0=A0authInfo.setUser(user);=0A>=A0=A0=A0=A0=A0=A0=A0=A0authInfo.= setPassword(password.getBytes());=0A>=A0=A0=A0=A0=A0=A0=A0=A0authInfo.setIn= stanceId(instanceId);=0A>=A0=A0=A0=A0=A0=A0=A0=A0=0A>=A0=A0=A0=A0=A0=A0=A0= =A0authInfo.setInstanceId(instanceId);=0A>=A0=A0=A0=A0=A0=A0=A0=A0=0A>=A0= =A0=A0=A0=A0=A0=A0=A0=0A>=A0=A0=A0=A0=A0=A0=A0=A0try=0A>=A0=A0=A0=A0=A0=A0= =A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0connector=A0=A0=3D=A0HdfsZoo= Instance.getInstance().getConnector(authInfo);=0A>=A0=A0=A0=A0=A0=A0=A0=A0}= =0A>=A0=A0=A0=A0=A0=A0=A0=A0catch=A0(Exception=A0e)=0A>=A0=A0=A0=A0=A0=A0= =A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0throw=A0new=A0RuntimeExcepti= on(e);=0A>=A0=A0=A0=A0=A0=A0=A0=A0}=0A>=A0=A0=A0=A0}=0A>=0A>=A0=A0=A0=A0@Ov= erride=0A>=A0=A0=A0=A0public=A0void=A0next()=A0throws=A0IOException=0A>=A0= =A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0if(=A0isDisabled=A0)=0A>=A0=A0=A0=A0= =A0=A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0super.next();=0A>=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return;=0A>=A0=A0=A0=A0=A0=A0=A0=A0}=0A>= =A0=A0=A0=A0=A0=A0=A0=A0=0A>=A0=A0=A0=A0=A0=A0=A0=A0SortedKeyValueIterator<= Key,=A0Value>=A0source=A0=3D=A0getSource();=0A>=A0=A0=A0=A0=A0=A0=A0=A0whil= e(source.hasTop())=0A>=A0=A0=A0=A0=A0=A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0Key=A0key=A0=3D=A0source.getTopKey();=0A>=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0Value=A0val=A0=3D=A0source.getTopValue();=0A>=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0source.next();= =0A>=A0=A0=A0=A0=A0=A0=A0=A0}=0A>=A0=A0=A0=A0=A0=A0=A0=A0doMutations(curren= tRowStart);=0A>=A0=A0=A0=A0=A0=A0=A0=A0super.next();=0A>=A0=A0=A0=A0}=0A>= =A0=A0=A0=A0=0A>=A0=A0=A0=A0public=A0void=A0process(=A0Key=A0key,=A0Value= =A0val=A0)=0A>=A0=A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0if(currentRowStart= =A0=3D=3D=A0null)=0A>=A0=A0=A0=A0=A0=A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0currentRowStart=A0=3D=A0key;=0A>=A0=A0=A0=A0=A0=A0=A0=A0}=0A>= =A0=A0=A0=A0=A0=A0=A0=A0else=0A>=A0=A0=A0=A0=A0=A0=A0=A0{=0A>=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0if(=A0!currentRowStart.getRow().equals(key.getRow()= )=A0)=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0doMutations(currentRowStart);=0A>=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0currentRowStart=A0=3D=A0key;=0A>=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0count=A0=3D=A00;=0A>=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0}=0A>=A0=A0=A0=A0=A0=A0=A0=A0}=0A>=A0=A0=A0=A0=A0=A0=A0= =A0count++;=0A>=A0=A0=A0=A0}=0A>=0A>=A0=A0=A0=A0public=A0void=A0doMutations= (=A0Key=A0rowStartKey=A0)=0A>=A0=A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0Batch= Writer=A0writer=A0=3D=A0null;=0A>=A0=A0=A0=A0=A0=A0=A0=A0try=0A>=A0=A0=A0= =A0=A0=A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0writer=A0=3D=A0conn= ector.createBatchWriter(tableId,=A00,=A00,=A02);=0A>=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0Mutation=A0mutation=A0=3D=A0new=A0Mutation(=A0rowStartKey.ge= tRow()=A0);=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0Text=A0colQ=A0=3D=A0new= =A0Text("count");=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ByteBuffer=A0b=A0= =3D=A0ByteBuffer.allocate(4);=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0b.putI= nt(count).array();=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0mutation.put(rowS= tartKey.getColumnFamily(),=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0colQ,=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0new=A0Value(b));=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0writer.add= Mutation(mutation);=0A>=A0=A0=A0=A0=A0=A0=A0=A0}=0A>=A0=A0=A0=A0=A0=A0=A0= =A0catch(Exception=A0e)=0A>=A0=A0=A0=A0=A0=A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0throw=A0new=A0RuntimeException(e);=0A>=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=0A>=A0=A0=A0=A0=A0=A0=A0=A0}=0A>=A0=A0=A0=A0=A0=A0=A0=A0= finally=0A>=A0=A0=A0=A0=A0=A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0if(writer=A0!=3D=A0null)=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0{=0A>=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0try=0A>=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0writer.close();=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0}=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0catch=A0(M= utationsRejectedException=A0e)=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0{=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0t= hrow=A0new=A0RuntimeException(e);=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0}=0A>=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0}=0A>=A0=A0=A0=A0=A0=A0=A0=A0}=0A>=A0=A0=A0=A0=A0=A0=A0= =A0=0A>=A0=A0=A0=A0}=0A>}=0A>=0A>=0A> --1253611123-2027089597-1366358956=:85676 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Many thank= s - this is exactly the kind of solution I was looking for, I think I prefe= r the buffered row approach as I can add my columns at arbitrary point= s. 

I looked at the whole row iterator,= bu I'm not keen on the serialization overhead.    &nbs= p;

tnx

Peter


From: Billie Rinaldi <billie.rinal= di@gmail.com>
To: "= user@accumulo.apache.org" <user@accumulo.apache.org>; Peter Tillotson= <slatemine@yahoo.co.uk>
S= ent: Thursday, 18 April 2013, 18:43
S= ubject: Re: Using iterators to add columns to a row
=

Writing mutations is not = necessary in this case.  The iterator has the ability to change how th= e current row is seen, so you don't have to create a mutation to change the= row -- you just have to create an extra key with the information you want.=
=0A=0A
One possibility is to write an iterator that passes thr= ough existing key/value pairs, counting them, until it gets to the end of t= he row, at which point it creates a new key/value pair and passes that alon= g before continuing.  You'd have to make sure the count column name wa= s chosen to sort at the end of the row.  (If that is not possible you = could iterate over the entire row first, but that's more work for Accumulo.= )  Below is an incomplete sketch of an end-of-row counting approach.=0A
  public Key getTopKey() {
    if count key= is ready
      return count key
  = ;  else
      return source's top key
&= nbsp; }
  public void next() throws IOException {
 &n= bsp;  if count key is ready
=0A
     = reset count key to null
    else {
 =      call next() on source iterator
 &nbs= p;    if this is the start of a new row {
  &n= bsp;     prepare count key for previous row
  =       reset count
=0A
   &nb= sp;  }
      increment count
    }
  }<= br>

Billie


On Thu, Apr 18, 2013 at 9:28 A= M, Peter Tillotson <slatemine@yahoo.co.uk> wrote:
=0A=0A

=0A
Apologies in = advanced - this is some of my first Accumulo code, but I suspect there is a= much better way to do this. 
=0A
=0A=0A
=0A=0ABasica= lly I'm trying to add an edge count column to each row of my table, so I ge= t rows along the following line
=0A=0A - node1 {  to:count:3, to:node2:, to:node3:, to:node3:  = }
=0A=0A
=
But on the client = side I only need write 
=0A=0A - node1 = {  to:node2:, to:node3:, to:node3:  }
=0A=0A
I= 'd like to use the same approach to add indexes to separate colum= n families, and combiners to aggregate.  
=0A=0A
<= /div>
=0A=0AAside from the inefficiency of a BatchWriter for=0A each=0A mutation = ;
 - is this the correct approach? or
=0A=0A - is there a s= impler way to achieve this?

=0A=0A
<= span style=3D"background-color:transparent;">Many thanks in advance<= /div>
=0A=0A
Peter T
=0A=0A 
--- code compiles but not tested ---
=0A=0A
import = java.io.IOException;
=0A=0Aimport&nbs= p;java.nio.ByteBuffer;<= br style=3D"font-family: monospace, monospace;">=0A=0Aimp= ort java
.util.<= /span>Map;=
=0A=0A
import org.apache.accumulo.core.client.BatchWriter;
=0A=0Aimport org.apache.accumulo.core.client.Connector;
=0A= =0Aimport org.apache.accumulo.core.client.Mu= tationsRejectedException;
=0A= =0Aimport org.apache.accumulo.core.data.Key<= /span>;
=0A=0Aimpor= t org= = .apache.accumulo.
core.<= span style=3D"font-family: monospace, monospace;">data.Mutation;
=0A=0Aimpor= t org= = .apache.accumulo.core.<= span style=3D"font-family: monospace, monospace;">data.Value;
=0A=0Aimpor= t org= = .apache.accumulo.core.<= span style=3D"font-family: monospace, monospace;">iterators.<= span style=3D"font-family: monospace, monospace;">IteratorEnvironment;
=0A= =0Aimport org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
=0A=0Aimport org.apache.accumulo.core.iterators.SortedKeyIterator;
=0A= =0Aimport org.apache.accumulo.core.iterators.SortedKeyValueIterator;
=0A= =0Aimport org.apache.accumulo.core.security.= thrift.Aut= hInfo;
=0A=0A= import org.apache.accumulo.server.= client.Hdf= sZooInstance;
=0A= =0Aimport org.apache.hadoop.io.Tex= t;
=0A=0A
public = class EdgeCountIterator extends SortedKeyIterator
=0A=0A{
    private boolean isDisabled = = =3D false;
=0A=0A    private 
Connector conne= ctor;
=0A=0A<= span style=3D"font-family: monospace, monospace;">    <= /span>private Key currentRowStart =3D null;
=0A=0A &nb= sp;  private String tableId;=0A=0A    int count =3D 0= = ;
=0A=0A    
    @Override
=0A=0A=     public void init(SortedKeyValueIterator<KeyValuesource,&nbs= p;Map<<= /span>String,&nbs= p;String&g= t; optionsItera= torEnvironment envthrows <= /span>IOException
=0A=0A    {
        super.init(= sourceoptionsenv);
=0A=0A&= nbsp;       if<= /span>(env= = .getIteratorScope= () =3D=3D IteratorScope.scan)
=0A=0A  = ;      {
isDisabled =3D true;
=0A=0A          &= nbsp; return;
=0A=0A        }

        <= /span>
=0A=0A      &n= bsp; String&= nbsp;user =3D options.get("username");
=0A=0A        String password 
=3D optio= ns.get
("password");
=0A=0A = ;       String instanceId =3D options.= get("ins= tance");
=0A= =0A   &nb= sp;    tableId =3D options.get("tableId");
=0A=0A        
        = AuthInfo aut= hInfo =3D new AuthInfo();
=0A=0A        authInfo.setUser(user);=0A=0A       &nbs= p;authInfo= = .setPasswordpassword.getBytes= = ());
=0A=0A     &nb= sp;  au= thInfo.set= InstanceId(instanceId);
=0A=0A   = ;     
  =       authInfo.setInstanceId(instanceId);
=0A=0A        
        
        try

= =0A=0A   =      {
 = ;           <= span style=3D"font-family: monospace, monospace;">connector  =3D HdfsZ= ooInstance.getInstance().getConnector(aut= hInfo);
=0A= =0A   &nb= sp;    }
 &n= bsp;      catch = ;(Exceptio= n e)
=0A= =0A   &nb= sp;    {
 &n= bsp;          throw new 
RuntimeException(e);
=0A=0A&nb= sp;       }
    }
=0A=0A
   &nb= sp;@Override
    public void next() IOE= xception
=0A=0A          &nbs= p; ifisDisabled )
=0A=0A        <= span style=3D"color: rgb(48, 16, 16); font-family: monospace, monospace;">{=

       &= nbsp;    super.<= span style=3D"font-family: monospace, monospace;">next
();
=0A=0A        =     return;=0A=0A        = ;}
     &nbs= p;  
=0A= =0A   &nb= sp;    SortedKeyValueIterator<KeyValuesource =3D getSource();
=0A=0A        while(source.hasTop())
=0A=0A =        {
           &n= bsp;Key key&= nbsp;=3D source.getTopKey();
=0A=0A   = ;         Value val =3D = ;source.getTopValue<= span style=3D"color: rgb(48, 16, 16); font-family: monospace, monospace;">(= );

=0A=0A      = ;      
 =            source
.next
();
=0A=0A        }
      = ;  doMu= tations(cu= rrentRowStart);
=0A=0A  &nb= sp;     super.next();=
=0A=0A    }    
=0A=0A    public void processKey keyValue val )
=0A=0A    {
        if(= currentRowStart =3D=3D null
)
=0A=0A      = ;  {
   &nbs= p;        
currentRowStart =3D key;=0A=0A        = ;}
     &nbs= p;  else
=0A=0A        {
         &n= bsp;  if( !currentRowStart.getRow
().equals
(key= .getRow()) )
=0A= =0A   &nb= sp;        {
          = ;      doMutations(currentRowStart);
=0A=0A           =      currentRowStart =3D key;
=0A=0A           &n= bsp;    count =3D 0;
=0A=0A          = ;  }
   &nbs= p;    
}
=0A=0A&nb= sp;       count++;
=0A=0A    }

    = public void <= span style=3D"font-family: monospace, monospace;">doMutations( = Key rowStart= Key )
= =0A=0A   =  {
     = ;   =3D nul= l;
=0A=0A    &nbs= p;   try
        {
=0A=0A        &nb= sp;   writer =3D connector.createBatchWriter(tableId002);
=0A=0A           &n= bsp;Mutation = ;mutation =3D new MutationrowStartKey.getRow()&nbs= p;);
=0A=0A     &nb= sp;      Text colQ =3D new = Text("count");
=0A=0A=             ByteBuffer b&nb= sp;=3D .allocate(4);
=0A=0A&n= bsp;           
b.putInt(count).array();
=0A=0A         &nb= sp;  mu= tation.put= (rowStartK= ey.getColu= mnFamily(),
= =0A=0A   =             &nb= sp;    colQ,
=0A=0A  &nb= sp;            =      new Value(b));
=0A=0A         &nbs= p;  wri= ter.addMut= ation(muta= tion);
=0A=0A=     =     }
  = ;      catch<= span style=3D"color: rgb(48, 16, 16); font-family: monospace, monospace;">(= Exception e<= /span>)
=0A=0A     =    {
   = ;         throw new RuntimeException(e);
=0A=0A &nbs= p;          
        <= span style=3D"color: rgb(48, 16, 16); font-family: monospace, monospace;">}=

=0A=0A      = ;  finally
{
=0A=0A         = ;   if(writer !=3D null)
=0A=0A &nb= sp;          {
        = ;        t= ry
=0A=0A      = ;          {

        &= nbsp;           writer.= close();<= br style=3D"font-family: monospace, monospace;">=0A=0A       &nb= sp;        }
          = ;      catch (MutationsRe= jectedException e)
=0A=0A &= nbsp;           &nbs= p;  {
   &nb= sp;            =     throw new 
RuntimeException= = (e); =             &nb= sp;
=0A=0A        = ;        }
          = ;  }
  &nbs= p;     }
&nb= sp;       
=0A=0A    }
}
=0A=0A



=0A


=
--1253611123-2027089597-1366358956=:85676--