Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

javadoc: define UTF16toUTF8 result.offset=0, doc that BytesRef references byte[] instead of copying

Yonik Seeley4258ebca68a4
diff --git a/lucene/src/java/org/apache/lucene/util/BytesRef.java b/lucene/src/java/org/apache/lucene/util/BytesRef.java
index 616d19bca32..218fc168140 100644
--- a/lucene/src/java/org/apache/lucene/util/BytesRef.java
+++ b/lucene/src/java/org/apache/lucene/util/BytesRef.java
@@ -40,7 +40,9 @@ public final class BytesRef implements Comparable<BytesRef> {
bytes = EMPTY_BYTES;
}
- /** bytes[] should not be null */
+ /** This instance will directly reference bytes w/o making a copy.
+ * bytes should not be null.
+ */
public BytesRef(byte[] bytes, int offset, int length) {
assert bytes != null;
this.bytes = bytes;
@@ -48,7 +50,8 @@ public final class BytesRef implements Comparable<BytesRef> {
this.length = length;
}
- /** bytes[] should not be null */
+ /** This instance will directly reference bytes w/o making a copy.
+ * bytes should not be null */
public BytesRef(byte[] bytes) {
assert bytes != null;
this.bytes = bytes;
diff --git a/lucene/src/java/org/apache/lucene/util/UnicodeUtil.java b/lucene/src/java/org/apache/lucene/util/UnicodeUtil.java
index 17f8c369024..abffbb0ab76 100644
--- a/lucene/src/java/org/apache/lucene/util/UnicodeUtil.java
+++ b/lucene/src/java/org/apache/lucene/util/UnicodeUtil.java
@@ -99,7 +99,7 @@ final public class UnicodeUtil {
}
/** Encode characters from a char[] source, starting at
- * offset for length chars. Returns a hash of the resulting bytes */
+ * offset for length chars. Returns a hash of the resulting bytes. After encoding, result.offset will always be 0. */
public static int UTF16toUTF8WithHash(final char[] source, final int offset, final int length, BytesRef result) {
int hash = 0;
int upto = 0;
@@ -154,7 +154,7 @@ final public class UnicodeUtil {
}
/** Encode characters from a char[] source, starting at
- * offset for length chars.
+ * offset for length chars. After encoding, result.offset will always be 0.
*/
public static void UTF16toUTF8(final char[] source, final int offset, final int length, BytesRef result) {
@@ -209,7 +209,7 @@ final public class UnicodeUtil {
}
/** Encode characters from this String, starting at offset
- * for length characters.
+ * for length characters. After encoding, result.offset will always be 0.
*/
public static void UTF16toUTF8(final CharSequence s, final int offset, final int length, BytesRef result) {
final int end = offset + length;