[ 
https://issues.apache.org/jira/browse/ARROW-1780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16416412#comment-16416412
 ] 

ASF GitHub Bot commented on ARROW-1780:
---------------------------------------

laurentgo commented on a change in pull request #1759: ARROW-1780 - [WIP] JDBC 
Adapter to convert Relational Data objects to Arrow Data Format Vector Objects
URL: https://github.com/apache/arrow/pull/1759#discussion_r177593417
 
 

 ##########
 File path: 
java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/JdbcToArrowTestHelper.java
 ##########
 @@ -0,0 +1,250 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.adapter.jdbc;
+
+import java.math.BigDecimal;
+
+import org.apache.arrow.vector.BigIntVector;
+import org.apache.arrow.vector.BitVector;
+import org.apache.arrow.vector.DateMilliVector;
+import org.apache.arrow.vector.DecimalVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.Float4Vector;
+import org.apache.arrow.vector.Float8Vector;
+import org.apache.arrow.vector.IntVector;
+import org.apache.arrow.vector.SmallIntVector;
+import org.apache.arrow.vector.TimeMilliVector;
+import org.apache.arrow.vector.TimeStampVector;
+import org.apache.arrow.vector.TinyIntVector;
+import org.apache.arrow.vector.VarBinaryVector;
+import org.apache.arrow.vector.VarCharVector;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * This is a Helper class which has functionalities to read and assert the 
values from teh given FieldVector object
+ *
+ */
+public class JdbcToArrowTestHelper {
+
+    public static boolean assertIntVectorValues(FieldVector fx, int rowCount, 
int[] values) {
+        IntVector intVector = ((IntVector) fx);
+
+        assertEquals(rowCount, intVector.getValueCount());
+
+        for(int j = 0; j < intVector.getValueCount(); j++) {
+            if(!intVector.isNull(j)) {
+                assertEquals(values[j], intVector.get(j));
+            }
+        }
+        return true;
+    }
+
+    public static boolean assertBitBooleanVectorValues(FieldVector fx, int 
rowCount, int[] values){
+        BitVector bitVector = ((BitVector)fx);
+        assertEquals(rowCount, bitVector.getValueCount());
+        for(int j = 0; j < bitVector.getValueCount(); j++){
+            if(!bitVector.isNull(j)) {
+                assertEquals(values[j], bitVector.get(j));
+            }
+        }
+        return true;
+    }
+
+    public static boolean assertTinyIntVectorValues(FieldVector fx, int 
rowCount, int[] values){
+        TinyIntVector tinyIntVector = ((TinyIntVector)fx);
+
+        assertEquals(rowCount, tinyIntVector.getValueCount());
+
+        for(int j = 0; j < tinyIntVector.getValueCount(); j++){
+            if(!tinyIntVector.isNull(j)) {
+                assertEquals(values[j], tinyIntVector.get(j));
+            }
+        }
+        return true;
+    }
+
+    public static boolean assertSmallIntVectorValues(FieldVector fx, int 
rowCount, int[] values){
+        SmallIntVector smallIntVector = ((SmallIntVector)fx);
+
+        assertEquals(rowCount, smallIntVector.getValueCount());
+
+        for(int j = 0; j < smallIntVector.getValueCount(); j++){
+            if(!smallIntVector.isNull(j)){
+                assertEquals(values[j], smallIntVector.get(j));
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean assertBigIntVectorValues(FieldVector fx, int 
rowCount, int[] values){
+        BigIntVector bigIntVector = ((BigIntVector)fx);
+
+        assertEquals(rowCount, bigIntVector.getValueCount());
+
+        for(int j = 0; j < bigIntVector.getValueCount(); j++){
+            if(!bigIntVector.isNull(j)) {
+                assertEquals(values[j], bigIntVector.get(j));
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean assertDecimalVectorValues(FieldVector fx, int 
rowCount, BigDecimal[] values){
+        DecimalVector decimalVector = ((DecimalVector)fx);
+
+        assertEquals(rowCount, decimalVector.getValueCount());
+
+        for(int j = 0; j < decimalVector.getValueCount(); j++){
+            if(!decimalVector.isNull(j)){
+                assertEquals(values[j].doubleValue(), 
decimalVector.getObject(j).doubleValue(), 0);
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean assertFloat8VectorValues(FieldVector fx, int 
rowCount, double[] values){
+        Float8Vector float8Vector = ((Float8Vector)fx);
+
+        assertEquals(rowCount, float8Vector.getValueCount());
+
+        for(int j = 0; j < float8Vector.getValueCount(); j++){
+            if(!float8Vector.isNull(j)) {
+                assertEquals(values[j], float8Vector.get(j), 0.01);
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean assertFloat4VectorValues(FieldVector fx, int 
rowCount, float[] values){
+        Float4Vector float4Vector = ((Float4Vector)fx);
+
+        assertEquals(rowCount, float4Vector.getValueCount());
+
+        for(int j = 0; j < float4Vector.getValueCount(); j++){
+            if(!float4Vector.isNull(j)){
+                assertEquals(values[j], float4Vector.get(j), 0.01);
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean assertTimeVectorValues(FieldVector fx, int rowCount, 
long[] values){
+        TimeMilliVector timeMilliVector = ((TimeMilliVector)fx);
+
+        assertEquals(rowCount, timeMilliVector.getValueCount());
+
+        for(int j = 0; j < timeMilliVector.getValueCount(); j++){
+            if(!timeMilliVector.isNull(j)){
+                assertEquals(values[j], timeMilliVector.get(j));
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean assertDateVectorValues(FieldVector fx, int rowCount, 
long[] values){
+        DateMilliVector dateMilliVector = ((DateMilliVector)fx);
+
+        assertEquals(rowCount, dateMilliVector.getValueCount());
+
+        for(int j = 0; j < dateMilliVector.getValueCount(); j++){
+            if(!dateMilliVector.isNull(j)){
+                assertEquals(values[j], dateMilliVector.get(j));
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean assertTimeStampVectorValues(FieldVector fx, int 
rowCount, long[] values){
+        TimeStampVector timeStampVector = ((TimeStampVector)fx);
+
+        assertEquals(rowCount, timeStampVector.getValueCount());
+
+        for(int j = 0; j < timeStampVector.getValueCount(); j++){
+            if(!timeStampVector.isNull(j)){
+                assertEquals(values[j], timeStampVector.get(j));
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean assertVarBinaryVectorValues(FieldVector fx, int 
rowCount, byte[][] values){
+        VarBinaryVector varBinaryVector =((VarBinaryVector) fx);
+
+        assertEquals(rowCount, varBinaryVector.getValueCount());
+
+        for(int j = 0; j < varBinaryVector.getValueCount(); j++){
+            if(!varBinaryVector.isNull(j)){
+                assertEquals(hashArray(values[j]), 
hashArray(varBinaryVector.get(j)));
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean assertVarcharVectorValues(FieldVector fx, int 
rowCount, byte[][] values) {
+        VarCharVector varCharVector = ((VarCharVector)fx);
+
+        assertEquals(rowCount, varCharVector.getValueCount());
+
+        for(int j = 0; j < varCharVector.getValueCount(); j++){
+            if(!varCharVector.isNull(j)){
+                assertEquals(hashArray(values[j]), 
hashArray(varCharVector.get(j)));
+            }
+        }
+
+        return true;
+    }
+
+    public static long hashArray(byte[] data){
 
 Review comment:
   use `Arrays.hashCode(byte[] instead)`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> JDBC Adapter for Apache Arrow
> -----------------------------
>
>                 Key: ARROW-1780
>                 URL: https://issues.apache.org/jira/browse/ARROW-1780
>             Project: Apache Arrow
>          Issue Type: New Feature
>            Reporter: Atul Dambalkar
>            Assignee: Atul Dambalkar
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.10.0
>
>
> At a high level the JDBC Adapter will allow upstream apps to query RDBMS data 
> over JDBC and get the JDBC objects converted to Arrow objects/structures. The 
> upstream utility can then work with Arrow objects/structures with usual 
> performance benefits. The utility will be very much similar to C++ 
> implementation of "Convert a vector of row-wise data into an Arrow table" as 
> described here - 
> https://arrow.apache.org/docs/cpp/md_tutorials_row_wise_conversion.html
> The utility will read data from RDBMS and covert the data into Arrow 
> objects/structures. So from that perspective this will Read data from RDBMS, 
> If the utility can push Arrow objects to RDBMS is something need to be 
> discussed and will be out of scope for this utility for now. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to