Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

nuke newRAMInstance

Michael McCandless9f62b51ab5ea
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41BinaryDocValues.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41BinaryDocValues.java
index 4ba4b4bf7f6..1c4f4fe6dfa 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41BinaryDocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41BinaryDocValues.java
@@ -90,19 +90,6 @@ public final class Lucene41BinaryDocValues extends BinaryDocValues {
public int maxLength() {
return maxLength;
}
-
-
-
- @Override
- public BinaryDocValues newRAMInstance() {
- try {
- return factory == null ? this : factory.getInMemory();
- } catch (IOException e) {
- return this; // nocommit ?? now IOException
- }
- }
-
-
public static final class Factory extends DocValuesFactory<BinaryDocValues> {
private final IndexInput datIn;
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41NumericDocValues.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41NumericDocValues.java
index d02b15ec5e7..68e1525ff79 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41NumericDocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41NumericDocValues.java
@@ -51,15 +51,6 @@ public class Lucene41NumericDocValues extends NumericDocValues {
return values.get(docID) + minValue;
}
- @Override
- public NumericDocValues newRAMInstance() {
- try {
- return factory == null ? this : factory.getInMemory();
- } catch (IOException e) {
- return this; // nocommit ?? now IOException
- }
- }
-
public static final class Factory extends DocValuesFactory<NumericDocValues> {
private final IndexInput datIn;
private final PackedInts.Header header;
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41SortedDocValues.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41SortedDocValues.java
index 180b3c83138..3da8a26aa94 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41SortedDocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41SortedDocValues.java
@@ -111,15 +111,6 @@ public class Lucene41SortedDocValues extends SortedDocValues {
return maxLength;
}
- @Override
- public SortedDocValues newRAMInstance() {
- try {
- return factory == null ? this : factory.getInMemory();
- } catch (IOException e) {
- return this; // nocommit ?? now IOException
- }
- }
-
public static final class Factory extends
DocValuesFactory<SortedDocValues> {
private final IndexInput datIn;
diff --git a/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.java b/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.java
index ece0b729efe..4f5d6b0437d 100644
--- a/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.java
@@ -30,54 +30,6 @@ public abstract class BinaryDocValues {
public abstract boolean isFixedLength();
public abstract int maxLength();
- // nocommit: rethink this api? alternative is boolean on atomicreader...?
- // doc that the thing returned here must be thread safe...
- public BinaryDocValues 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 int maxLength = maxLength();
- final boolean fixedLength = isFixedLength();
- final byte[][] values = new byte[maxDoc][];
- BytesRef scratch = new BytesRef();
- for(int docID=0;docID<maxDoc;docID++) {
- get(docID, scratch);
- values[docID] = new byte[scratch.length];
- System.arraycopy(scratch.bytes, scratch.offset, values[docID], 0, scratch.length);
- }
-
- return new BinaryDocValues() {
-
- @Override
- public void get(int docID, BytesRef result) {
- result.bytes = values[docID];
- result.offset = 0;
- result.length = result.bytes.length;
- }
-
- @Override
- public int size() {
- return maxDoc;
- }
-
- @Override
- public boolean isFixedLength() {
- return fixedLength;
- }
-
- @Override
- public int maxLength() {
- return maxLength;
- }
-
- @Override
- public BinaryDocValues newRAMInstance() {
- // nocommit: ugly, maybe throw exception instead?
- return this;
- }
- };
- }
-
public static class EMPTY extends BinaryDocValues {
private final int size;
diff --git a/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java b/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java
index f55265e09e8..03d275ad2aa 100644
--- a/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java
@@ -24,48 +24,6 @@ public abstract class NumericDocValues {
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;
diff --git a/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java b/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java
index c8525a2cf26..55daae6dce5 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java
@@ -144,68 +144,6 @@ public abstract class SortedDocValues extends BinaryDocValues {
};
}
- @Override
- public SortedDocValues newRAMInstance() {
- // nocommit optimize this
- // nocommit, see also BinaryDocValues nocommits
- final int maxDoc = size();
- final int maxLength = maxLength();
- final boolean fixedLength = isFixedLength();
- final int valueCount = getValueCount();
- // nocommit used packed ints and so on
- final byte[][] values = new byte[valueCount][];
- BytesRef scratch = new BytesRef();
- for(int ord=0;ord<values.length;ord++) {
- lookupOrd(ord, scratch);
- values[ord] = new byte[scratch.length];
- System.arraycopy(scratch.bytes, scratch.offset, values[ord], 0, scratch.length);
- }
-
- final int[] docToOrd = new int[maxDoc];
- for(int docID=0;docID<maxDoc;docID++) {
- docToOrd[docID] = getOrd(docID);
- }
- return new SortedDocValues() {
-
- @Override
- public int getOrd(int docID) {
- return docToOrd[docID];
- }
-
- @Override
- public void lookupOrd(int ord, BytesRef result) {
- result.bytes = values[ord];
- result.offset = 0;
- result.length = result.bytes.length;
- }
-
- @Override
- public int getValueCount() {
- return valueCount;
- }
-
- @Override
- public int size() {
- return maxDoc;
- }
-
- @Override
- public boolean isFixedLength() {
- return fixedLength;
- }
-
- @Override
- public int maxLength() {
- return maxLength;
- }
-
- @Override
- public SortedDocValues newRAMInstance() {
- return this; // see the nocommit in BinaryDocValues
- }
- };
- }
-
public static class EMPTY extends SortedDocValues {
private final int size;
diff --git a/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java b/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
index fb51f00ff9c..cabc730424c 100644
--- a/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
+++ b/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
@@ -396,13 +396,12 @@ class FieldCacheImpl implements FieldCache {
protected Object createValue(AtomicReader reader, CacheKey key, boolean setDocsWithField)
throws IOException {
- NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
+ final NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
if (valuesIn != null) {
- final NumericDocValues ramInstance = valuesIn.newRAMInstance();
return new Bytes() {
@Override
public byte get(int docID) {
- return (byte) ramInstance.get(docID);
+ return (byte) valuesIn.get(docID);
}
};
} else {
@@ -478,13 +477,12 @@ class FieldCacheImpl implements FieldCache {
protected Object createValue(AtomicReader reader, CacheKey key, boolean setDocsWithField)
throws IOException {
- NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
+ final NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
if (valuesIn != null) {
- final NumericDocValues ramInstance = valuesIn.newRAMInstance();
return new Shorts() {
@Override
public short get(int docID) {
- return (short) ramInstance.get(docID);
+ return (short) valuesIn.get(docID);
}
};
} else {
@@ -557,13 +555,12 @@ class FieldCacheImpl implements FieldCache {
protected Object createValue(final AtomicReader reader, CacheKey key, boolean setDocsWithField)
throws IOException {
- NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
+ final NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
if (valuesIn != null) {
- final NumericDocValues ramInstance = valuesIn.newRAMInstance();
return new Ints() {
@Override
public int get(int docID) {
- return (int) ramInstance.get(docID);
+ return (int) valuesIn.get(docID);
}
};
} else {
@@ -708,13 +705,12 @@ class FieldCacheImpl implements FieldCache {
protected Object createValue(AtomicReader reader, CacheKey key, boolean setDocsWithField)
throws IOException {
- NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
+ final NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
if (valuesIn != null) {
- final NumericDocValues ramInstance = valuesIn.newRAMInstance();
return new Floats() {
@Override
public float get(int docID) {
- return Float.intBitsToFloat((int) ramInstance.get(docID));
+ return Float.intBitsToFloat((int) valuesIn.get(docID));
}
};
} else {
@@ -796,13 +792,12 @@ class FieldCacheImpl implements FieldCache {
protected Object createValue(AtomicReader reader, CacheKey key, boolean setDocsWithField)
throws IOException {
- NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
+ final NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
if (valuesIn != null) {
- final NumericDocValues ramInstance = valuesIn.newRAMInstance();
return new Longs() {
@Override
public long get(int docID) {
- return ramInstance.get(docID);
+ return valuesIn.get(docID);
}
};
} else {
@@ -884,13 +879,12 @@ class FieldCacheImpl implements FieldCache {
protected Object createValue(AtomicReader reader, CacheKey key, boolean setDocsWithField)
throws IOException {
- NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
+ final NumericDocValues valuesIn = reader.getNumericDocValues(key.field);
if (valuesIn != null) {
- final NumericDocValues ramInstance = valuesIn.newRAMInstance();
return new Doubles() {
@Override
public double get(int docID) {
- return Double.longBitsToDouble(ramInstance.get(docID));
+ return Double.longBitsToDouble(valuesIn.get(docID));
}
};
} else {
@@ -1158,7 +1152,7 @@ class FieldCacheImpl implements FieldCache {
final int maxDoc = reader.maxDoc();
SortedDocValues valuesIn = reader.getSortedDocValues(key.field);
if (valuesIn != null) {
- return valuesIn.newRAMInstance();
+ return valuesIn;
} else {
Terms terms = reader.terms(key.field);
@@ -1328,7 +1322,7 @@ class FieldCacheImpl implements FieldCache {
BinaryDocValues valuesIn = reader.getBinaryDocValues(key.field);
if (valuesIn != null) {
- return valuesIn.newRAMInstance();
+ return valuesIn;
} else {
final int maxDoc = reader.maxDoc();
Terms terms = reader.terms(key.field);
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java b/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java
index f8c7428e48f..9cb6aa0583c 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java
@@ -986,12 +986,12 @@ public class TestDocValuesIndexing extends LuceneTestCase {
writer.close();
final AtomicReader sr = getOnlySegmentReader(r);
- final SortedDocValues dv = sorted(sr, "stringdv").newRAMInstance();
+ final SortedDocValues dv = sorted(sr, "stringdv");
assertNotNull(dv);
final long END_TIME = System.currentTimeMillis() + (TEST_NIGHTLY ? 30 : 1);
- final NumericDocValues docIDToID = numeric(sr, "id").newRAMInstance();
+ final NumericDocValues docIDToID = numeric(sr, "id");
final int NUM_THREADS = _TestUtil.nextInt(random(), 1, 10);
Thread[] threads = new Thread[NUM_THREADS];
@@ -1309,7 +1309,7 @@ public class TestDocValuesIndexing extends LuceneTestCase {
public NumericDocValues numeric(AtomicReader reader, String field) throws IOException {
NumericDocValues docValues = reader.getNumericDocValues(field);
if(random().nextBoolean()) {
- return docValues.newRAMInstance();
+ return docValues;
}
return docValues;
}
@@ -1327,16 +1327,15 @@ public class TestDocValuesIndexing extends LuceneTestCase {
public BinaryDocValues binary(AtomicReader reader, String field) throws IOException {
BinaryDocValues docValues = reader.getBinaryDocValues(field);
if(random().nextBoolean()) {
- return docValues.newRAMInstance();
+ return docValues;
}
return docValues;
}
public SortedDocValues sorted(AtomicReader reader, String field) throws IOException {
SortedDocValues docValues = reader.getSortedDocValues(field);
if(random().nextBoolean()) {
- return docValues.newRAMInstance();
+ return docValues;
}
return docValues;
}
-
}