lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 35037] - [PATCH] Some Field methods use Classcast check instead of instanceof which is slow
Date Tue, 24 May 2005 23:08:47 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35037>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35037





------- Additional Comments From psmith@apache.org  2005-05-25 01:08 -------
The area of code that is affected by this is in
DocumentWriter.invertDocument(Document):

...
          Reader reader;			  // find or make Reader
          if (field.readerValue() != null)
            reader = field.readerValue();
          else if (field.stringValue() != null)
            reader = new StringReader(field.stringValue());
          else
            throw new IllegalArgumentException
                    ("field must have either String or Reader value");


In my test scenario I do not use a reader, all my Fields are created as normal
String values, so the first if() to determine if the reader comes back null will
always result in an ClassCastException.  

That's 1 ClassCastException for each Indexed & Tokenized field _per_ Document.

I'm not sure of whether String/Reader is more prevelant out there in the wild,
but I would have thought String would have been common.  Sure for large
documents like PDF's etc it's more likely a Reader will be used.

Anyway, for the try/catch block, the JVM performs an implicit ClassCast check
anyway, that's how it determines whether it should throw an exception or not, so
there is no way to avoid some form of an instanceof.

Modern JVM's are quicker with instanceof.  However this may not (probably not)
true for older (1.2 or earlier?) VM's, although I don't have access to that
anymore test that theory.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message