You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/12/11 20:58:45 UTC
[21/27] lucene-solr:jira/http2: LUCENE-8602: Share TermsEnum if
possible while applying DV updates
LUCENE-8602: Share TermsEnum if possible while applying DV updates
Today we pull a new terms enum when we apply DV updates even though the
field stays the same which is the common case. Benchmarking this on a
larger term dictionary with a significant number of updates shows a
2x improvement in performance.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d08e2d49
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d08e2d49
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d08e2d49
Branch: refs/heads/jira/http2
Commit: d08e2d49d3000805d4bc67db453fde12d1e0810d
Parents: 3147c13
Author: Simon Willnauer <si...@apache.org>
Authored: Tue Dec 11 17:28:08 2018 +0100
Committer: Simon Willnauer <si...@apache.org>
Committed: Tue Dec 11 19:14:16 2018 +0100
----------------------------------------------------------------------
.../org/apache/lucene/index/FrozenBufferedUpdates.java | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d08e2d49/lucene/core/src/java/org/apache/lucene/index/FrozenBufferedUpdates.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/FrozenBufferedUpdates.java b/lucene/core/src/java/org/apache/lucene/index/FrozenBufferedUpdates.java
index 2ba2cc5..084bcc0 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FrozenBufferedUpdates.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FrozenBufferedUpdates.java
@@ -468,7 +468,7 @@ final class FrozenBufferedUpdates {
long delGen,
boolean segmentPrivateDeletes) throws IOException {
- TermsEnum termsEnum;
+ TermsEnum termsEnum = null;
PostingsEnum postingsEnum = null;
// TODO: we can process the updates per DV field, from last to first so that
@@ -492,11 +492,14 @@ final class FrozenBufferedUpdates {
boolean isNumeric = value.isNumeric();
FieldUpdatesBuffer.BufferedUpdateIterator iterator = value.iterator();
FieldUpdatesBuffer.BufferedUpdate bufferedUpdate;
+ String previousField = null;
while ((bufferedUpdate = iterator.next()) != null) {
- Terms terms = segState.reader.terms(bufferedUpdate.termField);
- if (terms != null) {
- termsEnum = terms.iterator();
- } else {
+ if (previousField == null || previousField.equals(bufferedUpdate.termField) == false) {
+ previousField = bufferedUpdate.termField;
+ Terms terms = segState.reader.terms(previousField);
+ termsEnum = terms == null ? null : terms.iterator();
+ }
+ if (termsEnum == null) {
// no terms in this segment for this field
continue;
}