Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@

package org.apache.arrow.vector.ipc;

import static org.junit.Assert.assertEquals;

import java.io.File;
import java.io.IOException;

import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.FieldVector;
import org.apache.arrow.vector.UInt1Vector;
import org.apache.arrow.vector.UInt4Vector;
import org.apache.arrow.vector.UInt8Vector;
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.arrow.vector.complex.StructVector;
import org.apache.arrow.vector.complex.impl.ComplexWriterImpl;
Expand Down Expand Up @@ -401,4 +406,39 @@ public void testWriteReadMapJSON() throws IOException {
reader.close();
}
}

@Test
public void testNoOverFlowWithUINT() {
try (final UInt8Vector uInt8Vector = new UInt8Vector("uint8", allocator);
final UInt4Vector uInt4Vector = new UInt4Vector("uint4", allocator);
final UInt1Vector uInt1Vector = new UInt1Vector("uint1", allocator)) {

long[] longValues = new long[]{Long.MIN_VALUE, Long.MAX_VALUE, -1L};
uInt8Vector.allocateNew(3);
uInt8Vector.setValueCount(3);
for (int i = 0; i < longValues.length; i++) {
uInt8Vector.set(i, longValues[i]);
long readValue = uInt8Vector.getObjectNoOverflow(i).longValue();
assertEquals(readValue, longValues[i]);
}

int[] intValues = new int[]{Integer.MIN_VALUE, Integer.MAX_VALUE, -1};
uInt4Vector.allocateNew(3);
uInt4Vector.setValueCount(3);
for (int i = 0; i < intValues.length; i++) {
uInt4Vector.set(i, intValues[i]);
int actualValue = (int) UInt4Vector.getNoOverflow(uInt4Vector.getDataBuffer(), i);
assertEquals(intValues[i], actualValue);
}

byte[] byteValues = new byte[]{Byte.MIN_VALUE, Byte.MAX_VALUE, -1};
uInt1Vector.allocateNew(3);
uInt1Vector.setValueCount(3);
for (int i = 0; i < byteValues.length; i++) {
uInt1Vector.set(i, byteValues[i]);
byte actualValue = (byte) UInt1Vector.getNoOverflow(uInt1Vector.getDataBuffer(),i);
assertEquals(byteValues[i], actualValue);
}
}
}
}