Apache Solr open-source search software
LUCENE-4425: Unclear documentation of StoredFieldVisitor.binaryValue
Robert Muir65d22acbbb2d
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex f8d287d312b..56061e561e8 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -139,6 +139,10 @@ API ChangesBits as liveDocs, then use the flex apis (fields(), terms(), etc) directly.(Mike McCandless, Robert Muir)+* LUCENE-4425: clarify documentation of StoredFieldVisitor.binaryValue+ and simplify the api to binaryField(FieldInfo, byte[]).+ (Adrien Grand, Robert Muir)+Bug Fixes* LUCENE-4423: DocumentStoredFieldVisitor.binaryField ignored offset anddiff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.javaindex 3cbbb894f83..4ca78b22a04 100644--- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.java+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.java@@ -139,10 +139,9 @@ public class SimpleTextStoredFieldsReader extends StoredFieldsReader {if (type == TYPE_STRING) {visitor.stringField(fieldInfo, new String(scratch.bytes, scratch.offset+VALUE.length, scratch.length-VALUE.length, "UTF-8"));} else if (type == TYPE_BINARY) {- // TODO: who owns the bytes?byte[] copy = new byte[scratch.length-VALUE.length];System.arraycopy(scratch.bytes, scratch.offset+VALUE.length, copy, 0, copy.length);- visitor.binaryField(fieldInfo, copy, 0, copy.length);+ visitor.binaryField(fieldInfo, copy);} else if (type == TYPE_INT) {UnicodeUtil.UTF8toUTF16(scratch.bytes, scratch.offset+VALUE.length, scratch.length-VALUE.length, scratchUTF16);visitor.intField(fieldInfo, Integer.parseInt(scratchUTF16.toString()));diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsReader.javaindex 3ab1b586819..bcdcdae83be 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsReader.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsReader.java@@ -188,7 +188,7 @@ public final class Lucene40StoredFieldsReader extends StoredFieldsReader implemebyte bytes[] = new byte[length];fieldsStream.readBytes(bytes, 0, length);if ((bits & FIELD_IS_BINARY) != 0) {- visitor.binaryField(info, bytes, 0, bytes.length);+ visitor.binaryField(info, bytes);} else {visitor.stringField(info, new String(bytes, 0, bytes.length, IOUtils.CHARSET_UTF_8));}diff --git a/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java b/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.javaindex a8927363dc3..340f2c41a13 100644--- a/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java+++ b/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java@@ -58,8 +58,8 @@ public class DocumentStoredFieldVisitor extends StoredFieldVisitor {}@Override- public void binaryField(FieldInfo fieldInfo, byte[] value, int offset, int length) throws IOException {- doc.add(new StoredField(fieldInfo.name, value, offset, length));+ public void binaryField(FieldInfo fieldInfo, byte[] value) throws IOException {+ doc.add(new StoredField(fieldInfo.name, value));}@Overridediff --git a/lucene/core/src/java/org/apache/lucene/index/StoredFieldVisitor.java b/lucene/core/src/java/org/apache/lucene/index/StoredFieldVisitor.javaindex 9967ca99a24..88ead6467cf 100644--- a/lucene/core/src/java/org/apache/lucene/index/StoredFieldVisitor.java+++ b/lucene/core/src/java/org/apache/lucene/index/StoredFieldVisitor.java@@ -41,8 +41,10 @@ public abstract class StoredFieldVisitor {protected StoredFieldVisitor() {}- /** Process a binary field. */- public void binaryField(FieldInfo fieldInfo, byte[] value, int offset, int length) throws IOException {+ /** Process a binary field.+ * @param value newly allocated byte array with the binary contents.+ */+ public void binaryField(FieldInfo fieldInfo, byte[] value) throws IOException {}/** Process a string field */diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/FieldFilterAtomicReader.java b/lucene/test-framework/src/java/org/apache/lucene/index/FieldFilterAtomicReader.javaindex 6744e2bda9a..f79ac4de076 100644--- a/lucene/test-framework/src/java/org/apache/lucene/index/FieldFilterAtomicReader.java+++ b/lucene/test-framework/src/java/org/apache/lucene/index/FieldFilterAtomicReader.java@@ -72,8 +72,8 @@ public final class FieldFilterAtomicReader extends FilterAtomicReader {public void document(final int docID, final StoredFieldVisitor visitor) throws IOException {super.document(docID, new StoredFieldVisitor() {@Override- public void binaryField(FieldInfo fieldInfo, byte[] value, int offset, int length) throws IOException {- visitor.binaryField(fieldInfo, value, offset, length);+ public void binaryField(FieldInfo fieldInfo, byte[] value) throws IOException {+ visitor.binaryField(fieldInfo, value);}@Overridediff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.javaindex 256f80c46b4..a3645949eac 100644--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java@@ -451,8 +451,8 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn}@Override- public void binaryField(FieldInfo fieldInfo, byte[] value, int offset, int length) throws IOException {- doc.add(new StoredField(fieldInfo.name, value, offset, length));+ public void binaryField(FieldInfo fieldInfo, byte[] value) throws IOException {+ doc.add(new StoredField(fieldInfo.name, value));}@Override