Apache Solr open-source search software
add missing files
Michael McCandless04af95d20f41
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/SimpleDVProducer.java b/lucene/core/src/java/org/apache/lucene/codecs/SimpleDVProducer.javanew file mode 100644index 00000000000..693a4803d6f--- /dev/null+++ b/lucene/core/src/java/org/apache/lucene/codecs/SimpleDVProducer.java@@ -0,0 +1,120 @@+package org.apache.lucene.codecs;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import java.io.Closeable;+import java.io.IOException;++import org.apache.lucene.index.BinaryDocValues;+import org.apache.lucene.index.FieldInfo;+import org.apache.lucene.index.NumericDocValues;+import org.apache.lucene.index.SortedDocValues;+import org.apache.lucene.util.BytesRef;++public abstract class SimpleDVProducer implements Closeable {++ private final int maxDoc;++ protected SimpleDVProducer(int maxDoc) {+ // nocommit kinda messy?+ this.maxDoc = maxDoc;+ }++ public abstract NumericDocValues getDirectNumeric(FieldInfo field) throws IOException;++ /** Loads all values into RAM. */+ public NumericDocValues getNumeric(FieldInfo field) throws IOException {+ NumericDocValues source = getDirectNumeric(field);+ // nocommit more ram efficient?+ final long[] values = new long[maxDoc];+ for(int docID=0;docID<maxDoc;docID++) {+ values[docID] = source.get(docID);+ }+ return new NumericDocValues() {+ @Override+ public long get(int docID) {+ return values[docID];+ }+ };+ }++ public abstract BinaryDocValues getDirectBinary(FieldInfo field) throws IOException;++ /** Loads all values into RAM. */+ public BinaryDocValues getBinary(FieldInfo field) throws IOException {++ BinaryDocValues source = getDirectBinary(field);++ // nocommit more ram efficient+ final byte[][] values = new byte[maxDoc][];+ BytesRef scratch = new BytesRef();+ for(int docID=0;docID<maxDoc;docID++) {+ source.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;+ }+ };+ }++ public abstract SortedDocValues getDirectSorted(FieldInfo field) throws IOException;++ /** Loads all values into RAM. */+ public SortedDocValues getSorted(FieldInfo field) throws IOException {+ SortedDocValues source = getDirectSorted(field);+ final int valueCount = source.getValueCount();+ final byte[][] values = new byte[valueCount][];+ BytesRef scratch = new BytesRef();+ for(int ord=0;ord<valueCount;ord++) {+ source.lookupOrd(ord, scratch);+ values[ord] = new byte[scratch.length];+ System.arraycopy(scratch.bytes, scratch.offset, values[ord], 0, scratch.length);+ }++ final int[] ords = new int[maxDoc];+ for(int docID=0;docID<maxDoc;docID++) {+ ords[docID] = source.getOrd(docID);+ }++ return new SortedDocValues() {+ @Override+ public int getOrd(int docID) {+ return ords[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;+ }+ };+ }+}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41BinaryDocValuesConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41BinaryDocValuesConsumer.javaindex 8bd482c4442..3a411c08e2f 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41BinaryDocValuesConsumer.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41BinaryDocValuesConsumer.java@@ -1,17 +1,5 @@package org.apache.lucene.codecs.lucene41.values;-import java.io.IOException;--import org.apache.lucene.codecs.BinaryDocValuesConsumer;-import org.apache.lucene.codecs.CodecUtil;-import org.apache.lucene.index.FieldInfos;-import org.apache.lucene.store.IndexOutput;-import org.apache.lucene.util.BytesRef;-import org.apache.lucene.util.IOUtils;-import org.apache.lucene.util.packed.AppendingLongBuffer;-import org.apache.lucene.util.packed.AppendingLongBuffer.Iterator;-import org.apache.lucene.util.packed.PackedInts;-/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements. See the NOTICE file distributed with@@ -29,6 +17,18 @@ import org.apache.lucene.util.packed.PackedInts;* limitations under the License.*/+import java.io.IOException;++import org.apache.lucene.codecs.BinaryDocValuesConsumer;+import org.apache.lucene.codecs.CodecUtil;+import org.apache.lucene.index.FieldInfos;+import org.apache.lucene.store.IndexOutput;+import org.apache.lucene.util.BytesRef;+import org.apache.lucene.util.IOUtils;+import org.apache.lucene.util.packed.AppendingLongBuffer;+import org.apache.lucene.util.packed.AppendingLongBuffer.Iterator;+import org.apache.lucene.util.packed.PackedInts;+public class Lucene41BinaryDocValuesConsumer extends BinaryDocValuesConsumer {private final IndexOutput dataOut;diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41SimpleDocValuesFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41SimpleDocValuesFormat.javaindex a0e90efef1c..6be62455cf1 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41SimpleDocValuesFormat.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/values/Lucene41SimpleDocValuesFormat.java@@ -49,13 +49,11 @@ public class Lucene41SimpleDocValuesFormat extends SimpleDocValuesFormat {@Overridepublic SimpleDVProducer fieldsProducer(SegmentReadState state)throws IOException {- // nocommit fixme- //return new Lucene41PerDocProducer(state);- return null;+ return new Lucene41DocValuesReader(state);}//nocommit this is equivalent to sep - we should pack in CFS- private static final class Lucene41PerDocProducer extends PerDocProducerBase {+ private static final class Lucene41DocValuesReader extends SimpleDVProducer {private final TreeMap<String, DocValues> docValues;/**diff --git a/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.java b/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.javanew file mode 100644index 00000000000..f2bcc7eedff--- /dev/null+++ b/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.java@@ -0,0 +1,26 @@+package org.apache.lucene.index;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import org.apache.lucene.util.BytesRef;++// nocommit need marker interface?+public abstract class BinaryDocValues {+ // nocommit throws IOE or not?+ public abstract void get(int docID, BytesRef result);+}diff --git a/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java b/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.javanew file mode 100644index 00000000000..264afd5554e--- /dev/null+++ b/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java@@ -0,0 +1,24 @@+package org.apache.lucene.index;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++// nocommit need marker interface?+public abstract class NumericDocValues {+ // nocommit throws IOE or not?+ public abstract long get(int docID);+}diff --git a/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java b/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.javanew file mode 100644index 00000000000..3ac419b4430--- /dev/null+++ b/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java@@ -0,0 +1,32 @@+package org.apache.lucene.index;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import org.apache.lucene.util.BytesRef;++// nocommit need marker interface?+public abstract class SortedDocValues {+ // nocommit throws IOE or not?+ public abstract int getOrd(int docID);++ // nocommit throws IOE or not?+ public abstract void lookupOrd(int ord, BytesRef result);++ // nocommit throws IOE or not?+ public abstract int getValueCount();+}