mirror of https://github.com/apache/lucene.git
LUCENE-4425: Unclear documentation of StoredFieldVisitor.binaryValue
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1390683 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bddab9a355
commit
65d22acbbb
|
@ -139,6 +139,10 @@ API Changes
|
|||
Bits 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 and
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -188,7 +188,7 @@ public final class Lucene40StoredFieldsReader extends StoredFieldsReader impleme
|
|||
byte 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));
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue