lidavidm commented on code in PR #14289:
URL: https://github.com/apache/arrow/pull/14289#discussion_r985694473
##########
java/vector/src/main/java/org/apache/arrow/vector/GenerateSampleData.java:
##########
@@ -267,6 +275,58 @@ private static void writeTinyIntData(TinyIntVector vector,
int valueCount) {
vector.setValueCount(valueCount);
}
+ private static void writeUInt1Data(UInt1Vector vector, int valueCount) {
+ final byte even = 1;
+ final byte odd = 2;
+ for (int i = 0; i < valueCount; i++) {
+ if (i % 2 == 0) {
+ vector.setSafe(i, even);
+ } else {
+ vector.setSafe(i, odd);
+ }
+ }
+ vector.setValueCount(valueCount);
+ }
+
+ private static void writeUInt2Data(UInt2Vector vector, int valueCount) {
+ final short even = 10;
+ final short odd = 20;
+ for (int i = 0; i < valueCount; i++) {
+ if (i % 2 == 0) {
+ vector.setSafe(i, even);
+ } else {
+ vector.setSafe(i, odd);
+ }
+ }
+ vector.setValueCount(valueCount);
+ }
+
+ private static void writeUInt4Data(UInt4Vector vector, int valueCount) {
+ final int even = 1000;
+ final int odd = 2000;
+ for (int i = 0; i < valueCount; i++) {
+ if (i % 2 == 0) {
+ vector.setSafe(i, even);
+ } else {
+ vector.setSafe(i, odd);
+ }
+ }
+ vector.setValueCount(valueCount);
+ }
+
+ private static void writeUInt8Data(UInt8Vector vector, int valueCount) {
+ final long even = 1000000000;
+ final long odd = 2000000000;
Review Comment:
Is it possible to use a value that wouldn't be representable in the signed
equivalent of the vectors? (Not sure how you write such a value though)
##########
java/vector/src/main/java/org/apache/arrow/vector/GenerateSampleData.java:
##########
@@ -267,6 +275,58 @@ private static void writeTinyIntData(TinyIntVector vector,
int valueCount) {
vector.setValueCount(valueCount);
}
+ private static void writeUInt1Data(UInt1Vector vector, int valueCount) {
+ final byte even = 1;
+ final byte odd = 2;
+ for (int i = 0; i < valueCount; i++) {
+ if (i % 2 == 0) {
+ vector.setSafe(i, even);
+ } else {
+ vector.setSafe(i, odd);
+ }
+ }
+ vector.setValueCount(valueCount);
+ }
+
+ private static void writeUInt2Data(UInt2Vector vector, int valueCount) {
+ final short even = 10;
+ final short odd = 20;
+ for (int i = 0; i < valueCount; i++) {
+ if (i % 2 == 0) {
+ vector.setSafe(i, even);
+ } else {
+ vector.setSafe(i, odd);
+ }
+ }
+ vector.setValueCount(valueCount);
+ }
+
+ private static void writeUInt4Data(UInt4Vector vector, int valueCount) {
+ final int even = 1000;
+ final int odd = 2000;
+ for (int i = 0; i < valueCount; i++) {
+ if (i % 2 == 0) {
+ vector.setSafe(i, even);
+ } else {
+ vector.setSafe(i, odd);
+ }
+ }
+ vector.setValueCount(valueCount);
+ }
+
+ private static void writeUInt8Data(UInt8Vector vector, int valueCount) {
+ final long even = 1000000000;
+ final long odd = 2000000000;
Review Comment:
Well, the value has to be representable somehow (else how would IPC work?
I'm guessing you'd just take a negative int and it would reinterpret it as an
unsigned integer) and I'd want us to test a range of values that may occur (the
C++ unit tests for kernels, for instance, try to test the extremes, 0,
negatives, etc. to catch corner cases, and frameworks like Hypothesis
generalize this)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]