Skip to content

Commit

Permalink
fixing warnings v17: vector s5
Browse files Browse the repository at this point in the history
  • Loading branch information
vibhatha committed Jan 17, 2024
1 parent 70e9efa commit 56a95fd
Show file tree
Hide file tree
Showing 23 changed files with 238 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static org.junit.Assert.assertTrue;

import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.BufferAllocator;
Expand Down Expand Up @@ -133,7 +134,7 @@ public void testLargeDecimalVector() {

for (int i = 0; i < vecLength; i++) {
ArrowBuf buf = largeVec.get(i);
assertEquals(buf.capacity(), DecimalVector.TYPE_WIDTH);
assertEquals(DecimalVector.TYPE_WIDTH, buf.capacity());
assertEquals(0, buf.getLong(0));
assertEquals(0, buf.getLong(8));

Expand Down Expand Up @@ -215,7 +216,7 @@ public void testLargeVarCharVector() {
logger.trace("Successfully allocated a vector with capacity " + vecLength);

for (int i = 0; i < vecLength; i++) {
largeVec.setSafe(i, strElement.getBytes());
largeVec.setSafe(i, strElement.getBytes(StandardCharsets.UTF_8));

if ((i + 1) % 10000 == 0) {
logger.trace("Successfully written " + (i + 1) + " values");
Expand All @@ -228,7 +229,7 @@ public void testLargeVarCharVector() {

for (int i = 0; i < vecLength; i++) {
byte[] val = largeVec.get(i);
assertEquals(strElement, new String(val));
assertEquals(strElement, new String(val, StandardCharsets.UTF_8));

if ((i + 1) % 10000 == 0) {
logger.trace("Successfully read " + (i + 1) + " values");
Expand All @@ -254,7 +255,7 @@ public void testLargeLargeVarCharVector() {
logger.trace("Successfully allocated a vector with capacity " + vecLength);

for (int i = 0; i < vecLength; i++) {
largeVec.setSafe(i, strElement.getBytes());
largeVec.setSafe(i, strElement.getBytes(StandardCharsets.UTF_8));

if ((i + 1) % 10000 == 0) {
logger.trace("Successfully written " + (i + 1) + " values");
Expand All @@ -267,7 +268,7 @@ public void testLargeLargeVarCharVector() {

for (int i = 0; i < vecLength; i++) {
byte[] val = largeVec.get(i);
assertEquals(strElement, new String(val));
assertEquals(strElement, new String(val, StandardCharsets.UTF_8));

if ((i + 1) % 10000 == 0) {
logger.trace("Successfully read " + (i + 1) + " values");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.nio.charset.StandardCharsets;

import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.ReferenceManager;
import org.apache.arrow.memory.RootAllocator;
Expand Down Expand Up @@ -65,7 +67,7 @@ public void testTransferVariableWidth() {

VarCharVector v1 = new VarCharVector("v1", childAllocator1);
v1.allocateNew();
v1.setSafe(4094, "hello world".getBytes(), 0, 11);
v1.setSafe(4094, "hello world".getBytes(StandardCharsets.UTF_8), 0, 11);
v1.setValueCount(4001);

VarCharVector v2 = new VarCharVector("v2", childAllocator2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Period;
import java.util.Objects;

import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
Expand Down Expand Up @@ -1084,19 +1085,19 @@ public void testCopySafeArrow7837() {

vc1.setSafe(0, "1234567890".getBytes(StandardCharsets.UTF_8));
assertFalse(vc1.isNull(0));
assertEquals(vc1.getObject(0).toString(), "1234567890");
assertEquals("1234567890", Objects.requireNonNull(vc1.getObject(0)).toString());

vc2.copyFromSafe(0, 0, vc1);
assertFalse(vc2.isNull(0));
assertEquals(vc2.getObject(0).toString(), "1234567890");
assertEquals("1234567890", Objects.requireNonNull(vc2.getObject(0)).toString());

vc2.copyFromSafe(0, 5, vc1);
assertTrue(vc2.isNull(1));
assertTrue(vc2.isNull(2));
assertTrue(vc2.isNull(3));
assertTrue(vc2.isNull(4));
assertFalse(vc2.isNull(5));
assertEquals(vc2.getObject(5).toString(), "1234567890");
assertEquals("1234567890", Objects.requireNonNull(vc2.getObject(5)).toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public class TestDecimal256Vector {
static {
intValues = new long[60];
for (int i = 0; i < intValues.length / 2; i++) {
intValues[i] = 1 << i + 1;
intValues[2 * i] = -1 * (1 << i + 1);
intValues[i] = 1L << (i + 1);
intValues[2 * i] = -1L * (1 << (i + 1));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public class TestDecimalVector {
static {
intValues = new long[60];
for (int i = 0; i < intValues.length / 2; i++) {
intValues[i] = 1 << i + 1;
intValues[2 * i] = -1 * (1 << i + 1);
intValues[i] = 1L << (i + 1);
intValues[2 * i] = -1L * (1 << (i + 1));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,16 @@ public void testGetFieldTypeInfo() throws Exception {
assertEquals(vector.getField(), field);

// Union has 2 child vectors
assertEquals(vector.size(), 2);
assertEquals(2, vector.size());

// Check child field 0
VectorWithOrdinal intChild = vector.getChildVectorWithOrdinal("int");
assertEquals(intChild.ordinal, 0);
assertEquals(0, intChild.ordinal);
assertEquals(intChild.vector.getField(), children.get(0));

// Check child field 1
VectorWithOrdinal varcharChild = vector.getChildVectorWithOrdinal("varchar");
assertEquals(varcharChild.ordinal, 1);
assertEquals(1, varcharChild.ordinal);
assertEquals(varcharChild.vector.getField(), children.get(1));
}

Expand Down Expand Up @@ -458,8 +458,8 @@ public void testMultipleStructs() {
// register relative types
byte typeId1 = unionVector.registerNewTypeId(structVector1.getField());
byte typeId2 = unionVector.registerNewTypeId(structVector2.getField());
assertEquals(typeId1, 0);
assertEquals(typeId2, 1);
assertEquals(0, typeId1);
assertEquals(1, typeId2);

// add two struct vectors to union vector
unionVector.addVector(typeId1, structVector1);
Expand Down Expand Up @@ -519,8 +519,8 @@ public void testMultipleVarChars() {
byte typeId1 = unionVector.registerNewTypeId(childVector1.getField());
byte typeId2 = unionVector.registerNewTypeId(childVector2.getField());

assertEquals(typeId1, 0);
assertEquals(typeId2, 1);
assertEquals(0, typeId1);
assertEquals(1, typeId2);

while (unionVector.getValueCapacity() < 5) {
unionVector.reAlloc();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ public void testEncodeWithEncoderInstance() {
// now run through the decoder and verify we get the original back
try (ValueVector decoded = encoder.decode(encoded)) {
assertEquals(vector.getClass(), decoded.getClass());
assertEquals(vector.getValueCount(), (decoded).getValueCount());
assertEquals(vector.getValueCount(), decoded.getValueCount());
for (int i = 0; i < 5; i++) {
assertEquals(vector.getObject(i), ((VarCharVector) decoded).getObject(i));
}
Expand Down Expand Up @@ -591,7 +591,7 @@ public void testEncodeMultiVectors() {
// now run through the decoder and verify we get the original back
try (ValueVector decoded = encoder.decode(encoded)) {
assertEquals(vector1.getClass(), decoded.getClass());
assertEquals(vector1.getValueCount(), (decoded).getValueCount());
assertEquals(vector1.getValueCount(), decoded.getValueCount());
for (int i = 0; i < 5; i++) {
assertEquals(vector1.getObject(i), ((VarCharVector) decoded).getObject(i));
}
Expand All @@ -611,7 +611,7 @@ public void testEncodeMultiVectors() {
// now run through the decoder and verify we get the original back
try (ValueVector decoded = encoder.decode(encoded)) {
assertEquals(vector2.getClass(), decoded.getClass());
assertEquals(vector2.getValueCount(), (decoded).getValueCount());
assertEquals(vector2.getValueCount(), decoded.getValueCount());
for (int i = 0; i < 3; i++) {
assertEquals(vector2.getObject(i), ((VarCharVector) decoded).getObject(i));
}
Expand Down
Loading

0 comments on commit 56a95fd

Please sign in to comment.