Apache Solr open-source search software
start at ST producer
Michael McCandless843c436e174f
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.javaindex 674572b0121..838164cd140 100644--- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.java+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSimpleDocValuesFormat.java@@ -241,7 +241,7 @@ public class SimpleTextSimpleDocValuesFormat extends SimpleDocValuesFormat {String pattern;int maxLength;int minValue;- }+ };final IndexInput data;final BytesRef scratch = new BytesRef();@@ -307,10 +307,63 @@ public class SimpleTextSimpleDocValuesFormat extends SimpleDocValuesFormat {}}+ class SimpleTextDocValues extends DocValues {+ private final OneField field;++ public SimpleTextDocValues(OneField field) {+ this.field = field;+ }++ @Override+ public Source loadSource() throws IOException {+ // nocommit todo+ return null;+ }++ @Override+ public DocValues.Type getType() {+ return field.fieldInfo.getDocValuesType();+ }++ @Override+ public Source loadDirectSource() throws IOException {+ DocValues.Type dvType = field.fieldInfo.getDocValuesType();+ if (DocValues.isNumber(dvType)) {+ final IndexInput in = data.clone();+ final BytesRef scratch = new BytesRef();+ final DecimalFormat decoder = new DecimalFormat(field.pattern, new DecimalFormatSymbols(Locale.ROOT));+ final ParsePosition pos = new ParsePosition(0);+ return new Source(dvType) {+ @Override+ public long getInt(int docID) {+ try {+ in.seek(field.dataStartFilePointer + (1+field.pattern.length())*docID);+ SimpleTextUtil.readLine(in, scratch);+ return decoder.parse(scratch.utf8ToString(), pos).longValue();+ } catch (IOException ioe) {+ throw new RuntimeException(ioe);+ }+ }+ };+ } else if (DocValues.isBytes(dvType)) {+ // nocommit+ return null;+ } else if (DocValues.isSortedBytes(dvType)) {+ // nocommit+ return null;+ }+ // nocommit+ return null;+ }+ }+@Overridepublic DocValues docValues(String fieldName) {- // nocommit TODO- return null;+ OneField field = fields.get(fieldName);+ if (field == null) {+ return null;+ }+ return new SimpleTextDocValues(field);}@Overridediff --git a/lucene/core/src/java/org/apache/lucene/index/DocValues.java b/lucene/core/src/java/org/apache/lucene/index/DocValues.javaindex 7e73ec0c94e..52808df7c76 100644--- a/lucene/core/src/java/org/apache/lucene/index/DocValues.java+++ b/lucene/core/src/java/org/apache/lucene/index/DocValues.java@@ -511,6 +511,44 @@ public abstract class DocValues implements Closeable {}};}++ // nocommit nuke+ public static boolean isSortedBytes(Type type) {+ switch(type) {+ case BYTES_VAR_SORTED:+ case BYTES_FIXED_SORTED:+ case BYTES_VAR_DEREF:+ case BYTES_FIXED_DEREF:+ return true;+ default:+ return false;+ }+ }++ // nocommit nuke+ public static boolean isBytes(Type type) {+ switch(type) {+ case BYTES_VAR_STRAIGHT:+ case BYTES_FIXED_STRAIGHT:+ return true;+ default:+ return false;+ }+ }++ // nocommit nuke+ public static boolean isNumber(Type type) {+ switch(type) {+ case VAR_INTS:+ case FIXED_INTS_8:+ case FIXED_INTS_16:+ case FIXED_INTS_32:+ case FIXED_INTS_64:+ return true;+ default:+ return false;+ }+ }/*** <code>Type</code> specifies the {@link DocValues} type for a