Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion ZoieSegmentReader.getUID maybe throws exceptioin

Received: by 10.42.161.74 with SMTP id s10mr24637619icx.5.1325211191865;
        Thu, 29 Dec 2011 18:13:11 -0800 (PST)
X-BeenThere: zoie@googlegroups.com
Received: by 10.231.29.8 with SMTP id o8ls23373132ibc.6.gmail; Thu, 29 Dec
 2011 18:13:11 -0800 (PST)
MIME-Version: 1.0
Received: by 10.50.207.106 with SMTP id lv10mr11682109igc.0.1325211191514;
 Thu, 29 Dec 2011 18:13:11 -0800 (PST)
Authentication-Results: ls.google.com; spf=pass (google.com: domain of
 yzygenu...@gmail.com designates internal as permitted sender)
 smtp.mail=yzygenu...@gmail.com; dkim=pass
 header...@gmail.com
Received: by g19g2000pri.googlegroups.com with HTTP; Thu, 29 Dec 2011 18:13:11
 -0800 (PST)
Date: Thu, 29 Dec 2011 18:13:11 -0800 (PST)
In-Reply-To: <CAK3ZUu+r-9ggKH0sHNW4g6EG-DHtEjbVEynDgTHdo5sjjU2cYw@mail.gmail.com>
References: <05a68844-0980-47ac-84cd-6480947a9da3@d6g2000pra.googlegroups.com>
 <CAK3ZUu+HLOJP9-TmqUoATPzZYLrysOOJXrqy4udo8e_RODeTzg@mail.gmail.com>
 <cc2a5870-2a71-4104-b0e2-23364968646f@q7g2000prl.googlegroups.com>
 <5d088183-4e9d-40bf-8ad4-0dfc0c7003a9@s10g2000prj.googlegroups.com>
 <CAK3ZUuKsGMToa0sOZ-p0VY_wqf4biap+b6Qh4+7kJRfY8khyaQ@mail.gmail.com>
 <CAEkdZG9N728Rq7mHOcc=2JSJcfEpG2HWd-RJoJ4nnOFcQJ1bbg@mail.gmail.com>
 <CAK3ZUu+evkXVce3ztHB_wwbnS7nRUjzRRSubGtOe4hY852bZtg@mail.gmail.com>
 <CAEkdZG9HzhptD8N7etZz6Z3Udc-=OK52R7auMoDdxe5sURQstg@mail.gmail.com> <CAK3ZUu+r-9ggKH0sHNW4g6EG-DHtEjbVEynDgTHdo5sjjU2cYw@mail.gmail.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1,gzip(gfe)
Message-ID: <9f1d326d-c236-4f33-85c1-6933a2f21ae5@g19g2000pri.googlegroups.com>
Subject: Re: ZoieSegmentReader.getUID maybe throws exceptioin
From: genuine <yzygenu...@gmail.com>
To: zoie <zoie@googlegroups.com>
Content-Type: text/plain; charset=GB2312
Content-Transfer-Encoding: quoted-printable

I use the zoie-core-3.1.0-SNAPSHOT,and I change some source,I have
change it base this version ,just like you send that source.


On Dec 30, 12:30 am, John Wang <john.w...@gmail.com> wrote:
> Oh. I think yo uare using a very old jar.
>
> See source at:
>
> https://github.com/javasoze/zoie/blob/master/zoie-solr/src/main/java/...
>
> So your change is definitely correct :)
>
> We will do a release shortly, stay tuned :)
>
> -John
>
> 2011/12/27 Gino Yu <yzygenu...@gmail.com>
>
>
>
>
>
>
>
> > That's I change the source..
>
> >   // long uid =3D zoieReader.getUID(doc + base);
> >    long uid =3D zoieReader.getUID(doc);
> > I change it at deleteByQuery.And it work,but I can't sure it ..
>
> > =D4=DA 2011=C4=EA12=D4=C227=C8=D5 =CF=C2=CE=E711:34=A3=ACJohn Wang <joh=
n.w...@gmail.com>=D0=B4=B5=C0=A3=BA
>
> > Is there a question or comment related to this post?
>
> >> -John
>
> >> 2011/12/27 Gino Yu <yzygenu...@gmail.com>
>
> >>> package proj.zoie.solr;
>
> >>> import it.unimi.dsi.fastutil.longs.LongArrayList;
> >>> import it.unimi.dsi.fastutil.longs.LongList;
>
> >>> import java.io.IOException;
> >>> import java.net.URL;
> >>> import java.util.ArrayList;
> >>> import java.util.Arrays;
> >>> import java.util.List;
> >>> import java.util.concurrent.Future;
>
> >>> import org.apache.log4j.Logger;
> >>> import org.apache.lucene.document.Document;
> >>> import org.apache.lucene.index.IndexReader;
> >>> import org.apache.lucene.index.MultiReader;
> >>> import org.apache.lucene.search.Collector;
> >>> import org.apache.lucene.search.IndexSearcher;
> >>> import org.apache.lucene.search.Query;
> >>> import org.apache.lucene.search.Scorer;
> >>> import org.apache.lucene.store.Directory;
> >>> import org.apache.solr.common.SolrException;
> >>> import org.apache.solr.common.util.NamedList;
> >>> import org.apache.solr.common.util.SimpleOrderedMap;
> >>> import org.apache.solr.core.SolrConfig;
> >>> import org.apache.solr.core.SolrCore;
> >>> import org.apache.solr.search.QueryParsing;
> >>> import org.apache.solr.update.AddUpdateCommand;
> >>> import org.apache.solr.update.CommitUpdateCommand;
> >>> import org.apache.solr.update.DeleteUpdateCommand;
> >>> import org.apache.solr.update.MergeIndexesCommand;
> >>> import org.apache.solr.update.RollbackUpdateCommand;
> >>> import org.apache.solr.update.UpdateHandler;
>
> >>> import proj.zoie.api.DataConsumer.DataEvent;
> >>> import proj.zoie.api.DocIDMapper;
> >>> import proj.zoie.api.Zoie;
> >>> import proj.zoie.api.ZoieException;
> >>> import proj.zoie.api.ZoieIndexReader;
> >>> import proj.zoie.api.indexing.IndexingEventListener;
> >>> import proj.zoie.impl.indexing.ZoieSystem;
>
> >>> public class ZoieUpdateHandler extends UpdateHandler {
> >>>     private static Logger log =3D
> >>> Logger.getLogger(ZoieUpdateHandler.class);
>
> >>>     private SolrCore _core;
>
> >>>     /**
> >>>      * =BC=E4=B8=F4=B6=E0=B3=A4=CA=B1=BC=E4=D6=D8=D0=C2=B4=F2=BF=AAse=
archer,=C4=AC=C8=CF=D6=B5=CA=C7=D2=BB=B7=D6=D6=D3
> >>>      */
> >>>     private static long intervalTime =3D 1000 * 60;// =D2=BB=B7=D6=D6=
=D3
>
> >>>     private Directory indexDir;
>
> >>>     private Zoie<IndexReader, DocumentWithID> zoie;
> >>>     /**
> >>>      * =BC=C7=C2=BC=D7=EE=BA=F3=D2=BB=B8=F6=B0=E6=B1=BE
> >>>      */
> >>>     private String lastVersion;
>
> >>>     public ZoieUpdateHandler(SolrCore core) {
> >>>         super(core);
> >>>         _core =3D core;
> >>>         SolrConfig solrConfig =3D _core.getSolrConfig();
> >>>         try {
> >>>             indexDir =3D
> >>> _core.getDirectoryFactory().open(solrConfig.getDataDir());
> >>>         } catch (Exception e) {
> >>>             log.error("", e);
> >>>         }
> >>>         long interval =3D
> >>> solrConfig.getInt("solrIndexSearcher.reopen.batchDelay", (int)
> >>> intervalTime);
> >>>         intervalTime =3D interval;
> >>>         log.info("intervalTime=A3=BA" + intervalTime + "
> >>> ,=BC=E4=B8=F4=CA=B1=BC=E4=D6=D8=D0=C2=B4=F2=BF=AASolrIndexSearcher");
> >>>         ZoieSystemHome zoieHome =3D ZoieSystemHome.getInstance(_core)=
;
> >>>         if (zoieHome =3D=3D null) {
> >>>             log.error("zoie home is not setup");
> >>>             throw new RuntimeException("zoie is not setup");
> >>>         }
> >>>         zoie =3D zoieHome.getZoieSystem();
> >>>         if (zoie =3D=3D null) {
> >>>             log.error("zoie is not setup");
> >>>             throw new RuntimeException("zoie is not setup");
> >>>         }
> >>>         lastVersion =3D zoie.getCurrentReaderVersion();
> >>>         log.info("###################################################=
########################"
> >>> + lastVersion);
> >>>         runOpenSolrIndexSearcher();
> >>>         log.info("=B3=F5=CA=BC=BB=AF=BD=E1=CA=F8");
>
> >>>         ZoieSystem _zoie =3D (ZoieSystem) zoie;
> >>>         _zoie.addIndexingEventListener(new IndexingEventListener() {
> >>>             @Override
> >>>             public void handleIndexingEvent(IndexingEvent evt) {
> >>>                 log.info(" ###########=CB=A2=CA=FD=BE=DD=B5=BD=D3=B2=
=C5=CC=B5=C4=CA=C2=BC=FE ###########");
> >>>             }
>
> >>>             @Override
> >>>             public void handleUpdatedDiskVersion(String version) {
> >>>                 log.info("indexingEventListener update
> >>> version###########");
> >>>             }
> >>>         });
> >>>     }
>
> >>>     /**
> >>>      * =BC=E0=BF=D8=CA=C7=B7=F1=D6=D8=D0=C2=B4=F2=BF=AAsearcher
> >>>      */
> >>>     private void runOpenSolrIndexSearcher() {
> >>>         log.info("=D7=BC=B1=B8=C6=F4=B6=AF=BC=E0=BF=D8=D6=D8=D0=C2=B4=
=F2=BF=AAsolrIndexSearcher=B5=C4=CF=DF=B3=CC=A1=A3=A1=A3");
> >>>         Thread thread =3D new Thread() {
> >>>             public void run() {
> >>>                 try {
> >>>                     log.info("=D0=DD=CF=A210=C3=EB=A1=A3=A1=A3");
> >>>                     Thread.sleep(10000);
> >>>                 } catch (Exception e) {
> >>>                     log.error("", e);
> >>>                 }
> >>>                 try {
> >>>                     while (true) {
> >>>                         log.info("=D0=DD=CF=A2" + intervalTime + "  =
=BA=C1=C3=EB=A1=A3=A1=A3");
> >>>                         Thread.sleep(intervalTime);
> >>>                         boolean hasChange =3D readerHasChange();
> >>>                         log.info("reader=CA=C7=B7=F1=D3=D0=D0=DE=B8=
=C4=B9=FD############################:"
> >>> + hasChange);
> >>>                         if (hasChange) {
> >>>                             log.info("=D6=D8=D0=C2=B4=F2=BF=AAsolrInd=
exSearcher");
> >>>                             try {
> >>>                                 updateReader(false);
> >>>                             } catch (Exception e) {
> >>>                                 log.error("", e);
> >>>                             }
> >>>                         }
> >>>                         log.info("=D0=DD=CF=A2");
> >>>                     }
> >>>                 } catch (Exception e) {
> >>>                     log.error("", e);
> >>>                 }
> >>>             }
> >>>         };
> >>>         thread.start();
> >>>         log.info("=C6=F4=B6=AF=BC=E0=CC=FD=CF=DF=B3=CC");
> >>>     }
>
> >>>     /**
> >>>      * =BC=EC=B2=E2reader=CA=C7=B7=F1=D3=D0=D0=DE=B8=C4=A3=AC=C8=E7=
=B9=FB=D3=D0=D0=DE=B8=C4=D6=D8=D0=C2new searcher
> >>>      *
> >>>      * @return
> >>>      * @throws Exception
> >>>      */
> >>>     private boolean readerHasChange() throws Exception {
> >>>         String version =3D zoie.getCurrentReaderVersion();
> >>>         log.info("###########################################version:=
"
> >>> + version);
> >>>         if (version =3D=3D null) {
> >>>             return false;
> >>>         }
> >>>         if ((version !=3D null && lastVersion =3D=3D null) ||
> >>> version.compareTo(lastVersion) > 0) {
> >>>             lastVersion =3D version;
> >>>             return true;
> >>>         } else {
> >>>             return false;
> >>>         }
> >>>     }
>
> >>>     @Override
> >>>     public int addDoc(AddUpdateCommand cmd) throws IOException {
> >>>         if (zoie =3D=3D null) {
> >>>             throw new IOException("zoie is not setup");
> >>>         }
> >>>         // String id =3D cmd.getIndexedId(_core.getSchema());
> >>>         String uid2 =3D (String)
> >>> cmd.solrDoc.getFieldValue(idField.getName());
> >>>         long zoieUid;
> >>>         try {
> >>>             zoieUid =3D Long.parseLong(uid2);
> >>>         } catch (Exception e) {
> >>>             throw new IOException("index uid must exist and of type
> >>> long: " + uid2);
> >>>         }
> >>>         Document doc =3D cmd.doc;
> >>>         long time =3D System.currentTimeMillis();
> >>>         String version =3D String.valueOf(time);
> >>>         DataEvent<DocumentWithID> event =3D new
> >>> DataEvent<DocumentWithID>(new DocumentWithID(zoieUid, doc), version);
> >>>         try {
> >>>             zoie.consume(Arrays.asList(event));
> >>>             return 1;
> >>>         } catch (ZoieException e) {
> >>>             log.error("", e);
> >>>             throw new IOException(e.toString());
> >>>         }
> >>>     }
>
> >>>     @Override
> >>>     public void close() throws IOException {
> >>>         ZoieSystemHome zoieHome =3D ZoieSystemHome.getInstance(_core)=
;
> >>>         if (zoieHome !=3D null) {
> >>>             zoieHome.shutdown();
> >>>         }
> >>>     }
>
> >>>     private void updateReader(boolean waitForSearcher) throws
> >>> IOException {
> >>>         callPostCommitCallbacks();
> >>>         Future[] waitSearcher =3D null;
> >>>         if (waitForSearcher) {
> >>>             waitSearcher =3D new Future[1];
> >>>         }
> >>>         core.getSearcher(true, false, waitSearcher);
> >>>     }
>
> >>>     @Override
> >>>     public void commit(CommitUpdateCommand cmd) throws IOException {
> >>>         if (zoie !=3D null) {
> >>>             try {
> >>>                 zoie.flushEvents(10000);
> >>>             } catch (ZoieException e) {
> >>>                 log.error(e.getMessage(), e);
> >>>             }
> >>>         }
> >>>         updateReader(cmd.waitSearcher);
> >>>     }
>
> >>>     @Override
> >>>     public void delete(DeleteUpdateCommand cmd) throws IOException {
> >>>         String id =3D cmd.id;
> >>>         long zoieUid;
> >>>         try {
> >>>             zoieUid =3D Long.parseLong(id);
> >>>         } catch (Exception e) {
> >>>             throw new IOException("index uid must exist and of type
> >>> long: " + id);
> >>>         }
> >>>         if (zoie =3D=3D null) {
> >>>             throw new IOException("zoie is not setup");
> >>>         }
> >>>         // String version =3D zoie.getVersion();
> >>>         long time =3D System.currentTimeMillis();
> >>>         String version =3D String.valueOf(time);
> >>>         DataEvent<DocumentWithID> event =3D new
> >>> DataEvent<DocumentWithID>(new DocumentWithID(zoieUid, true), version)=
;
> >>>         try {
> >>>             zoie.consume(Arrays.asList(event));
> >>>         } catch (ZoieException e) {
> >>>             log.error(e.getMessage(), e);
>
> ...
>