You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kr...@apache.org on 2016/10/20 19:31:35 UTC

[26/50] [abbrv] lucene-solr:jira/solr-8593: LUCENE-7489: Wrap only once in case GCD compression is used.

LUCENE-7489: Wrap only once in case GCD compression is used.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a17e9200
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a17e9200
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a17e9200

Branch: refs/heads/jira/solr-8593
Commit: a17e92006f087a0601d9329bf9b9c946ca72478b
Parents: 739981b
Author: Adrien Grand <jp...@gmail.com>
Authored: Tue Oct 18 16:07:52 2016 +0200
Committer: Adrien Grand <jp...@gmail.com>
Committed: Tue Oct 18 16:08:29 2016 +0200

----------------------------------------------------------------------
 .../lucene70/Lucene70DocValuesProducer.java     | 63 +++++++++-----------
 1 file changed, 27 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a17e9200/lucene/core/src/java/org/apache/lucene/codecs/lucene70/Lucene70DocValuesProducer.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene70/Lucene70DocValuesProducer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene70/Lucene70DocValuesProducer.java
index 755da79..637c8ee 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene70/Lucene70DocValuesProducer.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene70/Lucene70DocValuesProducer.java
@@ -424,47 +424,38 @@ final class Lucene70DocValuesProducer extends DocValuesProducer implements Close
       };
     } else {
       final RandomAccessInput slice = data.randomAccessSlice(entry.valuesOffset, entry.valuesLength);
-      LongValues values = DirectReader.getInstance(slice, entry.bitsPerValue);
-      if (entry.gcd != 1) {
-        values = applyGcd(values, entry.gcd);
-      }
-      if (entry.minValue != 0) {
-        values = applyDelta(values, entry.minValue);
-      }
+      final LongValues values = DirectReader.getInstance(slice, entry.bitsPerValue);
       if (entry.table != null) {
-        values = applyTable(values, entry.table);
+        final long[] table = entry.table;
+        return new LongValues() {
+          @Override
+          public long get(long index) {
+            return table[(int) values.get(index)];
+          }
+        };
+      } else if (entry.gcd != 1) {
+        final long gcd = entry.gcd;
+        final long minValue = entry.minValue;
+        return new LongValues() {
+          @Override
+          public long get(long index) {
+            return values.get(index) * gcd + minValue;
+          }
+        };
+      } else if (entry.minValue != 0) {
+        final long minValue = entry.minValue;
+        return new LongValues() {
+          @Override
+          public long get(long index) {
+            return values.get(index) + minValue;
+          }
+        };
+      } else {
+        return values;
       }
-      return values;
     }
   }
 
-  private LongValues applyDelta(LongValues values, long delta) {
-    return new LongValues() {
-      @Override
-      public long get(long index) {
-        return delta + values.get(index);
-      }
-    };
-  }
-
-  private LongValues applyGcd(LongValues values, long gcd) {
-    return new LongValues() {
-      @Override
-      public long get(long index) {
-        return values.get(index) * gcd;
-      }
-    };
-  }
-
-  private LongValues applyTable(LongValues values, long[] table) {
-    return new LongValues() {
-      @Override
-      public long get(long index) {
-        return table[(int) values.get(index)];
-      }
-    };
-  }
-
   @Override
   public BinaryDocValues getBinary(FieldInfo field) throws IOException {
     BinaryEntry entry = binaries.get(field.name);