Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: Two poorly optimized functions in SQLParser.java: msg#00393

apache.db.derby.devel

Subject: Re: Two poorly optimized functions in SQLParser.java


I am merely suggesting that it would be more efficient if JavaCC produced
'switch' statements for these rather than the nested 'if' statements.

So far, I haven't been able to determine how to modify the sqlgrammar.jj
file to achieve this.

It's time for me to out myself. I wrote most of sqlgrammar.jj, along with a lot of the other Cloudscape/Derby language code. I no longer work on Cloudscape or Derby, but I'm still interested in it.

The code in SQLParser.java consists mostly of rules from sqlgrammar.jj and lookahead code. I suspect the massive nested if statements are for lookahead.

sqlgrammar.jj uses a single token of lookahead by default. The first implementation of sqlgrammar.jj used numeric lookahead to disambiguate the grammar. That is, where javacc would report that more tokens of lookahead were needed, I would put in LOOKAHEAD(2) (or 3 or 4, or whatever javacc suggested). This led to a very large parser.

The javacc development team told me that the size of the parser would be reduced significantly if, in those places where more than one token of lookahead is needed, we used semantic lookahead rather than numeric lookahead. What that means is that, where the grammar is ambiguous with a single token of lookahead, we use a hand-written method for lookahead rather than tell javacc to look ahead two or more tokens. When I made this change, the number of generated methods starting with "jj_" shrank significantly.

I suspect the ugly massive nested if statements in SQLParser.java have to do with lookahead. I thought that maybe someone had put in some numeric lookahead, but I didn't find any such thing when I looked through sqlgrammar.jj. It's possible that I missed something, though.

In any case, it would help to have the complete call stack for the methods in question. I am particularly interested in which grammar rules are calling these methods. Given that, I might be able to figure out what's going on by looking at sqlgrammar.jj


- Jeff Lichtman
swazoo-KealBaEQdz4@xxxxxxxxxxxxxxxx
Check out Swazoo Koolak's Web Jukebox at
http://swazoo.com/



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
hardware.arm.at...    cms.citadel.dev...    video.gstreamer...    java.facelets.u...    misc.basics.qna...    web.wiki.instik...    network.uip.use...    xdg.devel/2003-...    tex.bibtex.bibd...    finance.quotesp...    ietf.zeroconf/2...    redhat.blinux.g...    suse.db2/2003-0...    php.phpesp/2004...    uml.devel/2003-...    gnome.labyrinth...    qnx.openqnx.dev...    boot-loaders.gr...    db.dataperfect....    audio.audacity....    linux.uclinux.m...    editors.j.devel...    os.openbsd.tech...    kde.users.multi...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation