Apache Lucene open-source search software
rename the 3 bytesref.copy methods to avoid type promotion traps
Robert Muir145d6e8d9229
diff --git a/lucene/src/java/org/apache/lucene/index/values/IndexDocValuesArray.java b/lucene/src/java/org/apache/lucene/index/values/IndexDocValuesArray.javaindex aa9d2ed5e9c..beda4f5b43d 100644--- a/lucene/src/java/org/apache/lucene/index/values/IndexDocValuesArray.java+++ b/lucene/src/java/org/apache/lucene/index/values/IndexDocValuesArray.java@@ -62,11 +62,11 @@ abstract class IndexDocValuesArray extends Source {}void toBytes(long value, BytesRef bytesRef) {- bytesRef.copy(value);+ bytesRef.copyLong(value);}void toBytes(double value, BytesRef bytesRef) {- bytesRef.copy(Double.doubleToRawLongBits(value));+ bytesRef.copyLong(Double.doubleToRawLongBits(value));}final static class ByteValues extends IndexDocValuesArray {@@ -140,7 +140,7 @@ abstract class IndexDocValuesArray extends Source {}void toBytes(long value, BytesRef bytesRef) {- bytesRef.copy((short) (0xFFFFL & value));+ bytesRef.copyShort((short) (0xFFFFL & value));}};@@ -179,7 +179,7 @@ abstract class IndexDocValuesArray extends Source {}void toBytes(long value, BytesRef bytesRef) {- bytesRef.copy((int) (0xFFFFFFFF & value));+ bytesRef.copyInt((int) (0xFFFFFFFF & value));}};@@ -252,7 +252,7 @@ abstract class IndexDocValuesArray extends Source {@Overridevoid toBytes(double value, BytesRef bytesRef) {- bytesRef.copy(Float.floatToRawIntBits((float)value));+ bytesRef.copyInt(Float.floatToRawIntBits((float)value));}diff --git a/lucene/src/java/org/apache/lucene/index/values/PackedIntValues.java b/lucene/src/java/org/apache/lucene/index/values/PackedIntValues.javaindex 7ee814f8b42..e4599a42db4 100644--- a/lucene/src/java/org/apache/lucene/index/values/PackedIntValues.java+++ b/lucene/src/java/org/apache/lucene/index/values/PackedIntValues.java@@ -73,7 +73,7 @@ class PackedIntValues {}}lastDocId = docID;- bytesRef.copy(v);+ bytesRef.copyLong(v);add(docID, bytesRef);}@@ -244,7 +244,7 @@ class PackedIntValues {@Overridepublic BytesRef getBytes(int docID, BytesRef ref) {ref.grow(8);- ref.copy(getInt(docID));+ ref.copyLong(getInt(docID));return ref;}diff --git a/lucene/src/java/org/apache/lucene/util/BytesRef.java b/lucene/src/java/org/apache/lucene/util/BytesRef.javaindex 43e8aeae859..0d2604d67f1 100644--- a/lucene/src/java/org/apache/lucene/util/BytesRef.java+++ b/lucene/src/java/org/apache/lucene/util/BytesRef.java@@ -227,7 +227,7 @@ public final class BytesRef implements Comparable<BytesRef> {* NOTE: this method resets the offset to 0, length to 8 and resizes the reference array* if needed.*/- public void copy(long value) {+ public void copyLong(long value) {if (bytes.length < 8) {bytes = new byte[8];}@@ -242,7 +242,7 @@ public final class BytesRef implements Comparable<BytesRef> {* NOTE: this method resets the offset to 0, length to 4 and resizes the reference array* if needed.*/- public void copy(int value) {+ public void copyInt(int value) {if (bytes.length < 4) {bytes = new byte[4];}@@ -256,7 +256,7 @@ public final class BytesRef implements Comparable<BytesRef> {* NOTE: this method resets the offset to 0, length to 2 and resizes the reference array* if needed.*/- public void copy(short value) {+ public void copyShort(short value) {if (bytes.length < 2) {bytes = new byte[2];}diff --git a/lucene/src/test/org/apache/lucene/index/values/TestTypePromotion.java b/lucene/src/test/org/apache/lucene/index/values/TestTypePromotion.javaindex 2e0aed4e01a..7bb5a19990a 100644--- a/lucene/src/test/org/apache/lucene/index/values/TestTypePromotion.java+++ b/lucene/src/test/org/apache/lucene/index/values/TestTypePromotion.java@@ -239,17 +239,17 @@ public class TestTypePromotion extends LuceneTestCase {case BYTES_FIXED_SORTED:case BYTES_FIXED_STRAIGHT:values[i] = random.nextLong();- ref.copy(values[i]);+ ref.copyLong(values[i]);valField.setBytes(ref, valueType);break;case BYTES_VAR_DEREF:case BYTES_VAR_SORTED:case BYTES_VAR_STRAIGHT:if (random.nextBoolean()) {- ref.copy(random.nextInt());+ ref.copyInt(random.nextInt());values[i] = asInt(ref);} else {- ref.copy(random.nextLong());+ ref.copyLong(random.nextLong());values[i] = asLong(ref);}valField.setBytes(ref, valueType);