You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2011/08/23 00:54:28 UTC
svn commit: r1160484 [1/2] - in /lucene/dev/branches/fieldtype_conflicted:
lucene/contrib/
lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/
lucene/contrib/misc/src/java/org/apache/lucene/document/
lucene/contrib/misc/src/test/...
Author: mikemccand
Date: Mon Aug 22 22:54:26 2011
New Revision: 1160484
URL: http://svn.apache.org/viewvc?rev=1160484&view=rev
Log:
LUCENE-2308: more merging/fixing
Modified:
lucene/dev/branches/fieldtype_conflicted/lucene/contrib/CHANGES.txt
lucene/dev/branches/fieldtype_conflicted/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java
lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/FieldSelectorVisitor.java
lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/LoadFirstFieldSelector.java
lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/SetBasedFieldSelector.java
lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/test/org/apache/lucene/index/TestContribFieldsReader.java
lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/test/org/apache/lucene/index/TestContribIndexReader.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/analysis/NumericTokenStream.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/BinaryField.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/CompressionTools.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/Document.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/Field.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/IndexDocValuesField.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/StringField.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocInverterPerField.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocumentStoredFieldVisitor.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/FieldsWriter.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/IndexableField.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/values/IntsImpl.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/values/PerDocFieldValues.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDocument.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexableField.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressNRT.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/search/TestDocBoost.java
lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/search/TestSort.java
lucene/dev/branches/fieldtype_conflicted/modules/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/java/org/apache/solr/schema/BinaryField.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/java/org/apache/solr/schema/LatLonType.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/java/org/apache/solr/schema/PointType.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/java/org/apache/solr/schema/TrieField.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/test/org/apache/solr/schema/PolyFieldTest.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/test/org/apache/solr/search/TestSort.java
lucene/dev/branches/fieldtype_conflicted/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/contrib/CHANGES.txt?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/contrib/CHANGES.txt (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/contrib/CHANGES.txt Mon Aug 22 22:54:26 2011
@@ -4,8 +4,6 @@ For more information on past and future
http://s.apache.org/luceneversions
======================= Trunk (not yet released) =======================
-<<<<<<<
-=======
Changes in Runtime Behavior
@@ -14,7 +12,6 @@ Changes in Runtime Behavior
ANALYZED fields). To ensure your offsets are correct you should
provide an analyzer that returns 1 from the offsetGap method.
(Mike McCandless)
->>>>>>>
Build
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java Mon Aug 22 22:54:26 2011
@@ -496,7 +496,7 @@ public class InstantiatedIndexWriter imp
if (field.stored()) {
fieldSetting.stored = true;
}
- if (field.binaryValue(null) != null) {
+ if (field.binaryValue() != null) {
fieldSetting.isBinary = true;
}
if (field.storeTermVectors()) {
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/FieldSelectorVisitor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/FieldSelectorVisitor.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/FieldSelectorVisitor.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/FieldSelectorVisitor.java Mon Aug 22 22:54:26 2011
@@ -215,6 +215,7 @@ public class FieldSelectorVisitor extend
private long pointer;
private final boolean cacheResult;
private final IndexInput in;
+ private boolean isBinary;
public LazyField(IndexInput in, String name, FieldType ft, int toRead, long pointer, boolean isBinary, boolean cacheResult) {
super(name, ft);
@@ -223,8 +224,6 @@ public class FieldSelectorVisitor extend
this.pointer = pointer;
this.isBinary = isBinary;
this.cacheResult = cacheResult;
- if (isBinary)
- binaryLength = toRead;
}
@Override
@@ -249,6 +248,7 @@ public class FieldSelectorVisitor extend
/** The value of the field as a Reader, or null. If null, the String value,
* binary value, or TokenStream value is used. Exactly one of stringValue(),
* readerValue(), getBinaryValue(), and tokenStreamValue() must be set. */
+ @Override
public Reader readerValue() {
return null;
}
@@ -256,6 +256,7 @@ public class FieldSelectorVisitor extend
/** The value of the field as a TokenStream, or null. If null, the Reader value,
* String value, or binary value is used. Exactly one of stringValue(),
* readerValue(), getBinaryValue(), and tokenStreamValue() must be set. */
+ @Override
public TokenStream tokenStreamValue() {
return null;
}
@@ -263,10 +264,11 @@ public class FieldSelectorVisitor extend
/** The value of the field as a String, or null. If null, the Reader value,
* binary value, or TokenStream value is used. Exactly one of stringValue(),
* readerValue(), getBinaryValue(), and tokenStreamValue() must be set. */
+ @Override
synchronized public String stringValue() {
- if (isBinary)
+ if (isBinary) {
return null;
- else {
+ } else {
if (fieldsData == null) {
String result = null;
IndexInput localFieldsStream = getFieldStream();
@@ -288,15 +290,12 @@ public class FieldSelectorVisitor extend
}
}
- synchronized private byte[] getBinaryValue(byte[] result) {
+ @Override
+ synchronized public BytesRef binaryValue() {
if (isBinary) {
if (fieldsData == null) {
// Allocate new buffer if result is null or too small
- final byte[] b;
- if (result == null || result.length < toRead)
- b = new byte[toRead];
- else
- b = result;
+ final byte[] b = new byte[toRead];
IndexInput localFieldsStream = getFieldStream();
@@ -309,24 +308,15 @@ public class FieldSelectorVisitor extend
throw new FieldReaderException(e);
}
- binaryOffset = 0;
- binaryLength = toRead;
+ final BytesRef result = new BytesRef(b);
+ result.length = toRead;
if (cacheResult == true){
- fieldsData = b;
+ fieldsData = result;
}
- return b;
+ return result;
} else {
- return (byte[]) fieldsData;
+ return (BytesRef) fieldsData;
}
- } else
- return null;
- }
-
- @Override
- public BytesRef binaryValue(BytesRef reuse) {
- final byte[] bytes = getBinaryValue(reuse != null ? reuse.bytes : null);
- if (bytes != null) {
- return new BytesRef(bytes, 0, bytes.length);
} else {
return null;
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/LoadFirstFieldSelector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/LoadFirstFieldSelector.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/LoadFirstFieldSelector.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/LoadFirstFieldSelector.java Mon Aug 22 22:54:26 2011
@@ -26,4 +26,4 @@ public class LoadFirstFieldSelector impl
public FieldSelectorResult accept(String fieldName) {
return FieldSelectorResult.LOAD_AND_BREAK;
}
-}
\ No newline at end of file
+}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/SetBasedFieldSelector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/SetBasedFieldSelector.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/SetBasedFieldSelector.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/java/org/apache/lucene/document/SetBasedFieldSelector.java Mon Aug 22 22:54:26 2011
@@ -59,4 +59,4 @@ public class SetBasedFieldSelector imple
}
return result;
}
-}
\ No newline at end of file
+}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/test/org/apache/lucene/index/TestContribFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/test/org/apache/lucene/index/TestContribFieldsReader.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/test/org/apache/lucene/index/TestContribFieldsReader.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/test/org/apache/lucene/index/TestContribFieldsReader.java Mon Aug 22 22:54:26 2011
@@ -111,10 +111,10 @@ public class TestContribFieldsReader ext
assertTrue("field is null and it shouldn't be", field != null);
assertTrue("stringValue isn't null for lazy binary field", field.stringValue() == null);
- byte [] bytes = field.binaryValue(null).bytes;
+ byte [] bytes = field.binaryValue().bytes;
assertTrue("bytes is null and it shouldn't be", bytes != null);
assertTrue("", DocHelper.LAZY_FIELD_BINARY_BYTES.length == bytes.length);
- assertTrue("calling binaryValue() twice should give same reference", field.binaryValue(null).bytes == field.binaryValue(null).bytes);
+ assertTrue("calling binaryValue() twice should give same reference", field.binaryValue().bytes == field.binaryValue().bytes);
for (int i = 0; i < bytes.length; i++) {
assertTrue("byte[" + i + "] is mismatched", bytes[i] == DocHelper.LAZY_FIELD_BINARY_BYTES[i]);
@@ -179,9 +179,9 @@ public class TestContribFieldsReader ext
field = doc.getField(DocHelper.LAZY_FIELD_BINARY_KEY);
assertTrue("field is null and it shouldn't be", field != null);
assertTrue("stringValue isn't null for lazy binary field", field.stringValue() == null);
- assertTrue("calling binaryValue() twice should give different references", field.binaryValue(null).bytes != field.binaryValue(null).bytes);
+ assertTrue("calling binaryValue() twice should give different references", field.binaryValue().bytes != field.binaryValue().bytes);
- byte [] bytes = field.binaryValue(null).bytes;
+ byte [] bytes = field.binaryValue().bytes;
assertTrue("bytes is null and it shouldn't be", bytes != null);
assertTrue("", DocHelper.LAZY_FIELD_BINARY_BYTES.length == bytes.length);
for (int i = 0; i < bytes.length; i++) {
@@ -300,12 +300,12 @@ public class TestContribFieldsReader ext
IndexableField f1 = doc.getField(DocHelper.TEXT_FIELD_1_KEY);
IndexableField f3 = doc.getField(DocHelper.TEXT_FIELD_3_KEY);
IndexableField fb = doc.getField(DocHelper.LAZY_FIELD_BINARY_KEY);
- assertTrue(f1.binaryValue(null)!=null);
- assertTrue(f3.binaryValue(null)==null);
- assertTrue(fb.binaryValue(null)!=null);
- assertSizeEquals(2*DocHelper.FIELD_1_TEXT.length(), f1.binaryValue(null).bytes);
+ assertTrue(f1.binaryValue()!=null);
+ assertTrue(f3.binaryValue()==null);
+ assertTrue(fb.binaryValue()!=null);
+ assertSizeEquals(2*DocHelper.FIELD_1_TEXT.length(), f1.binaryValue().bytes);
assertEquals(DocHelper.FIELD_3_TEXT, f3.stringValue());
- assertSizeEquals(DocHelper.LAZY_FIELD_BINARY_BYTES.length, fb.binaryValue(null).bytes);
+ assertSizeEquals(DocHelper.LAZY_FIELD_BINARY_BYTES.length, fb.binaryValue().bytes);
reader.close();
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/test/org/apache/lucene/index/TestContribIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/test/org/apache/lucene/index/TestContribIndexReader.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/test/org/apache/lucene/index/TestContribIndexReader.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/contrib/misc/src/test/org/apache/lucene/index/TestContribIndexReader.java Mon Aug 22 22:54:26 2011
@@ -143,7 +143,7 @@ public class TestContribIndexReader exte
assertEquals(1, fields.length);
Field b1 = (Field) fields[0];
assertTrue(b1.isBinary());
- BytesRef bytesRef = b1.binaryValue(null);
+ BytesRef bytesRef = b1.binaryValue();
assertEquals(bin.length, bytesRef.length);
for (int i = 0; i < bin.length; i++) {
assertEquals(bin[i], bytesRef.bytes[i + bytesRef.offset]);
@@ -156,8 +156,8 @@ public class TestContribIndexReader exte
assertNotNull(fields);
assertEquals(1, fields.length);
IndexableField fb1 = fields[0];
- assertTrue(fb1.binaryValue(null)!=null);
- bytesRef = fb1.binaryValue(null);
+ assertTrue(fb1.binaryValue()!=null);
+ bytesRef = fb1.binaryValue();
assertEquals(bin.length, bytesRef.bytes.length);
assertEquals(bin.length, bytesRef.length);
for (int i = 0; i < bin.length; i++) {
@@ -177,7 +177,7 @@ public class TestContribIndexReader exte
assertEquals(1, fields.length);
b1 = (Field) fields[0];
assertTrue(b1.isBinary());
- bytesRef = b1.binaryValue(null);
+ bytesRef = b1.binaryValue();
assertEquals(bin.length, bytesRef.length);
for (int i = 0; i < bin.length; i++) {
assertEquals(bin[i], bytesRef.bytes[i + bytesRef.offset]);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/analysis/NumericTokenStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/analysis/NumericTokenStream.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/analysis/NumericTokenStream.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/analysis/NumericTokenStream.java Mon Aug 22 22:54:26 2011
@@ -22,7 +22,7 @@ import org.apache.lucene.util.AttributeI
import org.apache.lucene.util.AttributeReflector;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.NumericUtils;
-import org.apache.lucene.document.NumericField;
+import org.apache.lucene.document.NumericField; // for javadocs
import org.apache.lucene.search.NumericRangeQuery; // for javadocs
import org.apache.lucene.search.NumericRangeFilter; // for javadocs
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/BinaryField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/BinaryField.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/BinaryField.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/BinaryField.java Mon Aug 22 22:54:26 2011
@@ -1,5 +1,7 @@
package org.apache.lucene.document;
+import org.apache.lucene.util.BytesRef;
+
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -27,17 +29,18 @@ public final class BinaryField extends F
public BinaryField(String name, byte[] value) {
super(name, BinaryField.TYPE_STORED, value);
- this.isBinary = true;
}
public BinaryField(String name, byte[] value, int offset, int length) {
super(name, BinaryField.TYPE_STORED, value, offset, length);
- this.isBinary = true;
+ }
+
+ public BinaryField(String name, BytesRef bytes) {
+ super(name, BinaryField.TYPE_STORED, bytes.bytes, bytes.offset, bytes.length);
}
public BinaryField(String name, FieldType custom, byte[] value) {
- super(name, custom, value);
- this.isBinary = true;
+ super(name, custom, value);
}
public boolean isNumeric() {
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/CompressionTools.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/CompressionTools.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/CompressionTools.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/CompressionTools.java Mon Aug 22 22:54:26 2011
@@ -92,16 +92,24 @@ public class CompressionTools {
return compress(result.bytes, 0, result.length, compressionLevel);
}
+ public static byte[] decompress(BytesRef bytes) throws DataFormatException {
+ return decompress(bytes.bytes, bytes.offset, bytes.length);
+ }
+
+ public static byte[] decompress(byte[] value) throws DataFormatException {
+ return decompress(value, 0, value.length);
+ }
+
/** Decompress the byte array previously returned by
* compress */
- public static byte[] decompress(byte[] value) throws DataFormatException {
+ public static byte[] decompress(byte[] value, int offset, int length) throws DataFormatException {
// Create an expandable byte array to hold the decompressed data
- ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
Inflater decompressor = new Inflater();
try {
- decompressor.setInput(value);
+ decompressor.setInput(value, offset, length);
// Decompress the data
final byte[] buf = new byte[1024];
@@ -119,9 +127,17 @@ public class CompressionTools {
/** Decompress the byte array previously returned by
* compressString back into a String */
public static String decompressString(byte[] value) throws DataFormatException {
- final byte[] bytes = decompress(value);
+ return decompressString(value, 0, value.length);
+ }
+
+ public static String decompressString(byte[] value, int offset, int length) throws DataFormatException {
+ final byte[] bytes = decompress(value, offset, length);
CharsRef result = new CharsRef(bytes.length);
UnicodeUtil.UTF8toUTF16(bytes, 0, bytes.length, result);
return new String(result.chars, 0, result.length);
}
+
+ public static String decompressString(BytesRef bytes) throws DataFormatException {
+ return decompressString(bytes.bytes, bytes.offset, bytes.length);
+ }
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/Document.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/Document.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/Document.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/Document.java Mon Aug 22 22:54:26 2011
@@ -23,6 +23,7 @@ import org.apache.lucene.index.IndexRead
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.IndexSearcher; // for javadoc
import org.apache.lucene.search.ScoreDoc; // for javadoc
+import org.apache.lucene.util.BytesRef;
/** Documents are the unit of indexing and search.
*
@@ -39,25 +40,28 @@ import org.apache.lucene.search.ScoreDoc
public final class Document implements Iterable<IndexableField> {
- List<IndexableField> fields = new ArrayList<IndexableField>();
+ private final List<IndexableField> fields = new ArrayList<IndexableField>();
/** Constructs a new document with no fields. */
public Document() {}
- // @Override not until Java 1.6
+ @Override
public Iterator<IndexableField> iterator() {
return new Iterator<IndexableField>() {
private int fieldUpto = 0;
+ @Override
public boolean hasNext() {
return fieldUpto < fields.size();
}
+ @Override
public void remove() {
throw new UnsupportedOperationException();
}
+ @Override
public IndexableField next() {
return fields.get(fieldUpto++);
}
@@ -118,7 +122,6 @@ public final class Document implements I
}
}
- private final static byte[][] NO_BYTES = new byte[0][];
/**
* Returns an array of byte arrays for of the fields that have the name specified
@@ -129,17 +132,18 @@ public final class Document implements I
* @param name the name of the field
* @return a <code>byte[][]</code> of binary field values
*/
- public final byte[][] getBinaryValues(String name) {
- List<byte[]> result = new ArrayList<byte[]>();
+ public final BytesRef[] getBinaryValues(String name) {
+ final List<BytesRef> result = new ArrayList<BytesRef>();
for (IndexableField field : fields) {
- if (field.name().equals(name) && ((Field) field).isBinary())
- result.add(field.binaryValue(null).bytes);
+ if (field.name().equals(name)) {
+ final BytesRef bytes = field.binaryValue();
+ if (bytes != null) {
+ result.add(bytes);
+ }
+ }
}
- if (result.size() == 0)
- return NO_BYTES;
-
- return result.toArray(new byte[result.size()][]);
+ return result.toArray(new BytesRef[result.size()]);
}
/**
@@ -151,24 +155,39 @@ public final class Document implements I
* @param name the name of the field.
* @return a <code>byte[]</code> containing the binary field value or <code>null</code>
*/
- public final byte[] getBinaryValue(String name) {
+ public final BytesRef getBinaryValue(String name) {
for (IndexableField field : fields) {
- if (field.name().equals(name) && ((Field) field).isBinary())
- return field.binaryValue(null).bytes;
+ if (field.name().equals(name)) {
+ final BytesRef bytes = field.binaryValue();
+ if (bytes != null) {
+ return bytes;
+ }
+ }
}
return null;
}
+ /** Returns a field with the given name if any exist in this document, or
+ * null. If multiple fields exists with this name, this method returns the
+ * first value added.
+ */
public final IndexableField getField(String name) {
for (IndexableField field : fields) {
- if (field.name().equals(name))
+ if (field.name().equals(name)) {
return field;
+ }
}
return null;
}
- private final static IndexableField[] NO_FIELDS = new IndexableField[0];
-
+ /**
+ * Returns an array of {@link IndexablField}s with the given name.
+ * This method returns an empty array when there are no
+ * matching fields. It never returns null.
+ *
+ * @param name the name of the field
+ * @return a <code>Fieldable[]</code> array
+ */
public IndexableField[] getFields(String name) {
List<IndexableField> result = new ArrayList<IndexableField>();
for (IndexableField field : fields) {
@@ -177,24 +196,31 @@ public final class Document implements I
}
}
- if (result.size() == 0)
- return NO_FIELDS;
-
return result.toArray(new IndexableField[result.size()]);
}
- public Integer size() {
- return fields.size();
- }
-
+ /** Returns a List of all the fields in a document.
+ * <p>Note that fields which are <i>not</i> stored are
+ * <i>not</i> available in documents retrieved from the
+ * index, e.g. {@link IndexSearcher#doc(int)} or {@link
+ * IndexReader#document(int)}.
+ */
public final List<IndexableField> getFields() {
return fields;
}
+ /** Returns the string value of the field with the given name if any exist in
+ * this document, or null. If multiple fields exist with this name, this
+ * method returns the first value added. If only binary fields with this name
+ * exist, returns null.
+ * For {@link NumericField} it returns the string value of the number. If you want
+ * the actual {@code NumericField} instance back, use {@link #getFieldable}.
+ */
public final String get(String name) {
- for (IndexableField field : fields) {
- if (field.name().equals(name) && (field.binaryValue(null) == null))
+ for (IndexableField field : fields) {
+ if (field.name().equals(name) && field.stringValue() != null) {
return field.stringValue();
+ }
}
return null;
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/Field.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/Field.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/Field.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/Field.java Mon Aug 22 22:54:26 2011
@@ -21,13 +21,10 @@ import java.io.Reader;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.index.FieldInfo.IndexOptions;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.document.NumericField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.values.PerDocFieldValues;
import org.apache.lucene.index.values.ValueType;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.StringHelper;
/**
* A field is a section of a Document. Each field has two parts, a name and a
@@ -42,13 +39,10 @@ public class Field implements IndexableF
protected FieldType type;
protected String name = "body";
// the data object for all different kind of field values
- protected Object fieldsData = null;
+ protected Object fieldsData;
// pre-analyzed tokenStream for indexed fields
protected TokenStream tokenStream;
- protected boolean isBinary = false;
// length/offset for all primitive types
- protected int binaryLength;
- protected int binaryOffset;
protected PerDocFieldValues docValues;
protected float boost = 1.0f;
@@ -59,23 +53,27 @@ public class Field implements IndexableF
}
public Field(String name, FieldType type, Reader reader) {
- if (name == null)
+ if (name == null) {
throw new NullPointerException("name cannot be null");
- if (reader == null)
+ }
+ if (reader == null) {
throw new NullPointerException("reader cannot be null");
+ }
- this.name = name; // field names are interned
+ this.name = name;
this.fieldsData = reader;
this.type = type;
}
public Field(String name, FieldType type, TokenStream tokenStream) {
- if (name == null)
+ if (name == null) {
throw new NullPointerException("name cannot be null");
- if (tokenStream == null)
+ }
+ if (tokenStream == null) {
throw new NullPointerException("tokenStream cannot be null");
+ }
- this.name = name; // field names are interned
+ this.name = name;
this.fieldsData = null;
this.tokenStream = tokenStream;
this.type = type;
@@ -84,21 +82,20 @@ public class Field implements IndexableF
public Field(String name, FieldType type, byte[] value) {
this(name, type, value, 0, value.length);
}
-
+
public Field(String name, FieldType type, byte[] value, int offset, int length) {
- this.isBinary = true;
- this.fieldsData = value;
+ this.fieldsData = new BytesRef(value, offset, length);
this.type = type;
- this.binaryOffset = offset;
- this.binaryLength = length;
this.name = name;
}
-
- public Field(String name, FieldType type, String value) {
- this(name, true, type, value);
+
+ public Field(String name, FieldType type, BytesRef bytes) {
+ this.fieldsData = bytes;
+ this.type = type;
+ this.name = name;
}
- public Field(String name, boolean internName, FieldType type, String value) {
+ public Field(String name, FieldType type, String value) {
if (name == null) {
throw new IllegalArgumentException("name cannot be null");
}
@@ -162,7 +159,7 @@ public class Field implements IndexableF
* </p>
*/
public void setValue(String value) {
- if (isBinary) {
+ if (isBinary()) {
throw new IllegalArgumentException(
"cannot set a String value on a binary field");
}
@@ -174,7 +171,7 @@ public class Field implements IndexableF
* href="#setValue(java.lang.String)">setValue(String)</a>.
*/
public void setValue(Reader value) {
- if (isBinary) {
+ if (isBinary()) {
throw new IllegalArgumentException(
"cannot set a Reader value on a binary field");
}
@@ -190,19 +187,18 @@ public class Field implements IndexableF
* href="#setValue(java.lang.String)">setValue(String)</a>.
*/
public void setValue(byte[] value) {
- if (!isBinary) {
+ if (!isBinary()) {
throw new IllegalArgumentException(
"cannot set a byte[] value on a non-binary field");
}
- fieldsData = value;
- binaryLength = value.length;
- binaryOffset = 0;
+ fieldsData = new BytesRef(value);
}
/**
* Expert: change the value of this field. See <a
* href="#setValue(java.lang.String)">setValue(String)</a>.
*/
+ /*
public void setValue(byte[] value, int offset, int length) {
if (!isBinary) {
throw new IllegalArgumentException(
@@ -212,6 +208,7 @@ public class Field implements IndexableF
binaryLength = length;
binaryOffset = offset;
}
+ */
/**
* Expert: sets the token stream to be used for indexing and causes
@@ -264,61 +261,20 @@ public class Field implements IndexableF
return null;
}
- private byte[] getBinaryValue(byte[] result /* unused */) {
- if (isBinary || fieldsData instanceof byte[]) return (byte[]) fieldsData;
- else return null;
- }
-
- protected byte[] getBinaryValue() {
- return getBinaryValue(null);
- }
-
- public BytesRef binaryValue(BytesRef reuse) {
- final byte[] bytes = getBinaryValue();
- if (bytes != null) {
- if (reuse == null) {
- return new BytesRef(bytes, getBinaryOffset(), getBinaryLength());
- } else {
- reuse.bytes = bytes;
- reuse.offset = getBinaryOffset();
- reuse.length = getBinaryLength();
- return reuse;
- }
- } else {
+ public BytesRef binaryValue() {
+ if (!isBinary()) {
return null;
+ } else {
+ return (BytesRef) fieldsData;
}
}
- /**
- * Returns length of byte[] segment that is used as value, if Field is not
- * binary returned value is undefined
- *
- * @return length of byte[] segment that represents this Field value
- */
- protected int getBinaryLength() {
- if (isBinary) {
- return binaryLength;
- } else if (fieldsData instanceof byte[]) return ((byte[]) fieldsData).length;
- else return 0;
- }
-
- /**
- * Returns offset into byte[] segment that is used as value, if Field is not
- * binary returned value is undefined
- *
- * @return index of the first character in byte[] segment that represents this
- * Field value
- */
- public int getBinaryOffset() {
- return binaryOffset;
- }
+ /** methods from inner FieldType */
public boolean isBinary() {
- return isBinary;
+ return fieldsData instanceof BytesRef;
}
- /** methods from inner FieldType */
-
public boolean stored() {
return type.stored();
}
@@ -353,7 +309,7 @@ public class Field implements IndexableF
/** Prints a Field for human consumption. */
@Override
- public final String toString() {
+ public String toString() {
StringBuilder result = new StringBuilder();
result.append(type.toString());
result.append('<');
@@ -368,24 +324,22 @@ public class Field implements IndexableF
return result.toString();
}
- public PerDocFieldValues docValues() {
- return docValues;
- }
-
public void setDocValues(PerDocFieldValues docValues) {
this.docValues = docValues;
}
-
- public boolean hasDocValues() {
- return docValues != null && docValues.type() != null;
+
+ @Override
+ public PerDocFieldValues docValues() {
+ return null;
}
+ @Override
public ValueType docValuesType() {
- return docValues == null? null : docValues.type();
+ return null;
}
+ /** Returns FieldType for this field. */
public FieldType getFieldType() {
- // get a copy
- return new FieldType(type);
+ return type;
}
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/IndexDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/IndexDocValuesField.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/IndexDocValuesField.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/IndexDocValuesField.java Mon Aug 22 22:54:26 2011
@@ -70,6 +70,7 @@ import org.apache.lucene.util.BytesRef;
* </pre>
*
* */
+// TODO: maybe rename to DocValuesField?
public class IndexDocValuesField extends Field implements PerDocFieldValues {
protected BytesRef bytes;
@@ -82,21 +83,27 @@ public class IndexDocValuesField extends
* Creates a new {@link IndexDocValuesField} with the given name.
*/
public IndexDocValuesField(String name) {
- super(name, new FieldType());
- setDocValues(this);
+ this(name, new FieldType());
}
- /**
- * Creates a {@link IndexDocValuesField} prototype
- */
- IndexDocValuesField() {
- this("");
+ public IndexDocValuesField(String name, FieldType type) {
+ this(name, type, null);
+ }
+
+ public IndexDocValuesField(String name, FieldType type, String value) {
+ super(name, type);
+ fieldsData = value;
+ }
+
+ @Override
+ public PerDocFieldValues docValues() {
+ return this;
}
/**
* Sets the given <code>long</code> value and sets the field's {@link ValueType} to
* {@link ValueType#VAR_INTS} unless already set. If you want to change the
- * default type use {@link #setType(ValueType)}.
+ * default type use {@link #setDocValuesType(ValueType)}.
*/
public void setInt(long value) {
setInt(value, false);
@@ -121,7 +128,7 @@ public class IndexDocValuesField extends
/**
* Sets the given <code>int</code> value and sets the field's {@link ValueType} to
* {@link ValueType#VAR_INTS} unless already set. If you want to change the
- * default type use {@link #setType(ValueType)}.
+ * default type use {@link #setDocValuesType(ValueType)}.
*/
public void setInt(int value) {
setInt(value, false);
@@ -146,7 +153,7 @@ public class IndexDocValuesField extends
/**
* Sets the given <code>short</code> value and sets the field's {@link ValueType} to
* {@link ValueType#VAR_INTS} unless already set. If you want to change the
- * default type use {@link #setType(ValueType)}.
+ * default type use {@link #setDocValuesType(ValueType)}.
*/
public void setInt(short value) {
setInt(value, false);
@@ -171,11 +178,12 @@ public class IndexDocValuesField extends
/**
* Sets the given <code>byte</code> value and sets the field's {@link ValueType} to
* {@link ValueType#VAR_INTS} unless already set. If you want to change the
- * default type use {@link #setType(ValueType)}.
+ * default type use {@link #setDocValuesType(ValueType)}.
*/
public void setInt(byte value) {
setInt(value, false);
}
+
/**
* Sets the given <code>byte</code> value as a 8 bit signed integer.
*
@@ -195,7 +203,7 @@ public class IndexDocValuesField extends
/**
* Sets the given <code>float</code> value and sets the field's {@link ValueType}
* to {@link ValueType#FLOAT_32} unless already set. If you want to
- * change the type use {@link #setType(ValueType)}.
+ * change the type use {@link #setDocValuesType(ValueType)}.
*/
public void setFloat(float value) {
if (type == null) {
@@ -207,7 +215,7 @@ public class IndexDocValuesField extends
/**
* Sets the given <code>double</code> value and sets the field's {@link ValueType}
* to {@link ValueType#FLOAT_64} unless already set. If you want to
- * change the default type use {@link #setType(ValueType)}.
+ * change the default type use {@link #setDocValuesType(ValueType)}.
*/
public void setFloat(double value) {
if (type == null) {
@@ -238,7 +246,7 @@ public class IndexDocValuesField extends
if (value == null) {
throw new IllegalArgumentException("value must not be null");
}
- setType(type);
+ setDocValuesType(type);
if (bytes == null) {
bytes = new BytesRef(value);
} else {
@@ -286,7 +294,7 @@ public class IndexDocValuesField extends
/**
* Sets the {@link ValueType} for this field.
*/
- public void setType(ValueType type) {
+ public void setDocValuesType(ValueType type) {
if (type == null) {
throw new IllegalArgumentException("Type must not be null");
}
@@ -294,13 +302,6 @@ public class IndexDocValuesField extends
}
/**
- * Returns the field's {@link ValueType}
- */
- public ValueType type() {
- return type;
- }
-
- /**
* Returns always <code>null</code>
*/
public Reader readerValue() {
@@ -310,36 +311,54 @@ public class IndexDocValuesField extends
/**
* Returns always <code>null</code>
*/
- public String stringValue() {
+ public TokenStream tokenStreamValue() {
return null;
}
- /**
- * Returns always <code>null</code>
- */
- public TokenStream tokenStreamValue() {
- return null;
+ @Override
+ public ValueType docValuesType() {
+ return type;
}
- /**
- * Sets this {@link IndexDocValuesField} to the given {@link Field} and
- * returns the given field. Any modifications to this instance will be visible
- * to the given field.
- */
- public <T extends Field> T set(T field) {
- field.setDocValues(this);
- return field;
+ @Override
+ public String toString() {
+ final String value;
+ switch (type) {
+ case BYTES_FIXED_DEREF:
+ case BYTES_FIXED_SORTED:
+ case BYTES_FIXED_STRAIGHT:
+ case BYTES_VAR_DEREF:
+ case BYTES_VAR_SORTED:
+ case BYTES_VAR_STRAIGHT:
+ value = "bytes:bytes.utf8ToString();";
+ break;
+ case VAR_INTS:
+ value = "int:" + longValue;
+ break;
+ case FLOAT_32:
+ value = "float32:" + doubleValue;
+ break;
+ case FLOAT_64:
+ value = "float64:" + doubleValue;
+ break;
+ default:
+ throw new IllegalArgumentException("unknown type: " + type);
+ }
+ return "<" + name() + ": IndexDocValuesField " + value + ">";
}
/**
- * Sets a new {@link PerDocFieldValues} instance on the given field with the
- * given type and returns it.
- *
+ * Returns an IndexDocValuesField holding the value from
+ * the provided string field, as the specified type. The
+ * incoming field must have a string value. The name, {@link
+ * FieldType} and string value are carried over from the
+ * incoming Field.
*/
- public static <T extends Field> T set(T field, ValueType type) {
- if (field instanceof IndexDocValuesField)
- return field;
- final IndexDocValuesField valField = new IndexDocValuesField();
+ public static IndexDocValuesField build(Field field, ValueType type) {
+ if (field instanceof IndexDocValuesField) {
+ return (IndexDocValuesField) field;
+ }
+ final IndexDocValuesField valField = new IndexDocValuesField(field.name(), field.getFieldType(), field.stringValue());
switch (type) {
case BYTES_FIXED_DEREF:
case BYTES_FIXED_SORTED:
@@ -347,9 +366,7 @@ public class IndexDocValuesField extends
case BYTES_VAR_DEREF:
case BYTES_VAR_SORTED:
case BYTES_VAR_STRAIGHT:
- BytesRef ref = field.isBinary() ? new BytesRef(field.getBinaryValue(),
- field.getBinaryOffset(), field.getBinaryLength()) : new BytesRef(
- field.stringValue());
+ BytesRef ref = field.isBinary() ? field.binaryValue() : new BytesRef(field.stringValue());
valField.setBytes(ref, type);
break;
case VAR_INTS:
@@ -364,7 +381,6 @@ public class IndexDocValuesField extends
default:
throw new IllegalArgumentException("unknown type: " + type);
}
- return valField.set(field);
+ return valField;
}
-
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/StringField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/StringField.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/StringField.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/document/StringField.java Mon Aug 22 22:54:26 2011
@@ -36,12 +36,8 @@ public final class StringField extends F
TYPE_STORED.freeze();
}
- public StringField(String name, boolean internName, String value) {
- super(name, StringField.TYPE_UNSTORED, value);
- }
-
public StringField(String name, String value) {
- this(name, true, value);
+ super(name, TYPE_UNSTORED, value);
}
@Override
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java Mon Aug 22 22:54:26 2011
@@ -24,12 +24,12 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.index.DocumentsWriterPerThread.DocState;
import org.apache.lucene.index.codecs.Codec;
-import org.apache.lucene.index.codecs.PerDocConsumer;
import org.apache.lucene.index.codecs.DocValuesConsumer;
+import org.apache.lucene.index.codecs.PerDocConsumer;
+import org.apache.lucene.index.values.PerDocFieldValues;
+import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.IOUtils;
@@ -262,9 +262,9 @@ final class DocFieldProcessor extends Do
if (field.stored()) {
fieldsWriter.addField(field, fp.fieldInfo);
}
- if (field.hasDocValues()) {
- final DocValuesConsumer docValuesConsumer = docValuesConsumer(docState, fp.fieldInfo);
- docValuesConsumer.add(docState.docID, field.docValues());
+ final PerDocFieldValues docValues = field.docValues();
+ if (docValues != null) {
+ docValuesConsumer(docState, fp.fieldInfo).add(docState.docID, docValues);
}
}
@@ -332,5 +332,4 @@ final class DocFieldProcessor extends Do
docValues.put(fieldInfo.name, docValuesConsumer);
return docValuesConsumer;
}
-
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocInverterPerField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocInverterPerField.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocInverterPerField.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocInverterPerField.java Mon Aug 22 22:54:26 2011
@@ -84,7 +84,8 @@ final class DocInverterPerField extends
// a TokenStream, even for multi-valued fields
if (!field.tokenized()) { // un-tokenized field
- String stringValue = field.stringValue();
+ final String stringValue = field.stringValue();
+ assert stringValue != null;
final int valueLength = stringValue.length();
parent.singleToken.reinit(stringValue, 0, valueLength);
fieldState.attributeSource = parent.singleToken;
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocumentStoredFieldVisitor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocumentStoredFieldVisitor.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocumentStoredFieldVisitor.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/DocumentStoredFieldVisitor.java Mon Aug 22 22:54:26 2011
@@ -84,7 +84,6 @@ public class DocumentStoredFieldVisitor
ft.setOmitNorms(fieldInfo.omitNorms);
ft.setIndexOptions(fieldInfo.indexOptions);
doc.add(new Field(fieldInfo.name,
- false,
ft,
new String(b, "UTF-8")));
} else {
@@ -140,4 +139,4 @@ public class DocumentStoredFieldVisitor
public Document getDocument() {
return doc;
}
-}
\ No newline at end of file
+}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/FieldsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/FieldsWriter.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/FieldsWriter.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/FieldsWriter.java Mon Aug 22 22:54:26 2011
@@ -26,7 +26,7 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
final class FieldsWriter {
- // NOTE: bit 0 is free here!
+ // NOTE: bit 0 is free here! You can steal it!
static final int FIELD_IS_BINARY = 1 << 1;
// the old bit 1 << 2 was compressed, is now left out
@@ -160,7 +160,7 @@ final class FieldsWriter {
string = null;
bytes = null;
} else {
- bytes = field.binaryValue(null);
+ bytes = field.binaryValue();
if (bytes != null) {
bits |= FIELD_IS_BINARY;
string = null;
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/IndexableField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/IndexableField.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/IndexableField.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/IndexableField.java Mon Aug 22 22:54:26 2011
@@ -28,6 +28,8 @@ import org.apache.lucene.util.BytesRef;
// TODO: how to handle versioning here...?
+// TODO: we need to break out separate StoredField...
+
/** Represents a single field for indexing. IndexWriter
* consumes Iterable<IndexableField> as a document.
*
@@ -37,38 +39,66 @@ public interface IndexableField {
// TODO: add attrs to this API?
+ /* Field name */
public String name();
// NOTE: if doc/field impl has the notion of "doc level boost"
// it must be multiplied in w/ this field's boost
+
+ /** Field boost (you must pre-multiply in any doc boost). */
public float boost();
+ /* True if the field's value should be stored */
public boolean stored();
- public BytesRef binaryValue(BytesRef reuse);
+ /* Non-null if this field has a binary value */
+ public BytesRef binaryValue();
+
+ /* Non-null if this field has a string value */
public String stringValue();
+
+ /* Non-null if this field has a Reader value */
public Reader readerValue();
+ /* Non-null if this field has a pre-tokenized ({@link TokenStream}) value */
public TokenStream tokenStreamValue();
// Numeric field:
+ /* True if this field is numeric */
public boolean numeric();
+
+ /* Numeric {@link NumericField.DataType}; only used if
+ * the field is numeric */
public NumericField.DataType numericDataType();
+
+ /* Numeric value; only used if the field is numeric */
public Number numericValue();
- // If this returns true then we index this field:
+ /* True if this field should be indexed (inverted) */
public boolean indexed();
+ /* True if this field's value should be analyzed */
public boolean tokenized();
+
+ /* True if norms should not be indexed */
public boolean omitNorms();
+
+ /* {@link IndexOptions}, describing what should be
+ * recorded into the inverted index */
public IndexOptions indexOptions();
+ /* True if term vectors should be indexed */
public boolean storeTermVectors();
+
+ /* True if term vector offsets should be indexed */
public boolean storeTermVectorOffsets();
+
+ /* True if term vector positions should be indexed */
public boolean storeTermVectorPositions();
- // doc values
- public boolean hasDocValues();
+ /* Non-null if doc values should be indexed */
public PerDocFieldValues docValues();
+
+ /* DocValues type; only used if docValues is non-null */
public ValueType docValuesType();
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java Mon Aug 22 22:54:26 2011
@@ -69,8 +69,7 @@ public class PersistentSnapshotDeletionP
// index is allowed to have exactly one document or 0.
if (numDocs == 1) {
Document doc = r.document(r.maxDoc() - 1);
- Field sid = (Field) doc.getField(SNAPSHOTS_ID);
- if (sid == null) {
+ if (doc.getField(SNAPSHOTS_ID) == null) {
throw new IllegalStateException("directory is not a valid snapshots store!");
}
doc.removeField(SNAPSHOTS_ID);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/values/IntsImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/values/IntsImpl.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/values/IntsImpl.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/values/IntsImpl.java Mon Aug 22 22:54:26 2011
@@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.lucene.index.IndexFileNames;
-import org.apache.lucene.index.values.IndexDocValuesArray;
import org.apache.lucene.index.values.IndexDocValues.Source;
import org.apache.lucene.index.values.IndexDocValues.SourceEnum;
import org.apache.lucene.index.values.IndexDocValuesArray.ByteValues;
@@ -319,7 +318,7 @@ class IntsImpl {
try {
input = (IndexInput) datIn.clone();
input.seek(CodecUtil.headerLength(CODEC_NAME) + 1);
- source = loadFixedSource(type, input, numDocs);
+ source = loadFixedSource(type, input, numDocs);
success = true;
return source;
} finally {
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/values/PerDocFieldValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/values/PerDocFieldValues.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/values/PerDocFieldValues.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/java/org/apache/lucene/index/values/PerDocFieldValues.java Mon Aug 22 22:54:26 2011
@@ -19,14 +19,12 @@ package org.apache.lucene.index.values;
import java.util.Comparator;
import org.apache.lucene.document.IndexDocValuesField;
-import org.apache.lucene.index.IndexableField; // for javadoc
import org.apache.lucene.index.codecs.DocValuesConsumer;
import org.apache.lucene.util.BytesRef;
/**
* Per document and field values consumed by {@link DocValuesConsumer}.
* @see IndexDocValuesField
- * @see IndexableField#setDocValues(PerDocFieldValues)
*
* @lucene.experimental
*/
@@ -91,11 +89,10 @@ public interface PerDocFieldValues {
/**
* Sets the {@link ValueType}
*/
- public void setType(ValueType type);
+ public void setDocValuesType(ValueType type);
/**
* Returns the {@link ValueType}
*/
- public ValueType type();
-
-}
\ No newline at end of file
+ public ValueType docValuesType();
+}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java Mon Aug 22 22:54:26 2011
@@ -294,6 +294,6 @@ class DocHelper {
}
public static int numFields(Document doc) {
- return doc.size();
+ return doc.getFields().size();
}
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java Mon Aug 22 22:54:26 2011
@@ -133,7 +133,7 @@ public class RandomIndexWriter implement
// addDocuments? Would be better testing.
w.addDocuments(new Iterable<Iterable<T>>() {
- // @Override -- not until Java 1.6
+ @Override
public Iterator<Iterable<T>> iterator() {
return new Iterator<Iterable<T>>() {
boolean done;
@@ -148,7 +148,7 @@ public class RandomIndexWriter implement
throw new UnsupportedOperationException();
}
- // @Override -- not until Java 1.6
+ @Override
public Iterable<T> next() {
if (done) {
throw new IllegalStateException();
@@ -258,7 +258,7 @@ public class RandomIndexWriter implement
if (r.nextInt(5) == 3) {
w.updateDocuments(t, new Iterable<Iterable<T>>() {
- // @Override -- not until Java 1.6
+ @Override
public Iterator<Iterable<T>> iterator() {
return new Iterator<Iterable<T>>() {
boolean done;
@@ -273,7 +273,7 @@ public class RandomIndexWriter implement
throw new UnsupportedOperationException();
}
- // @Override -- not until Java 1.6
+ @Override
public Iterable<T> next() {
if (done) {
throw new IllegalStateException();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java Mon Aug 22 22:54:26 2011
@@ -1,7 +1,5 @@
package org.apache.lucene.document;
-import org.apache.lucene.util.LuceneTestCase;
-
import org.apache.lucene.document.BinaryField;
import org.apache.lucene.document.CompressionTools;
import org.apache.lucene.document.Document;
@@ -11,6 +9,8 @@ import org.apache.lucene.index.IndexRead
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.LuceneTestCase;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -52,7 +52,7 @@ public class TestBinaryDocument extends
doc.add(stringFldStored);
/** test for field count */
- assertEquals(2, doc.fields.size());
+ assertEquals(2, doc.getFields().size());
/** add the doc to a ram index */
Directory dir = newDirectory();
@@ -65,7 +65,9 @@ public class TestBinaryDocument extends
assertTrue(docFromReader != null);
/** fetch the binary stored field and compare it's content with the original one */
- String binaryFldStoredTest = new String(docFromReader.getBinaryValue("binaryStored"));
+ BytesRef bytes = docFromReader.getBinaryValue("binaryStored");
+ assertNotNull(bytes);
+ String binaryFldStoredTest = new String(bytes.bytes, bytes.offset, bytes.length);
assertTrue(binaryFldStoredTest.equals(binaryValStored));
/** fetch the string field and compare it's content with the original one */
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDocument.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDocument.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDocument.java Mon Aug 22 22:54:26 2011
@@ -15,6 +15,7 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
/**
@@ -54,14 +55,14 @@ public class TestDocument extends Lucene
doc.add(stringFld);
doc.add(binaryFld);
- assertEquals(2, doc.fields.size());
+ assertEquals(2, doc.getFields().size());
- assertTrue(binaryFld.binaryValue(null) != null);
+ assertTrue(binaryFld.binaryValue() != null);
assertTrue(binaryFld.stored());
assertFalse(binaryFld.indexed());
assertFalse(binaryFld.tokenized());
- String binaryTest = new String(doc.getBinaryValue("binary"));
+ String binaryTest = doc.getBinaryValue("binary").utf8ToString();
assertTrue(binaryTest.equals(binaryVal));
String stringTest = doc.get("string");
@@ -69,14 +70,14 @@ public class TestDocument extends Lucene
doc.add(binaryFld2);
- assertEquals(3, doc.fields.size());
+ assertEquals(3, doc.getFields().size());
- byte[][] binaryTests = doc.getBinaryValues("binary");
+ BytesRef[] binaryTests = doc.getBinaryValues("binary");
assertEquals(2, binaryTests.length);
- binaryTest = new String(binaryTests[0]);
- String binaryTest2 = new String(binaryTests[1]);
+ binaryTest = binaryTests[0].utf8ToString();
+ String binaryTest2 = binaryTests[1].utf8ToString();
assertFalse(binaryTest.equals(binaryTest2));
@@ -84,10 +85,10 @@ public class TestDocument extends Lucene
assertTrue(binaryTest2.equals(binaryVal2));
doc.removeField("string");
- assertEquals(2, doc.fields.size());
+ assertEquals(2, doc.getFields().size());
doc.removeFields("binary");
- assertEquals(0, doc.fields.size());
+ assertEquals(0, doc.getFields().size());
}
/**
@@ -98,29 +99,29 @@ public class TestDocument extends Lucene
*/
public void testRemoveForNewDocument() throws Exception {
Document doc = makeDocumentWithFields();
- assertEquals(8, doc.fields.size());
+ assertEquals(8, doc.getFields().size());
doc.removeFields("keyword");
- assertEquals(6, doc.fields.size());
+ assertEquals(6, doc.getFields().size());
doc.removeFields("doesnotexists"); // removing non-existing fields is
// siltenlty ignored
doc.removeFields("keyword"); // removing a field more than once
- assertEquals(6, doc.fields.size());
+ assertEquals(6, doc.getFields().size());
doc.removeField("text");
- assertEquals(5, doc.fields.size());
+ assertEquals(5, doc.getFields().size());
doc.removeField("text");
- assertEquals(4, doc.fields.size());
+ assertEquals(4, doc.getFields().size());
doc.removeField("text");
- assertEquals(4, doc.fields.size());
+ assertEquals(4, doc.getFields().size());
doc.removeField("doesnotexists"); // removing non-existing fields is
// siltenlty ignored
- assertEquals(4, doc.fields.size());
+ assertEquals(4, doc.getFields().size());
doc.removeFields("unindexed");
- assertEquals(2, doc.fields.size());
+ assertEquals(2, doc.getFields().size());
doc.removeFields("unstored");
- assertEquals(0, doc.fields.size());
+ assertEquals(0, doc.getFields().size());
doc.removeFields("doesnotexists"); // removing non-existing fields is
// siltenlty ignored
- assertEquals(0, doc.fields.size());
+ assertEquals(0, doc.getFields().size());
}
public void testConstructorExceptions() {
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexReader.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexReader.java Mon Aug 22 22:54:26 2011
@@ -43,7 +43,6 @@ import org.apache.lucene.index.IndexWrit
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.FieldCache;
-import org.apache.lucene.search.Similarity;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
@@ -392,8 +391,8 @@ public class TestIndexReader extends Luc
assertNotNull(fields);
assertEquals(1, fields.length);
IndexableField b1 = fields[0];
- assertTrue(b1.binaryValue(null) != null);
- BytesRef bytesRef = b1.binaryValue(null);
+ assertTrue(b1.binaryValue() != null);
+ BytesRef bytesRef = b1.binaryValue();
assertEquals(bin.length, bytesRef.length);
for (int i = 0; i < bin.length; i++) {
assertEquals(bin[i], bytesRef.bytes[i + bytesRef.offset]);
@@ -411,8 +410,8 @@ public class TestIndexReader extends Luc
assertNotNull(fields);
assertEquals(1, fields.length);
b1 = fields[0];
- assertTrue(b1.binaryValue(null) != null);
- bytesRef = b1.binaryValue(null);
+ assertTrue(b1.binaryValue() != null);
+ bytesRef = b1.binaryValue();
assertEquals(bin.length, bytesRef.length);
for (int i = 0; i < bin.length; i++) {
assertEquals(bin[i], bytesRef.bytes[i + bytesRef.offset]);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java Mon Aug 22 22:54:26 2011
@@ -26,17 +26,13 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.analysis.MockFixedLengthPayloadFilter;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
@@ -59,7 +55,6 @@ import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.Lock;
import org.apache.lucene.store.LockFactory;
@@ -68,12 +63,9 @@ import org.apache.lucene.store.NoLockFac
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.SingleInstanceLockFactory;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.ThreadInterruptedException;
-import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util._TestUtil;
-import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec;
public class TestIndexWriter extends LuceneTestCase {
@@ -1002,11 +994,11 @@ public class TestIndexWriter extends Luc
Document doc = new Document();
Field f = new BinaryField("binary", b, 10, 17);
- byte[] bx = f.binaryValue(null).bytes;
+ byte[] bx = f.binaryValue().bytes;
assertTrue(bx != null);
assertEquals(50, bx.length);
- assertEquals(10, f.binaryValue(null).offset);
- assertEquals(17, f.binaryValue(null).length);
+ assertEquals(10, f.binaryValue().offset);
+ assertEquals(17, f.binaryValue().length);
doc.add(f);
w.addDocument(doc);
w.close();
@@ -1014,7 +1006,7 @@ public class TestIndexWriter extends Luc
IndexReader ir = IndexReader.open(dir, true);
Document doc2 = ir.document(0);
IndexableField f2 = doc2.getField("binary");
- b = f2.binaryValue(null).bytes;
+ b = f2.binaryValue().bytes;
assertTrue(b != null);
assertEquals(17, b.length, 17);
assertEquals(87, b[0]);
@@ -1285,14 +1277,14 @@ public class TestIndexWriter extends Luc
IndexReader ir = IndexReader.open(dir, true);
Document doc2 = ir.document(0);
IndexableField f3 = doc2.getField("binary");
- b = f3.binaryValue(null).bytes;
+ b = f3.binaryValue().bytes;
assertTrue(b != null);
assertEquals(17, b.length, 17);
assertEquals(87, b[0]);
- assertTrue(ir.document(0).getField("binary").binaryValue(null)!=null);
- assertTrue(ir.document(1).getField("binary").binaryValue(null)!=null);
- assertTrue(ir.document(2).getField("binary").binaryValue(null)!=null);
+ assertTrue(ir.document(0).getField("binary").binaryValue()!=null);
+ assertTrue(ir.document(1).getField("binary").binaryValue()!=null);
+ assertTrue(ir.document(2).getField("binary").binaryValue()!=null);
assertEquals("value", ir.document(0).get("string"));
assertEquals("value", ir.document(1).get("string"));
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexableField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexableField.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexableField.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestIndexableField.java Mon Aug 22 22:54:26 2011
@@ -17,70 +17,26 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
import java.io.Reader;
import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.analysis.MockFixedLengthPayloadFilter;
-import org.apache.lucene.analysis.MockTokenizer;
+
import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.Tokenizer;
-import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-import org.apache.lucene.document.BinaryField;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.NumericField.DataType;
import org.apache.lucene.document.NumericField;
import org.apache.lucene.document.StringField;
-import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec;
import org.apache.lucene.index.values.PerDocFieldValues;
import org.apache.lucene.index.values.ValueType;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.NumericRangeQuery;
-import org.apache.lucene.search.PhraseQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
-import org.apache.lucene.search.spans.SpanTermQuery;
-import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.IOContext;
-import org.apache.lucene.store.IndexOutput;
-import org.apache.lucene.store.Lock;
-import org.apache.lucene.store.LockFactory;
-import org.apache.lucene.store.MockDirectoryWrapper;
-import org.apache.lucene.store.NoLockFactory;
-import org.apache.lucene.store.RAMDirectory;
-import org.apache.lucene.store.SingleInstanceLockFactory;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.ThreadInterruptedException;
-import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util._TestUtil;
public class TestIndexableField extends LuceneTestCase {
@@ -109,7 +65,7 @@ public class TestIndexableField extends
}
@Override
- public BytesRef binaryValue(BytesRef reuse) {
+ public BytesRef binaryValue() {
if ((counter%10) == 3) {
final byte[] bytes = new byte[10];
for(int idx=0;idx<bytes.length;idx++) {
@@ -208,11 +164,6 @@ public class TestIndexableField extends
}
@Override
- public boolean hasDocValues() {
- return false;
- }
-
- @Override
public ValueType docValuesType() {
return null;
}
@@ -311,7 +262,7 @@ public class TestIndexableField extends
assertNotNull("doc " + id + " doesn't have field f" + counter, f);
if (binary) {
assertNotNull("doc " + id + " doesn't have field f" + counter, f);
- final BytesRef b = f.binaryValue(null);
+ final BytesRef b = f.binaryValue();
assertNotNull(b);
assertEquals(10, b.length);
for(int idx=0;idx<10;idx++) {
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java Mon Aug 22 22:54:26 2011
@@ -17,7 +17,6 @@ package org.apache.lucene.index;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -30,7 +29,6 @@ import org.apache.lucene.util.*;
import junit.framework.Assert;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.index.IndexableField;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
@@ -263,7 +261,6 @@ public class TestStressIndexing2 extends
Collections.sort(fields, fieldNameComparator2);
Document d1 = new Document();
- //d1.setBoost(d.getBoost());
for (int i=0; i<fields.size(); i++) {
d1.add(fields.get(i));
}
@@ -527,8 +524,8 @@ public class TestStressIndexing2 extends
for (int i=0; i<ff1.size(); i++) {
IndexableField f1 = ff1.get(i);
IndexableField f2 = ff2.get(i);
- if (f1.binaryValue(null) != null) {
- assert(f2.binaryValue(null) != null);
+ if (f1.binaryValue() != null) {
+ assert(f2.binaryValue() != null);
} else {
String s1 = f1.stringValue();
String s2 = f2.stringValue();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressNRT.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressNRT.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressNRT.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressNRT.java Mon Aug 22 22:54:26 2011
@@ -28,7 +28,6 @@ import java.util.concurrent.atomic.Atomi
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.search.IndexSearcher;
@@ -83,6 +82,9 @@ public class TestStressNRT extends Lucen
final int nReadThreads = _TestUtil.nextInt(random, 1, TEST_NIGHTLY ? 10 : 5);
initModel(ndocs);
+ final FieldType storedOnlyType = new FieldType();
+ storedOnlyType.setStored(true);
+
if (VERBOSE) {
System.out.println("\n");
System.out.println("TEST: commitPercent=" + commitPercent);
@@ -230,10 +232,8 @@ public class TestStressNRT extends Lucen
// add tombstone first
if (tombstones) {
Document d = new Document();
- d.add(new Field("id", StringField.TYPE_STORED, "-"+Integer.toString(id)));
- FieldType stored = new FieldType();
- stored.setStored(true);
- d.add(new Field(field, stored, Long.toString(nextVal)));
+ d.add(newField("id", "-"+Integer.toString(id), StringField.TYPE_STORED));
+ d.add(newField(field, Long.toString(nextVal), storedOnlyType));
writer.updateDocument(new Term("id", "-"+Integer.toString(id)), d);
}
@@ -248,10 +248,8 @@ public class TestStressNRT extends Lucen
// add tombstone first
if (tombstones) {
Document d = new Document();
- d.add(new Field("id", StringField.TYPE_STORED, "-"+Integer.toString(id)));
- FieldType stored = new FieldType();
- stored.setStored(true);
- d.add(new Field(field, stored, Long.toString(nextVal)));
+ d.add(newField("id", "-"+Integer.toString(id), StringField.TYPE_STORED));
+ d.add(newField(field, Long.toString(nextVal), storedOnlyType));
writer.updateDocument(new Term("id", "-"+Integer.toString(id)), d);
}
@@ -263,10 +261,8 @@ public class TestStressNRT extends Lucen
} else {
// assertU(adoc("id",Integer.toString(id), field, Long.toString(nextVal)));
Document d = new Document();
- d.add(new Field("id", StringField.TYPE_STORED, "-"+Integer.toString(id)));
- FieldType stored = new FieldType();
- stored.setStored(true);
- d.add(new Field(field, stored, Long.toString(nextVal)));
+ d.add(newField("id", Integer.toString(id), StringField.TYPE_STORED));
+ d.add(newField(field, Long.toString(nextVal), storedOnlyType));
if (VERBOSE) {
System.out.println("TEST: " + Thread.currentThread().getName() + ": u id:" + id + " val=" + nextVal);
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java Mon Aug 22 22:54:26 2011
@@ -496,11 +496,8 @@ public class TestDocValuesIndexing exten
ft.setStored(true);
}
- Field field = random.nextBoolean() ? new IndexDocValuesField(value.name())
- : newField(value.name(), _TestUtil.randomRealisticUnicodeString(random,
- 10), ft);
- doc.add(field);
- IndexDocValuesField valField = new IndexDocValuesField("prototype");
+ IndexDocValuesField valField = new IndexDocValuesField(value.name());
+ doc.add(valField);
final BytesRef bytesRef = new BytesRef();
final String idBase = value.name() + "_";
@@ -549,7 +546,6 @@ public class TestDocValuesIndexing exten
}
doc.removeFields("id");
doc.add(new Field("id", StringField.TYPE_STORED, idBase + i));
- valField.set(field);
w.addDocument(doc);
if (i % 7 == 0) {
@@ -571,8 +567,9 @@ public class TestDocValuesIndexing exten
w.commit();
// TODO test unoptimized with deletions
- if (withDeletions || random.nextBoolean())
+ if (withDeletions || random.nextBoolean()) {
w.optimize(true);
+ }
return deleted;
}
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/search/TestDocBoost.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/search/TestDocBoost.java?rev=1160484&r1=1160483&r2=1160484&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/search/TestDocBoost.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/search/TestDocBoost.java Mon Aug 22 22:54:26 2011
@@ -23,7 +23,6 @@ import org.apache.lucene.analysis.MockAn
import org.apache.lucene.document.*;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
@@ -45,20 +44,12 @@ public class TestDocBoost extends Lucene
Document d1 = new Document();
Document d2 = new Document();
- Document d3 = new Document();
- Document d4 = new Document();
- //d3.setBoost(3.0f);
- //d4.setBoost(2.0f);
d1.add(f1); // boost = 1
d2.add(f2); // boost = 2
- //d3.add(f1); // boost = 3
- //d4.add(f2); // boost = 4
writer.addDocument(d1);
writer.addDocument(d2);
- //writer.addDocument(d3);
- //writer.addDocument(d4);
IndexReader reader = writer.getReader();
writer.close();