You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/11/19 15:29:54 UTC
svn commit: r1411200 - in
/lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene:
codecs/SimpleDVConsumer.java index/NumericDocValues.java
Author: rmuir
Date: Mon Nov 19 14:29:53 2012
New Revision: 1411200
URL: http://svn.apache.org/viewvc?rev=1411200&view=rev
Log:
add in-ram datastructure to Numeric codec api too
Modified:
lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/codecs/SimpleDVConsumer.java
lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java
Modified: lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/codecs/SimpleDVConsumer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/codecs/SimpleDVConsumer.java?rev=1411200&r1=1411199&r2=1411200&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/codecs/SimpleDVConsumer.java (original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/codecs/SimpleDVConsumer.java Mon Nov 19 14:29:53 2012
@@ -85,7 +85,7 @@ public abstract class SimpleDVConsumer i
//System.out.println("merge field=" + mergeState.fieldInfo.name);
NumericDocValues docValues = reader.getNumericDocValues(mergeState.fieldInfo.name);
if (docValues == null) {
- docValues = new NumericDocValues.EMPTY(1);
+ docValues = new NumericDocValues.EMPTY(maxDoc);
}
for (int i = 0; i < maxDoc; i++) {
if (liveDocs == null || liveDocs.get(i)) {
Modified: lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java?rev=1411200&r1=1411199&r2=1411200&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java (original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java Mon Nov 19 14:29:53 2012
@@ -25,6 +25,48 @@ public abstract class NumericDocValues {
public abstract long minValue();
public abstract long maxValue();
public abstract int size();
+
+ public NumericDocValues newRAMInstance() {
+ // TODO: optimize this default impl with e.g. isFixedLength/maxLength and so on
+ // nocommit used packed ints/pagedbytes and so on
+ final int maxDoc = size();
+ final long minValue = minValue();
+ final long maxValue = maxValue();
+
+ final long[] values = new long[maxDoc];
+ for(int docID=0;docID<maxDoc;docID++) {
+ values[docID] = get(docID);
+ }
+
+ return new NumericDocValues() {
+
+ @Override
+ public long get(int docID) {
+ return values[docID];
+ }
+
+ @Override
+ public int size() {
+ return maxDoc;
+ }
+
+ @Override
+ public long minValue() {
+ return minValue;
+ }
+
+ @Override
+ public long maxValue() {
+ return maxValue;
+ }
+
+ @Override
+ public NumericDocValues newRAMInstance() {
+ // nocommit: ugly, maybe throw exception instead?
+ return this;
+ }
+ };
+ }
public static final class EMPTY extends NumericDocValues {
private final int size;