You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2020/07/30 12:56:42 UTC

[lucene-solr] branch branch_8x updated: LUCENE-9395: ConstantValuesSource now shares a single DoubleValues instance across all segments

This is an automated email from the ASF dual-hosted git repository.

mikemccand pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new 1eb61d3  LUCENE-9395: ConstantValuesSource now shares a single DoubleValues instance across all segments
1eb61d3 is described below

commit 1eb61d355b0ef62c245436b339b6c8f4949db7b5
Author: Mike McCandless <mi...@apache.org>
AuthorDate: Thu Jul 30 08:53:44 2020 -0400

    LUCENE-9395: ConstantValuesSource now shares a single DoubleValues instance across all segments
---
 lucene/CHANGES.txt                                 |  4 +++-
 .../apache/lucene/search/DoubleValuesSource.java   | 24 ++++++++++++----------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index fd1bc46..ae5b37b 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -30,7 +30,9 @@ Improvements
 
 Optimizations
 ---------------------
-(No changes)
+
+* LUCENE-9395: ConstantValuesSource now shares a single DoubleValues
+  instance across all segments (Tony Xu)
 
 Bug Fixes
 ---------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/DoubleValuesSource.java b/lucene/core/src/java/org/apache/lucene/search/DoubleValuesSource.java
index b181186..106069d 100644
--- a/lucene/core/src/java/org/apache/lucene/search/DoubleValuesSource.java
+++ b/lucene/core/src/java/org/apache/lucene/search/DoubleValuesSource.java
@@ -268,21 +268,12 @@ public abstract class DoubleValuesSource implements SegmentCacheable {
 
   private static class ConstantValuesSource extends DoubleValuesSource {
 
+    private final DoubleValues doubleValues;
     private final double value;
 
     private ConstantValuesSource(double value) {
       this.value = value;
-    }
-
-    @Override
-    public DoubleValuesSource rewrite(IndexSearcher searcher) {
-      return this;
-    }
-
-
-    @Override
-    public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws IOException {
-      return new DoubleValues() {
+      this.doubleValues = new DoubleValues() {
         @Override
         public double doubleValue() throws IOException {
           return value;
@@ -296,6 +287,17 @@ public abstract class DoubleValuesSource implements SegmentCacheable {
     }
 
     @Override
+    public DoubleValuesSource rewrite(IndexSearcher searcher) {
+      return this;
+    }
+
+
+    @Override
+    public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws IOException {
+      return doubleValues;
+    }
+
+    @Override
     public boolean needsScores() {
       return false;
     }