Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.

Commit 01f9a48

Browse files
committed
revert changes in copyFrom
1 parent a22d58a commit 01f9a48

File tree

7 files changed

+13
-161
lines changed

7 files changed

+13
-161
lines changed

java/performance/src/test/java/org/apache/arrow/vector/util/TransferPairBenchmarks.java

Lines changed: 0 additions & 129 deletions
This file was deleted.

java/vector/src/main/codegen/templates/UnionVector.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,6 @@ public TransferPair makeTransferPair(ValueVector target) {
408408
@Override
409409
public void copyFrom(int inIndex, int outIndex, ValueVector from) {
410410
Preconditions.checkArgument(this.getMinorType() == from.getMinorType());
411-
Preconditions.checkArgument(inIndex >= 0 && inIndex < from.getValueCount(),
412-
"Invalid inIndex: %s", inIndex);
413411
UnionVector fromCast = (UnionVector) from;
414412
fromCast.getReader().setPosition(inIndex);
415413
getWriter().setPosition(outIndex);

java/vector/src/main/java/org/apache/arrow/vector/BaseFixedWidthVector.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,6 @@ protected void handleSafe(int index) {
833833
@Override
834834
public void copyFrom(int fromIndex, int thisIndex, ValueVector from) {
835835
Preconditions.checkArgument(this.getMinorType() == from.getMinorType());
836-
Preconditions.checkArgument(fromIndex >= 0 && fromIndex < from.getValueCount(),
837-
"Invalid fromIndex: %s", fromIndex);
838836
if (from.isNull(fromIndex)) {
839837
BitVectorHelper.unsetBit(this.getValidityBuffer(), thisIndex);
840838
} else {
@@ -856,8 +854,6 @@ public void copyFrom(int fromIndex, int thisIndex, ValueVector from) {
856854
@Override
857855
public void copyFromSafe(int fromIndex, int thisIndex, ValueVector from) {
858856
Preconditions.checkArgument(this.getMinorType() == from.getMinorType());
859-
Preconditions.checkArgument(fromIndex >= 0 && fromIndex < from.getValueCount(),
860-
"Invalid fromIndex: %s", fromIndex);
861857
handleSafe(thisIndex);
862858
copyFrom(fromIndex, thisIndex, from);
863859
}

java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,8 +1339,6 @@ public void copyFrom(int fromIndex, int thisIndex, ValueVector from) {
13391339
@Override
13401340
public void copyFromSafe(int fromIndex, int thisIndex, ValueVector from) {
13411341
Preconditions.checkArgument(this.getMinorType() == from.getMinorType());
1342-
Preconditions.checkArgument(fromIndex >= 0 && fromIndex < from.getValueCount(),
1343-
"Invalid fromIndex: %s", fromIndex);
13441342
if (from.isNull(fromIndex)) {
13451343
handleSafe(thisIndex, 0);
13461344
fillHoles(thisIndex);

java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,6 @@ public void copyFromSafe(int inIndex, int outIndex, ValueVector from) {
364364
@Override
365365
public void copyFrom(int inIndex, int outIndex, ValueVector from) {
366366
Preconditions.checkArgument(this.getMinorType() == from.getMinorType());
367-
Preconditions.checkArgument(inIndex >= 0 && inIndex < from.getValueCount(),
368-
"Invalid inIndex: %s", inIndex);
369367
FieldReader in = from.getReader();
370368
in.setPosition(inIndex);
371369
FieldWriter out = getWriter();

java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ public FieldReader getReader() {
9999
@Override
100100
public void copyFrom(int fromIndex, int thisIndex, ValueVector from) {
101101
Preconditions.checkArgument(this.getMinorType() == from.getMinorType());
102-
Preconditions.checkArgument(fromIndex >= 0 && fromIndex < from.getValueCount(),
103-
"Invalid fromIndex: %s", fromIndex);
104102
if (ephPair == null || ephPair.from != from) {
105103
ephPair = (StructTransferPair) from.makeTransferPair(this);
106104
}

java/vector/src/test/java/org/apache/arrow/vector/TestSplitAndTransfer.java

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.junit.After;
3030
import org.junit.Before;
3131
import org.junit.Test;
32+
import org.junit.jupiter.api.Assertions;
3233

3334
public class TestSplitAndTransfer {
3435
private BufferAllocator allocator;
@@ -172,22 +173,6 @@ public void testCopyValueSafe() {
172173
}
173174
}
174175

175-
@Test(expected = IllegalArgumentException.class)
176-
public void testInvalidCopyValueSafe() {
177-
try (final VarCharVector varCharVector = new VarCharVector("myvector", allocator);
178-
final VarCharVector newVarCharVector = new VarCharVector("newvector", allocator)) {
179-
varCharVector.allocateNew(10000, 1000);
180-
181-
final int valueCount = 500;
182-
populateVarcharVector(varCharVector, valueCount, null);
183-
184-
final TransferPair tp = varCharVector.makeTransferPair(newVarCharVector);
185-
186-
// fromIndex is invalid.
187-
tp.copyValueSafe(valueCount, 0);
188-
}
189-
}
190-
191176
@Test
192177
public void testSplitAndTransferNon() {
193178
try (final VarCharVector varCharVector = new VarCharVector("myvector", allocator)) {
@@ -224,7 +209,7 @@ public void testSplitAndTransferAll() {
224209
}
225210
}
226211

227-
@Test(expected = IllegalArgumentException.class)
212+
@Test
228213
public void testInvalidStartIndex() {
229214
try (final VarCharVector varCharVector = new VarCharVector("myvector", allocator);
230215
final VarCharVector newVarCharVector = new VarCharVector("newvector", allocator)) {
@@ -235,13 +220,17 @@ public void testInvalidStartIndex() {
235220

236221
final TransferPair tp = varCharVector.makeTransferPair(newVarCharVector);
237222

238-
tp.splitAndTransfer(valueCount, 10);
223+
IllegalArgumentException e = Assertions.assertThrows(
224+
IllegalArgumentException.class,
225+
() -> tp.splitAndTransfer(valueCount, 10));
226+
227+
assertEquals("Invalid startIndex: 500", e.getMessage());
239228

240229
newVarCharVector.clear();
241230
}
242231
}
243232

244-
@Test(expected = IllegalArgumentException.class)
233+
@Test
245234
public void testInvalidLength() {
246235
try (final VarCharVector varCharVector = new VarCharVector("myvector", allocator);
247236
final VarCharVector newVarCharVector = new VarCharVector("newvector", allocator)) {
@@ -252,7 +241,11 @@ public void testInvalidLength() {
252241

253242
final TransferPair tp = varCharVector.makeTransferPair(newVarCharVector);
254243

255-
tp.splitAndTransfer(0, valueCount * 2);
244+
IllegalArgumentException e = Assertions.assertThrows(
245+
IllegalArgumentException.class,
246+
() -> tp.splitAndTransfer(0, valueCount * 2));
247+
248+
assertEquals("Invalid length: 1000", e.getMessage());
256249

257250
newVarCharVector.clear();
258251
}

0 commit comments

Comments
 (0)