From: Rodrigo C. <rn...@gm...> - 2007-02-28 12:45:25
|
I understand NodeRecorder was not intended to be kept in large numbers, but I think that should exactly be the idea of a random access API: a lightweight way of keeping a bunch of bookmarks in the datastructure the programmer wants, not in the structure we want, or something... Your API is nice for somewhat serial processing, not for true random access, using pre-build hash tables, for example, or trees, or whatever. I could built a wrapper around NodeRecorder implementing a simplier API, but that would be really clumsy. My API, while incomplete, is much more simple, and flexible also... it's also rather light. I would like to learn about other opinions on the subject, since we are probably both too used to our way of doing things to be impartial. Jimmy Zhang wrote: > There is an example in the code example that shows you how to use this > class correctly... > resetPointer is only called *after* you finish recording and *before* > you* > start reading... > Look at the example and let me know, I thought about the possibility of > creating something as part of VTDNav, and vote against it because > (1) multiple instance of nodeRecorder can be instantiated > (2) It could get pretty heavy if overused > > The suggestion that you wrote seems to assume that there are only a few > copies of context, that may not general purpose enough for other people's > needs > ----- Original Message ----- From: "Rodrigo Cunha" <rn...@gm...> > To: <vtd...@li...> > Sent: Tuesday, February 27, 2007 10:42 AM > Subject: Re: [Vtd-xml-users] Random Access Proposal (take 2) > > >> Hi Jimmy! >> >> I've tested the new random access API... it doesn't quite work the way I >> expected, for example: >> >> AutoPilot ap = new AutoPilot(vn); >> ap.bind(vn); >> ap.selectElement("ServiceID"); >> NodeRecorder myContext = new NodeRecorder(vn); >> while(ap.iterate()){ >> myContext.record(); >> // do something messy >> myContext.resetPointer(); >> } >> >> resetPointer also affects ap context precluding it from correctly >> cycling the values. >> >> Why don't you just export something similar to what is kept in the stack >> anyway? A context is so simple, you just need an efficient byte array... >> >> When you ask for context repositioning you just have to overwrite the >> values in "vn", no need for anything more. A context is (should be) the >> equivalent to a stack position, nothing more... >> >> I think I sent you my altered ximpleware_1.6, do you want the code to >> look again? >> >> This is a simple context: >> >> /** >> * This class is used to store a single context of VTDNav class. >> */ >> public class SimpleContext{ >> private int[] buf; >> private int bufsize = 0; >> public SimpleContext(int[] in) { >> // This allows both allocation during creation and allocating >> // an adequate buffer size so that no further reallocation is >> // needed in the future. >> if (in != null) { >> buf = in.clone(); >> bufsize = in.length; >> } else { >> buf = new int[0]; >> bufsize = 0; >> } >> } >> public void set(int[] in) { >> if (buf.length < in.length) { >> buf = in.clone(); >> } else { >> System.arraycopy(in,0,buf,0,in.length); >> bufsize = in.length; >> } >> } >> public boolean get(int[] out) { >> if (bufsize > 0) { >> if (out.length != buf.length) { >> out = buf.clone(); >> } else { >> System.arraycopy(buf,0,out,0,bufsize); >> } >> return true; >> } else { >> return false; >> } >> } >> } >> >> >> Jimmy Zhang wrote: >>> The latest benchmark reports (on Version 2.0) is now live >>> at >>> http://vtd-xml.sf.net/benchmark1.html >>> >>> The corresponding benchmark code also was uploaded >>> to the sourceforge at >>> >>> http://sourceforge.net/project/showfiles.php?group_id=110612 >>> >>> >>> ------------------------------------------------------------------------- >>> >>> Take Surveys. Earn Cash. Influence the Future of IT >>> Join SourceForge.net's Techsay panel and you'll get the chance to >>> share your >>> opinions on IT & business topics through brief surveys-and earn cash >>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >>> >>> _______________________________________________ >>> Vtd-xml-users mailing list >>> Vtd...@li... >>> https://lists.sourceforge.net/lists/listinfo/vtd-xml-users >>> >>> >> >> >> ------------------------------------------------------------------------- >> >> Take Surveys. Earn Cash. Influence the Future of IT >> Join SourceForge.net's Techsay panel and you'll get the chance to >> share your >> opinions on IT & business topics through brief surveys-and earn cash >> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >> >> _______________________________________________ >> Vtd-xml-users mailing list >> Vtd...@li... >> https://lists.sourceforge.net/lists/listinfo/vtd-xml-users > > > |