Issue Details (XML | Word | Printable)

Key: LUCENE-1185
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Christian Kohlschütter
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

[PATCH] Avoid checking for TermBuffer in SegmentTermEnum#scanTo

Created: 22/Feb/08 10:25 AM   Updated: 11/Oct/08 12:49 PM
Return to search
Component/s: Index
Affects Version/s: 2.3, 2.3.1, 2.4
Fix Version/s: 2.4

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works LUCENE-1185-SegmentTermEnum.patch 2008-02-22 10:56 AM Christian Kohlschütter 1 kB
Environment: any

Lucene Fields: Patch Available, New
Resolution Date: 23/Feb/08 02:36 AM


 Description  « Hide
It seems that SegmentTermEnum#scanTo is a critical method which is called very often, especially whenever we iterate over a sequence of terms in an index.

When that method is called, the first thing happens is that it checks whether a temporary TermBuffer "scratch" has already been initialized.

In fact, this is not necessary. We can simply declare and initialize the "scratch"-Buffer at the class-level (right now, the initial value is null). Java's lazy-loading capabilities allow this without adding any memory footprint for cases where we do not need that buffer.

The attached patch takes care of this. We now save one comparison per term.
In addition to that, the patch renames "scratch" to "scanBuffer", which aligns with the naming of the other two buffers that are declared in the class.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Christian Kohlschütter added a comment - 22/Feb/08 10:26 AM
The patch.

Christian Kohlschütter made changes - 22/Feb/08 10:26 AM
Field Original Value New Value
Attachment patch-SegmentTermEnum.diff [ 12376212 ]
Christian Kohlschütter made changes - 22/Feb/08 10:56 AM
Attachment patch-SegmentTermEnum.diff [ 12376212 ]
Christian Kohlschütter added a comment - 22/Feb/08 10:56 AM
The patch.

Christian Kohlschütter made changes - 22/Feb/08 10:56 AM
Attachment LUCENE-1185-SegmentTermEnum.patch [ 12376219 ]
Repository Revision Date User Message
ASF #630377 Sat Feb 23 02:35:14 UTC 2008 buschmi LUCENE-1185: Avoid checking if the TermBuffer 'scratch' in SegmentTermEnum is null for every call of scanTo().
Files Changed
MODIFY /lucene/java/trunk/CHANGES.txt
MODIFY /lucene/java/trunk/src/java/org/apache/lucene/index/SegmentTermEnum.java

Michael Busch added a comment - 23/Feb/08 02:36 AM
Committed. Thanks Christian!

Michael Busch made changes - 23/Feb/08 02:36 AM
Resolution Fixed [ 1 ]
Lucene Fields [Patch Available, New] [New, Patch Available]
Fix Version/s 2.4 [ 12312681 ]
Status Open [ 1 ] Resolved [ 5 ]
Michael McCandless made changes - 11/Oct/08 12:49 PM
Status Resolved [ 5 ] Closed [ 6 ]