fix test-framework compile

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1433673 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-01-15 21:38:33 +00:00
parent 63ace26be7
commit ef48cd20e7
2 changed files with 18 additions and 82 deletions

View File

@ -25,6 +25,7 @@ import java.util.Random;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.document.BinaryDocValuesField;
import org.apache.lucene.document.ByteDocValuesField;
import org.apache.lucene.document.DerefBytesDocValuesField;
import org.apache.lucene.document.Document;
@ -37,6 +38,7 @@ import org.apache.lucene.document.PackedLongDocValuesField;
import org.apache.lucene.document.ShortDocValuesField;
import org.apache.lucene.document.SortedBytesDocValuesField;
import org.apache.lucene.document.StraightBytesDocValuesField;
import org.apache.lucene.index.FieldInfo.DocValuesType;
import org.apache.lucene.index.IndexWriter; // javadoc
import org.apache.lucene.search.Query;
import org.apache.lucene.store.Directory;
@ -220,55 +222,23 @@ public class RandomIndexWriter implements Closeable {
private void randomPerDocFieldValues(Document doc) {
DocValues.Type[] values = DocValues.Type.values();
DocValues.Type type = values[r.nextInt(values.length)];
DocValuesType[] values = DocValuesType.values();
DocValuesType type = values[r.nextInt(values.length)];
String name = "random_" + type.name() + "" + docValuesFieldPrefix;
if (doc.getField(name) != null) {
return;
}
final Field f;
switch (type) {
case BYTES_FIXED_DEREF:
f = new DerefBytesDocValuesField(name, getFixedRandomBytes(), true);
case BINARY:
f = new BinaryDocValuesField(name, new BytesRef(_TestUtil.randomUnicodeString(r, 20)));
break;
case BYTES_VAR_DEREF:
f = new DerefBytesDocValuesField(name, new BytesRef(_TestUtil.randomUnicodeString(r, 20)), false);
case SORTED:
f = new SortedBytesDocValuesField(name, new BytesRef(_TestUtil.randomUnicodeString(r, 20)));
break;
case BYTES_FIXED_STRAIGHT:
f = new StraightBytesDocValuesField(name, getFixedRandomBytes(), true);
break;
case BYTES_VAR_STRAIGHT:
f = new StraightBytesDocValuesField(name, new BytesRef(_TestUtil.randomUnicodeString(r, 20)), false);
break;
case BYTES_FIXED_SORTED:
f = new SortedBytesDocValuesField(name, getFixedRandomBytes(), true);
break;
case BYTES_VAR_SORTED:
f = new SortedBytesDocValuesField(name, new BytesRef(_TestUtil.randomUnicodeString(r, 20)), false);
break;
case FLOAT_32:
f = new FloatDocValuesField(name, r.nextFloat());
break;
case FLOAT_64:
f = new DoubleDocValuesField(name, r.nextDouble());
break;
case VAR_INTS:
f = new PackedLongDocValuesField(name, r.nextLong());
break;
case FIXED_INTS_16:
// TODO: we should test negatives too?
f = new ShortDocValuesField(name, (short) r.nextInt(Short.MAX_VALUE));
break;
case FIXED_INTS_32:
f = new IntDocValuesField(name, r.nextInt());
break;
case FIXED_INTS_64:
case NUMERIC:
f = new LongDocValuesField(name, r.nextLong());
break;
case FIXED_INTS_8:
// TODO: we should test negatives too?
f = new ByteDocValuesField(name, (byte) r.nextInt(128));
break;
default:
throw new IllegalArgumentException("no such type: " + type);
}

View File

@ -46,18 +46,13 @@ import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.lucene41.Lucene41Codec;
import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat;
import org.apache.lucene.document.BinaryDocValuesField;
import org.apache.lucene.document.ByteDocValuesField;
import org.apache.lucene.document.DerefBytesDocValuesField;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.DoubleDocValuesField;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FloatDocValuesField;
import org.apache.lucene.document.IntDocValuesField;
import org.apache.lucene.document.LongDocValuesField;
import org.apache.lucene.document.PackedLongDocValuesField;
import org.apache.lucene.document.ShortDocValuesField;
import org.apache.lucene.document.SortedBytesDocValuesField;
import org.apache.lucene.document.StraightBytesDocValuesField;
import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.CheckIndex;
import org.apache.lucene.index.CheckIndex.Status.DocValuesStatus;
@ -66,9 +61,9 @@ import org.apache.lucene.index.CheckIndex.Status.StoredFieldStatus;
import org.apache.lucene.index.CheckIndex.Status.TermIndexStatus;
import org.apache.lucene.index.CheckIndex.Status.TermVectorStatus;
import org.apache.lucene.index.ConcurrentMergeScheduler;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.DocsAndPositionsEnum;
import org.apache.lucene.index.DocsEnum;
import org.apache.lucene.index.FieldInfo.DocValuesType;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.IndexReader;
@ -863,47 +858,18 @@ public class _TestUtil {
for(IndexableField f : doc1.getFields()) {
final Field field1 = (Field) f;
final Field field2;
final DocValues.Type dvType = field1.fieldType().docValueType();
final DocValuesType dvType = field1.fieldType().docValueType();
if (dvType != null) {
switch(dvType) {
case VAR_INTS:
field2 = new PackedLongDocValuesField(field1.name(), field1.numericValue().longValue());
break;
case FIXED_INTS_8:
field2 = new ByteDocValuesField(field1.name(), field1.numericValue().byteValue());
break;
case FIXED_INTS_16:
field2 = new ShortDocValuesField(field1.name(), field1.numericValue().shortValue());
break;
case FIXED_INTS_32:
field2 = new IntDocValuesField(field1.name(), field1.numericValue().intValue());
break;
case FIXED_INTS_64:
// nocommit: not quite right!
case NUMERIC:
field2 = new LongDocValuesField(field1.name(), field1.numericValue().longValue());
break;
case FLOAT_32:
field2 = new FloatDocValuesField(field1.name(), field1.numericValue().floatValue());
case BINARY:
field2 = new BinaryDocValuesField(field1.name(), field1.binaryValue());
break;
case FLOAT_64:
field2 = new DoubleDocValuesField(field1.name(), field1.numericValue().doubleValue());
break;
case BYTES_FIXED_STRAIGHT:
field2 = new StraightBytesDocValuesField(field1.name(), field1.binaryValue(), true);
break;
case BYTES_VAR_STRAIGHT:
field2 = new StraightBytesDocValuesField(field1.name(), field1.binaryValue(), false);
break;
case BYTES_FIXED_DEREF:
field2 = new DerefBytesDocValuesField(field1.name(), field1.binaryValue(), true);
break;
case BYTES_VAR_DEREF:
field2 = new DerefBytesDocValuesField(field1.name(), field1.binaryValue(), false);
break;
case BYTES_FIXED_SORTED:
field2 = new SortedBytesDocValuesField(field1.name(), field1.binaryValue(), true);
break;
case BYTES_VAR_SORTED:
field2 = new SortedBytesDocValuesField(field1.name(), field1.binaryValue(), false);
case SORTED:
field2 = new SortedBytesDocValuesField(field1.name(), field1.binaryValue());
break;
default:
throw new IllegalStateException("unknown Type: " + dvType);