This is an automated email from the ASF dual-hosted git repository.
wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new c06cbae ARROW-3383: [Gandiva][Java] Fix java build
c06cbae is described below
commit c06cbaeaa4d56f6e1770da2eb8f8b3fe3046dc63
Author: Pindikura Ravindra <[email protected]>
AuthorDate: Wed Oct 10 09:39:48 2018 -0400
ARROW-3383: [Gandiva][Java] Fix java build
- set arrow as parent project, use same style as arrow java
- fix lots of checkctyle violations
- add java build/tests to CI
Author: Pindikura Ravindra <[email protected]>
Closes #2720 from pravindra/arrow-3383 and squashes the following commits:
d191219f0 <Pindikura Ravindra> ARROW-3383: fix java build
---
.travis.yml | 11 +-
...ipt_gandiva.sh => travis_script_gandiva_cpp.sh} | 0
...cript_java.sh => travis_script_gandiva_java.sh} | 13 +-
ci/travis_script_java.sh | 1 -
java/gandiva/dev/checkstyle/checkstyle.license | 17 --
java/gandiva/dev/checkstyle/checkstyle.xml | 259 ------------------
java/gandiva/dev/checkstyle/suppressions.xml | 33 ---
java/gandiva/pom.xml | 79 ++----
.../gandiva/evaluator/ExpressionRegistry.java | 10 +-
.../org/apache/arrow/gandiva/evaluator/Filter.java | 51 ++--
.../arrow/gandiva/evaluator/FunctionSignature.java | 12 +-
.../apache/arrow/gandiva/evaluator/JniWrapper.java | 12 +-
.../apache/arrow/gandiva/evaluator/Projector.java | 7 +-
.../arrow/gandiva/evaluator/SelectionVector.java | 9 +-
.../gandiva/evaluator/SelectionVectorInt16.java | 3 +-
.../gandiva/evaluator/SelectionVectorInt32.java | 3 +-
.../apache/arrow/gandiva/expression/AndNode.java | 4 +-
.../arrow/gandiva/expression/ArrowTypeHelper.java | 14 +-
.../arrow/gandiva/expression/BinaryNode.java | 4 +-
.../arrow/gandiva/expression/FunctionNode.java | 4 +-
.../apache/arrow/gandiva/expression/OrNode.java | 4 +-
.../arrow/gandiva/expression/StringNode.java | 4 +-
.../arrow/gandiva/expression/TreeBuilder.java | 6 +-
.../arrow/gandiva/evaluator/BaseEvaluatorTest.java | 77 +++---
.../gandiva/evaluator/ExpressionRegistryTest.java | 8 +-
.../apache/arrow/gandiva/evaluator/FilterTest.java | 34 +--
.../gandiva/evaluator/MicroBenchmarkTest.java | 57 ++--
.../arrow/gandiva/evaluator/ProjectorTest.java | 298 +++++++++++----------
.../gandiva/expression/ArrowTypeHelperTest.java | 11 +-
.../arrow/gandiva/expression/TreeBuilderTest.java | 115 ++++++--
java/gandiva/src/test/resources/logback.xml | 19 ++
java/pom.xml | 15 ++
32 files changed, 491 insertions(+), 703 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 24fde86..2115218 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -93,21 +93,21 @@ matrix:
- export PLASMA_VALGRIND=1
- $TRAVIS_BUILD_DIR/ci/travis_script_python.sh 3.6
- $TRAVIS_BUILD_DIR/ci/travis_upload_cpp_coverage.sh
- # Gandiva C++ w/ gcc 4.9
+ # Gandiva C++ w/ gcc 4.9 and Java
- compiler: gcc
language: cpp
os: linux
jdk: openjdk8
env:
+ - ARROW_TRAVIS_GANDIVA=1
- ARROW_TRAVIS_USE_TOOLCHAIN=1
- ARROW_TRAVIS_VALGRIND=1
- ARROW_TRAVIS_CLANG_FORMAT=1
- ARROW_BUILD_WARNING_LEVEL=CHECKIN
- - ARROW_TRAVIS_GANDIVA=1
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
before_script:
- # Run if something changed in CPP.
- - if [ $ARROW_CI_CPP_AFFECTED != "1" ]; then exit; fi
+ # Run if something changed in CPP or Java.
+ - if [ $ARROW_CI_CPP_AFFECTED != "1" && $ARROW_CI_JAVA_AFFECTED != "1" ];
then exit; fi
- $TRAVIS_BUILD_DIR/ci/travis_install_linux.sh
- $TRAVIS_BUILD_DIR/ci/travis_install_clang_tools.sh
- $TRAVIS_BUILD_DIR/ci/travis_lint.sh
@@ -115,7 +115,8 @@ matrix:
- git submodule update --init
- $TRAVIS_BUILD_DIR/ci/travis_before_script_cpp.sh --only-library
script:
- - $TRAVIS_BUILD_DIR/ci/travis_script_gandiva.sh
+ - $TRAVIS_BUILD_DIR/ci/travis_script_gandiva_cpp.sh
+ - $TRAVIS_BUILD_DIR/ci/travis_script_gandiva_java.sh
# [OS X] C++ & Python w/ XCode 6.4
- compiler: clang
language: cpp
diff --git a/ci/travis_script_gandiva.sh b/ci/travis_script_gandiva_cpp.sh
similarity index 100%
rename from ci/travis_script_gandiva.sh
rename to ci/travis_script_gandiva_cpp.sh
diff --git a/ci/travis_script_java.sh b/ci/travis_script_gandiva_java.sh
similarity index 79%
copy from ci/travis_script_java.sh
copy to ci/travis_script_gandiva_java.sh
index 9553dd5..8c26e5c 100755
--- a/ci/travis_script_java.sh
+++ b/ci/travis_script_gandiva_java.sh
@@ -19,16 +19,17 @@
set -e
+source $TRAVIS_BUILD_DIR/ci/travis_env_common.sh
JAVA_DIR=${TRAVIS_BUILD_DIR}/java
pushd $JAVA_DIR
export MAVEN_OPTS="$MAVEN_OPTS -Dorg.slf4j.simpleLogger.defaultLogLevel=warn"
-if [ $ARROW_TRAVIS_JAVA_BUILD_ONLY == "1" ]; then
- # Save time and make build less verbose by skipping tests and style checks
- mvn -DskipTests=true -Dcheckstyle.skip=true -B install
-else
- mvn -B install
-fi
+
+# build with gandiva profile
+mvn -P gandiva -B install -DskipTests -Dgandiva.cpp.build.dir=$CPP_BUILD_DIR
+
+# run gandiva tests
+mvn test -P gandiva -pl gandiva -Dgandiva.cpp.build.dir=$CPP_BUILD_DIR
popd
diff --git a/ci/travis_script_java.sh b/ci/travis_script_java.sh
index 9553dd5..8a71fdc 100755
--- a/ci/travis_script_java.sh
+++ b/ci/travis_script_java.sh
@@ -20,7 +20,6 @@
set -e
JAVA_DIR=${TRAVIS_BUILD_DIR}/java
-
pushd $JAVA_DIR
export MAVEN_OPTS="$MAVEN_OPTS -Dorg.slf4j.simpleLogger.defaultLogLevel=warn"
diff --git a/java/gandiva/dev/checkstyle/checkstyle.license
b/java/gandiva/dev/checkstyle/checkstyle.license
deleted file mode 100644
index 8cf41b0..0000000
--- a/java/gandiva/dev/checkstyle/checkstyle.license
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * 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.
- */
\ No newline at end of file
diff --git a/java/gandiva/dev/checkstyle/checkstyle.xml
b/java/gandiva/dev/checkstyle/checkstyle.xml
deleted file mode 100644
index c081d95..0000000
--- a/java/gandiva/dev/checkstyle/checkstyle.xml
+++ /dev/null
@@ -1,259 +0,0 @@
-<!--
- ~ 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.
- -->
-
-<!DOCTYPE module PUBLIC
- "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
- "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
-
-<!--
- Checkstyle configuration that checks the Google coding conventions from
Google Java Style
- that can be found at https://google.github.io/styleguide/javaguide.html.
-
- Checkstyle is very configurable. Be sure to read the documentation at
- http://checkstyle.sf.net (or in your downloaded distribution).
-
- To completely disable a check, just comment it out or delete it from the
file.
-
- Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
- -->
-
-<module name="Checker">
- <property name="charset" value="UTF-8"/>
-
- <property name="severity" value="warning"/>
-
- <property name="fileExtensions" value="java, properties, xml"/>
-
- <!-- Arrow specific modules -->
-
- <module name="Header">
- <property name="headerFile" value="${checkstyle.header.file}"/>
- </module>
-
- <module name="SuppressionFilter">
- <property name="file" value="${checkstyle.suppressions.file}"/>
- </module>
-
- <module name="NewlineAtEndOfFile"/>
-
- <!--
- If you wish to turn off checking for a section of code, you can put a
comment in the source
- before and after the section, with the following syntax:
- // checkstyle:off no.XXX (such as checkstyle.off: NoFinalizer)
- ... // stuff that breaks the styles
- // checkstyle:on
- -->
- <module name="SuppressionCommentFilter">
- <property name="offCommentFormat" value="checkstyle.off\: ([\w\|]+)"/>
- <property name="onCommentFormat" value="checkstyle.on\: ([\w\|]+)"/>
- <property name="checkFormat" value="$1"/>
- </module>
-
- <!-- Google style modules -->
-
- <!-- Checks for whitespace -->
- <!-- See http://checkstyle.sf.net/config_whitespace.html -->
- <module name="FileTabCharacter">
- <property name="eachLine" value="true"/>
- </module>
-
- <module name="TreeWalker">
- <module name="OuterTypeFilename"/>
- <module name="IllegalTokenText">
- <property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
- <property name="format"
-
value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
- <property name="message" value="Avoid using corresponding octal or
Unicode escape."/>
- </module>
- <module name="AvoidEscapedUnicodeCharacters">
- <property name="allowEscapesForControlCharacters" value="true"/>
- <property name="allowByTailComment" value="true"/>
- <property name="allowNonPrintableEscapes" value="true"/>
- </module>
- <module name="LineLength">
- <property name="max" value="100"/>
- <property name="ignorePattern" value="^package.*|^import.*|a
href|href|http://|https://|ftp://"/>
- </module>
- <module name="AvoidStarImport"/>
- <module name="OneTopLevelClass"/>
- <module name="NoLineWrap"/>
- <module name="EmptyBlock">
- <property name="option" value="TEXT"/>
- <property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY,
LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
- </module>
- <module name="NeedBraces"/>
- <module name="LeftCurly">
- <property name="maxLineLength" value="100"/>
- </module>
- <module name="RightCurly"/>
- <module name="RightCurly">
- <property name="option" value="alone"/>
- <property name="tokens"
- value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR,
LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
- </module>
- <module name="WhitespaceAround">
- <property name="allowEmptyConstructors" value="true"/>
- <property name="allowEmptyMethods" value="true"/>
- <property name="allowEmptyTypes" value="true"/>
- <property name="allowEmptyLoops" value="true"/>
- <message key="ws.notFollowed"
- value="WhitespaceAround: ''{0}'' is not followed by
whitespace. Empty blocks may only be represented as '{}' when not part of a
multi-block statement (4.1.3)"/>
- <message key="ws.notPreceded"
- value="WhitespaceAround: ''{0}'' is not preceded with
whitespace."/>
- </module>
- <module name="OneStatementPerLine"/>
- <module name="MultipleVariableDeclarations"/>
- <module name="ArrayTypeStyle"/>
- <module name="MissingSwitchDefault"/>
- <module name="FallThrough"/>
- <module name="UpperEll"/>
- <module name="ModifierOrder"/>
- <module name="EmptyLineSeparator">
- <property name="allowNoEmptyLineBetweenFields" value="true"/>
- </module>
- <module name="SeparatorWrap">
- <property name="tokens" value="DOT"/>
- <property name="option" value="nl"/>
- </module>
- <module name="SeparatorWrap">
- <property name="tokens" value="COMMA"/>
- <property name="option" value="EOL"/>
- </module>
- <module name="PackageName">
- <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
- <message key="name.invalidPattern"
- value="Package name ''{0}'' must match pattern ''{1}''."/>
- </module>
- <module name="TypeName">
- <message key="name.invalidPattern"
- value="Type name ''{0}'' must match pattern ''{1}''."/>
- </module>
- <module name="MemberName">
- <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
- <message key="name.invalidPattern"
- value="Member name ''{0}'' must match pattern ''{1}''."/>
- </module>
- <module name="ParameterName">
- <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
- <message key="name.invalidPattern"
- value="Parameter name ''{0}'' must match pattern
''{1}''."/>
- </module>
- <module name="CatchParameterName">
- <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
- <message key="name.invalidPattern"
- value="Catch parameter name ''{0}'' must match pattern
''{1}''."/>
- </module>
- <module name="LocalVariableName">
- <property name="tokens" value="VARIABLE_DEF"/>
- <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
- <property name="allowOneCharVarInForLoop" value="true"/>
- <message key="name.invalidPattern"
- value="Local variable name ''{0}'' must match pattern
''{1}''."/>
- </module>
- <module name="ClassTypeParameterName">
- <property name="format"
value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
- <message key="name.invalidPattern"
- value="Class type name ''{0}'' must match pattern
''{1}''."/>
- </module>
- <module name="MethodTypeParameterName">
- <property name="format"
value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
- <message key="name.invalidPattern"
- value="Method type name ''{0}'' must match pattern
''{1}''."/>
- </module>
- <module name="InterfaceTypeParameterName">
- <property name="format"
value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
- <message key="name.invalidPattern"
- value="Interface type name ''{0}'' must match pattern
''{1}''."/>
- </module>
- <module name="NoFinalizer"/>
- <module name="GenericWhitespace">
- <message key="ws.followed"
- value="GenericWhitespace ''{0}'' is followed by
whitespace."/>
- <message key="ws.preceded"
- value="GenericWhitespace ''{0}'' is preceded with
whitespace."/>
- <message key="ws.illegalFollow"
- value="GenericWhitespace ''{0}'' should followed by
whitespace."/>
- <message key="ws.notPreceded"
- value="GenericWhitespace ''{0}'' is not preceded with
whitespace."/>
- </module>
- <module name="Indentation">
- <property name="basicOffset" value="2"/>
- <property name="braceAdjustment" value="0"/>
- <property name="caseIndent" value="2"/>
- <property name="throwsIndent" value="4"/>
- <property name="lineWrappingIndentation" value="4"/>
- <property name="arrayInitIndent" value="2"/>
- </module>
- <module name="AbbreviationAsWordInName">
- <property name="ignoreFinal" value="false"/>
- <property name="allowedAbbreviationLength" value="1"/>
- </module>
- <module name="OverloadMethodsDeclarationOrder"/>
- <module name="VariableDeclarationUsageDistance"/>
- <module name="CustomImportOrder">
- <property name="specialImportsRegExp" value="com.google"/>
- <property name="sortImportsInGroupAlphabetically" value="true"/>
- <property name="customImportOrderRules"
-
value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
- </module>
- <module name="MethodParamPad"/>
- <module name="OperatorWrap">
- <property name="option" value="NL"/>
- <property name="tokens"
- value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND,
LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR,
STAR "/>
- </module>
- <module name="AnnotationLocation">
- <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
METHOD_DEF, CTOR_DEF"/>
- </module>
- <module name="AnnotationLocation">
- <property name="tokens" value="VARIABLE_DEF"/>
- <property name="allowSamelineMultipleAnnotations" value="true"/>
- </module>
- <module name="NonEmptyAtclauseDescription"/>
- <module name="JavadocTagContinuationIndentation"/>
- <module name="SummaryJavadoc">
- <property name="forbiddenSummaryFragments"
- value="^@return the *|^This method returns |^A [{]@code
[a-zA-Z0-9]+[}]( is a )"/>
- </module>
- <module name="JavadocParagraph"/>
- <module name="AtclauseOrder">
- <property name="tagOrder" value="@param, @return, @throws,
@deprecated"/>
- <property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
- </module>
- <module name="JavadocMethod">
- <property name="scope" value="public"/>
- <property name="allowMissingParamTags" value="true"/>
- <property name="allowMissingThrowsTags" value="true"/>
- <property name="allowMissingReturnTag" value="true"/>
- <property name="minLineCount" value="2"/>
- <property name="allowedAnnotations" value="Override, Test"/>
- <property name="allowThrowsTagsForSubclasses" value="true"/>
- </module>
- <module name="MethodName">
- <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
- <message key="name.invalidPattern"
- value="Method name ''{0}'' must match pattern ''{1}''."/>
- </module>
- <module name="SingleLineJavadoc">
- <property name="ignoreInlineTags" value="false"/>
- </module>
- <module name="EmptyCatchBlock">
- <property name="exceptionVariableName" value="expected"/>
- </module>
- <module name="CommentsIndentation"/>
- </module>
-</module>
diff --git a/java/gandiva/dev/checkstyle/suppressions.xml
b/java/gandiva/dev/checkstyle/suppressions.xml
deleted file mode 100644
index 6fd92fb..0000000
--- a/java/gandiva/dev/checkstyle/suppressions.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
- ~ 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.
- -->
-
-<!DOCTYPE suppressions PUBLIC
- "-//Puppy Crawl//DTD Suppressions 1.1//EN"
- "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
-
-<suppressions>
- <suppress checks="JavadocPackage" files=".*[\\/]src[\\/]test[\\/].*"/>
- <suppress checks="JavadocPackage" files=".*[\\/]maven-archetypes[\\/].*"/>
- <suppress checks="JavadocPackage" files=".*[\\/]examples[\\/].*"/>
-
- <!-- suppress all checks in the generated directories -->
- <suppress checks=".*" files=".+[\\/]generated[\\/].+\.java"/>
- <suppress checks=".*" files=".+[\\/]generated-sources[\\/].+\.java"/>
- <suppress checks=".*" files=".+[\\/]generated-test-sources[\\/].+\.java"/>
-
- <suppress checks=".*" files=".*\.properties"/>
-</suppressions>
diff --git a/java/gandiva/pom.xml b/java/gandiva/pom.xml
index 0fd8d01..ab88351 100644
--- a/java/gandiva/pom.xml
+++ b/java/gandiva/pom.xml
@@ -13,36 +13,34 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.arrow</groupId>
+ <artifactId>arrow-java-root</artifactId>
+ <version>0.12.0-SNAPSHOT</version>
+ </parent>
<groupId>org.apache.arrow.gandiva</groupId>
- <artifactId>gandiva-java</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <artifactId>arrow-gandiva</artifactId>
<packaging>jar</packaging>
- <name>Gandiva Java Project</name>
+ <name>Arrow Gandiva</name>
<properties>
- <arrow.version>0.9.0</arrow.version>
- <protobuf.version>2.5.0</protobuf.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
+ <protobuf.version>2.5.0</protobuf.version>
<dep.guava.version>18.0</dep.guava.version>
<checkstyle.failOnViolation>true</checkstyle.failOnViolation>
- <gandiva.cpp.build.dir>../cpp/debug</gandiva.cpp.build.dir>
+ <gandiva.cpp.build.dir>../../cpp/debug</gandiva.cpp.build.dir>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.arrow</groupId>
- <artifactId>arrow-format</artifactId>
- <version>${arrow.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.arrow</groupId>
<artifactId>arrow-memory</artifactId>
- <version>${arrow.version}</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-vector</artifactId>
- <version>${arrow.version}</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
@@ -60,6 +58,16 @@
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ <version>2.10</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
<profile>
@@ -158,51 +166,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.17</version>
- <dependencies>
- <dependency>
- <groupId>com.puppycrawl.tools</groupId>
- <artifactId>checkstyle</artifactId>
- <version>6.19</version>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>${dep.guava.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>1.7.5</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>validate</id>
- <phase>validate</phase>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
-
<configLocation>dev/checkstyle/checkstyle.xml</configLocation>
-
<headerLocation>dev/checkstyle/checkstyle.license</headerLocation>
-
<suppressionsLocation>dev/checkstyle/suppressions.xml</suppressionsLocation>
- <encoding>UTF-8</encoding>
- <consoleOutput>true</consoleOutput>
- <failsOnError>${checkstyle.failOnViolation}</failsOnError>
-
<failOnViolation>${checkstyle.failOnViolation}</failOnViolation>
- <violationSeverity>warning</violationSeverity>
- <format>xml</format>
- <format>html</format>
-
<outputFile>${project.build.directory}/test/checkstyle-errors.xml</outputFile>
- <linkXRef>false</linkXRef>
- </configuration>
- </plugin>
</plugins>
</build>
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistry.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistry.java
index ad473ee..abaf8ff 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistry.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistry.java
@@ -18,9 +18,8 @@
package org.apache.arrow.gandiva.evaluator;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.protobuf.InvalidProtocolBufferException;
+import java.util.List;
+import java.util.Set;
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.gandiva.ipc.GandivaTypes;
@@ -33,8 +32,9 @@ import org.apache.arrow.vector.types.FloatingPointPrecision;
import org.apache.arrow.vector.types.TimeUnit;
import org.apache.arrow.vector.types.pojo.ArrowType;
-import java.util.List;
-import java.util.Set;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.protobuf.InvalidProtocolBufferException;
/**
* Used to get the functions and data types supported by
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/Filter.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/Filter.java
index 02de6e5..e401f95 100644
--- a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/Filter.java
+++ b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/Filter.java
@@ -18,7 +18,8 @@
package org.apache.arrow.gandiva.evaluator;
-import io.netty.buffer.ArrowBuf;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.arrow.gandiva.exceptions.EvaluatorClosedException;
import org.apache.arrow.gandiva.exceptions.GandivaException;
@@ -31,18 +32,16 @@ import org.apache.arrow.vector.types.pojo.Schema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
+import io.netty.buffer.ArrowBuf;
/**
* This class provides a mechanism to filter a RecordBatch by evaluating a
condition expression.
- * Follow these steps to use this class:
- * 1) Use the static method make() to create an instance of this class that
evaluates a
- * condition.
- * 2) Invoke the method evaluate() to evaluate the filter against a RecordBatch
- * 3) Invoke close() to release resources
+ * Follow these steps to use this class: 1) Use the static method make() to
create an instance of
+ * this class that evaluates a condition. 2) Invoke the method evaluate() to
evaluate the filter
+ * against a RecordBatch 3) Invoke close() to release resources
*/
public class Filter {
+
private static final Logger logger = LoggerFactory.getLogger(Filter.class);
private final long moduleId;
@@ -56,12 +55,11 @@ public class Filter {
}
/**
- * Invoke this function to generate LLVM code to evaluate the condition
expression.
- * Invoke Filter::Evaluate() against a RecordBatch to evaluate the filter on
- * this record batch
+ * Invoke this function to generate LLVM code to evaluate the condition
expression. Invoke
+ * Filter::Evaluate() against a RecordBatch to evaluate the filter on this
record batch
*
- * @param schema Table schema. The field names in the schema should match
the fields used
- * to create the TreeNodes
+ * @param schema Table schema. The field names in the schema should match
the fields used to
+ * create the TreeNodes
* @param condition condition to be evaluated against data
* @return A native filter object that can be used to invoke on a RecordBatch
*/
@@ -70,13 +68,12 @@ public class Filter {
}
/**
- * Invoke this function to generate LLVM code to evaluate the condition
expression.
- * Invoke Filter::Evaluate() against a RecordBatch to evaluate the filter on
- * this record batch
+ * Invoke this function to generate LLVM code to evaluate the condition
expression. Invoke
+ * Filter::Evaluate() against a RecordBatch to evaluate the filter on this
record batch
*
- * @param schema Table schema. The field names in the schema should
match the fields used
- * to create the TreeNodes
- * @param condition condition to be evaluated against data
+ * @param schema Table schema. The field names in the schema should match
the fields used to
+ * create the TreeNodes
+ * @param condition condition to be evaluated against data
* @param configurationId Custom configuration created through config
builder.
* @return A native evaluator object that can be used to invoke these
projections on a RecordBatch
*/
@@ -96,7 +93,7 @@ public class Filter {
* Invoke this function to evaluate a filter against a recordBatch.
*
* @param recordBatch Record batch including the data
- * @param selectionVector Result of applying the filter on the data
+ * @param selectionVector Result of applying the filter on the data
*/
public void evaluate(ArrowRecordBatch recordBatch, SelectionVector
selectionVector)
throws GandivaException {
@@ -105,15 +102,15 @@ public class Filter {
}
/**
- * Invoke this function to evaluate filter against a set of arrow buffers.
- * (this is an optimised version that skips taking references).
+ * Invoke this function to evaluate filter against a set of arrow buffers.
(this is an optimised
+ * version that skips taking references).
*
* @param numRows number of rows.
* @param buffers List of input arrow buffers
- * @param selectionVector Result of applying the filter on the data
+ * @param selectionVector Result of applying the filter on the data
*/
public void evaluate(int numRows, List<ArrowBuf> buffers,
- SelectionVector selectionVector) throws
GandivaException {
+ SelectionVector selectionVector) throws GandivaException {
List<ArrowBuffer> buffersLayout = new ArrayList<>();
long offset = 0;
for (ArrowBuf arrowBuf : buffers) {
@@ -125,13 +122,13 @@ public class Filter {
}
private void evaluate(int numRows, List<ArrowBuf> buffers, List<ArrowBuffer>
buffersLayout,
- SelectionVector selectionVector) throws
GandivaException {
+ SelectionVector selectionVector) throws GandivaException {
if (this.closed) {
throw new EvaluatorClosedException();
}
if (selectionVector.getMaxRecords() < numRows) {
- logger.error("selectionVector has capacity for " +
selectionVector.getMaxRecords()
- + " rows, minimum required " + numRows);
+ logger.error("selectionVector has capacity for " +
selectionVector.getMaxRecords() +
+ " rows, minimum required " + numRows);
throw new GandivaException("SelectionVector too small");
}
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/FunctionSignature.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/FunctionSignature.java
index 6414a5d..baa4495 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/FunctionSignature.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/FunctionSignature.java
@@ -18,12 +18,12 @@
package org.apache.arrow.gandiva.evaluator;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
+import java.util.List;
import org.apache.arrow.vector.types.pojo.ArrowType;
-import java.util.List;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
/**
* POJO to define a function signature.
@@ -70,9 +70,9 @@ public class FunctionSignature {
return false;
}
final FunctionSignature other = (FunctionSignature) signature;
- return Objects.equal(this.name, other.name)
- && Objects.equal(this.returnType, other.returnType)
- && Objects.equal(this.paramTypes, other.paramTypes);
+ return Objects.equal(this.name, other.name) &&
+ Objects.equal(this.returnType, other.returnType) &&
+ Objects.equal(this.paramTypes, other.paramTypes);
}
@Override
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniWrapper.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniWrapper.java
index 9a8a106..bc75d9e 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniWrapper.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniWrapper.java
@@ -20,14 +20,14 @@ package org.apache.arrow.gandiva.evaluator;
import static java.util.UUID.randomUUID;
-import org.apache.arrow.gandiva.exceptions.GandivaException;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
+import org.apache.arrow.gandiva.exceptions.GandivaException;
+
/**
* This class is implemented in JNI. This provides the Java interface
* to invoke functions in JNI
@@ -101,12 +101,12 @@ class JniWrapper {
final String randomizeFileName = libraryToLoad + randomUUID();
final File temp = new File(tmpDir, randomizeFileName);
if (temp.exists() && !temp.delete()) {
- throw new GandivaException("File: " + temp.getAbsolutePath()
- + " already exists and cannot be removed.");
+ throw new GandivaException("File: " + temp.getAbsolutePath() +
+ " already exists and cannot be removed.");
}
if (!temp.createNewFile()) {
- throw new GandivaException("File: " + temp.getAbsolutePath()
- + " could not be created.");
+ throw new GandivaException("File: " + temp.getAbsolutePath() +
+ " could not be created.");
}
temp.deleteOnExit();
return temp;
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/Projector.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/Projector.java
index 246f71c..cde0071 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/Projector.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/Projector.java
@@ -18,7 +18,9 @@
package org.apache.arrow.gandiva.evaluator;
-import io.netty.buffer.ArrowBuf;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.arrow.gandiva.exceptions.EvaluatorClosedException;
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.gandiva.exceptions.UnsupportedTypeException;
@@ -31,8 +33,7 @@ import org.apache.arrow.vector.ipc.message.ArrowBuffer;
import org.apache.arrow.vector.ipc.message.ArrowRecordBatch;
import org.apache.arrow.vector.types.pojo.Schema;
-import java.util.ArrayList;
-import java.util.List;
+import io.netty.buffer.ArrowBuf;
/**
* This class provides a mechanism to evaluate a set of expressions against a
RecordBatch.
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVector.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVector.java
index 52390d3..da9316d 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVector.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVector.java
@@ -18,9 +18,10 @@
package org.apache.arrow.gandiva.evaluator;
-import io.netty.buffer.ArrowBuf;
import org.apache.arrow.gandiva.ipc.GandivaTypes.SelectionVectorType;
+import io.netty.buffer.ArrowBuf;
+
/**
* A selection vector contains the indexes of "selected" records in a row
batch. It is backed by an
* arrow buffer.
@@ -57,9 +58,9 @@ public abstract class SelectionVector {
*/
final void setRecordCount(int recordCount) {
if (recordCount * getRecordSize() > buffer.capacity()) {
- throw new IllegalArgumentException("recordCount " + recordCount
- + " of size " + getRecordSize()
- + " exceeds buffer capacity " + buffer.capacity());
+ throw new IllegalArgumentException("recordCount " + recordCount +
+ " of size " + getRecordSize() +
+ " exceeds buffer capacity " + buffer.capacity());
}
this.recordCount = recordCount;
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVectorInt16.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVectorInt16.java
index 0341cc8..3826702 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVectorInt16.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVectorInt16.java
@@ -18,9 +18,10 @@
package org.apache.arrow.gandiva.evaluator;
-import io.netty.buffer.ArrowBuf;
import org.apache.arrow.gandiva.ipc.GandivaTypes.SelectionVectorType;
+import io.netty.buffer.ArrowBuf;
+
/*
* Selection vector with records of arrow type INT16.
*/
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVectorInt32.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVectorInt32.java
index c2cf57c..0e8a1c4 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVectorInt32.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/SelectionVectorInt32.java
@@ -18,9 +18,10 @@
package org.apache.arrow.gandiva.evaluator;
-import io.netty.buffer.ArrowBuf;
import org.apache.arrow.gandiva.ipc.GandivaTypes.SelectionVectorType;
+import io.netty.buffer.ArrowBuf;
+
/*
* Selection vector with records of arrow type INT32.
*/
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/AndNode.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/AndNode.java
index 304cf20..1dc5dc4 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/AndNode.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/AndNode.java
@@ -18,11 +18,11 @@
package org.apache.arrow.gandiva.expression;
+import java.util.List;
+
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.gandiva.ipc.GandivaTypes;
-import java.util.List;
-
class AndNode implements TreeNode {
private final List<TreeNode> children;
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/ArrowTypeHelper.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/ArrowTypeHelper.java
index de2dc20..51104e8 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/ArrowTypeHelper.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/ArrowTypeHelper.java
@@ -34,9 +34,8 @@ public class ArrowTypeHelper {
static final int WIDTH_32 = 32;
static final int WIDTH_64 = 64;
- private static void initArrowTypeInt(ArrowType.Int intType,
- GandivaTypes.ExtGandivaType.Builder
builder)
- throws GandivaException {
+ private static void initArrowTypeInt(
+ ArrowType.Int intType, GandivaTypes.ExtGandivaType.Builder builder)
throws GandivaException {
int width = intType.getBitWidth();
if (intType.getIsSigned()) {
@@ -87,9 +86,9 @@ public class ArrowTypeHelper {
}
}
- private static void initArrowTypeFloat(ArrowType.FloatingPoint floatType,
- GandivaTypes.ExtGandivaType.Builder
builder)
- throws GandivaException {
+ private static void initArrowTypeFloat(
+ ArrowType.FloatingPoint floatType, GandivaTypes.ExtGandivaType.Builder
builder)
+ throws GandivaException {
switch (floatType.getPrecision()) {
case HALF: {
builder.setType(GandivaTypes.GandivaType.HALF_FLOAT);
@@ -197,11 +196,12 @@ public class ArrowTypeHelper {
/**
* Converts an arrow type into a protobuf.
+ *
* @param arrowType Arrow type to be converted
* @return Protobuf representing the arrow type
*/
public static GandivaTypes.ExtGandivaType arrowTypeToProtobuf(ArrowType
arrowType)
- throws GandivaException {
+ throws GandivaException {
GandivaTypes.ExtGandivaType.Builder builder =
GandivaTypes.ExtGandivaType.newBuilder();
byte typeId = arrowType.getTypeID().getFlatbufID();
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/BinaryNode.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/BinaryNode.java
index 0725ab2..5da9a31 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/BinaryNode.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/BinaryNode.java
@@ -18,11 +18,11 @@
package org.apache.arrow.gandiva.expression;
-import com.google.protobuf.ByteString;
-
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.gandiva.ipc.GandivaTypes;
+import com.google.protobuf.ByteString;
+
/**
* Used to represent expression tree nodes representing binary constants.
*/
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/FunctionNode.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/FunctionNode.java
index c208515..9f0d6a9 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/FunctionNode.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/FunctionNode.java
@@ -18,12 +18,12 @@
package org.apache.arrow.gandiva.expression;
+import java.util.List;
+
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.gandiva.ipc.GandivaTypes;
import org.apache.arrow.vector.types.pojo.ArrowType;
-import java.util.List;
-
class FunctionNode implements TreeNode {
private final String function;
private final List<TreeNode> children;
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/OrNode.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/OrNode.java
index aed12b5..f684188 100644
--- a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/OrNode.java
+++ b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/OrNode.java
@@ -18,11 +18,11 @@
package org.apache.arrow.gandiva.expression;
+import java.util.List;
+
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.gandiva.ipc.GandivaTypes;
-import java.util.List;
-
class OrNode implements TreeNode {
private final List<TreeNode> children;
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/StringNode.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/StringNode.java
index 3281674..2a754f4 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/StringNode.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/StringNode.java
@@ -18,12 +18,12 @@
package org.apache.arrow.gandiva.expression;
-import com.google.protobuf.ByteString;
+import java.nio.charset.Charset;
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.gandiva.ipc.GandivaTypes;
-import java.nio.charset.Charset;
+import com.google.protobuf.ByteString;
/**
* Used to represent expression tree nodes representing utf8 constants.
diff --git
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/TreeBuilder.java
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/TreeBuilder.java
index 8f1fbae..aec6808 100644
---
a/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/TreeBuilder.java
+++
b/java/gandiva/src/main/java/org/apache/arrow/gandiva/expression/TreeBuilder.java
@@ -18,12 +18,12 @@
package org.apache.arrow.gandiva.expression;
-import org.apache.arrow.vector.types.pojo.ArrowType;
-import org.apache.arrow.vector.types.pojo.Field;
-
import java.util.ArrayList;
import java.util.List;
+import org.apache.arrow.vector.types.pojo.ArrowType;
+import org.apache.arrow.vector.types.pojo.Field;
+
public class TreeBuilder {
/**
* Helper functions to create literal constants.
diff --git
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/BaseEvaluatorTest.java
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/BaseEvaluatorTest.java
index 33f7649..cdf601a 100644
---
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/BaseEvaluatorTest.java
+++
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/BaseEvaluatorTest.java
@@ -18,7 +18,11 @@
package org.apache.arrow.gandiva.evaluator;
-import io.netty.buffer.ArrowBuf;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.gandiva.expression.Condition;
import org.apache.arrow.gandiva.expression.ExpressionTree;
@@ -35,18 +39,17 @@ import org.joda.time.Instant;
import org.junit.After;
import org.junit.Before;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
+import io.netty.buffer.ArrowBuf;
interface BaseEvaluator {
+
void evaluate(ArrowRecordBatch recordBatch, BufferAllocator allocator)
throws GandivaException;
long getElapsedMillis();
}
class ProjectEvaluator implements BaseEvaluator {
+
private Projector projector;
private DataAndVectorGenerator generator;
private int numExprs;
@@ -55,9 +58,9 @@ class ProjectEvaluator implements BaseEvaluator {
private List<ValueVector> outputVectors = new ArrayList<>();
public ProjectEvaluator(Projector projector,
- DataAndVectorGenerator generator,
- int numExprs,
- int maxRowsInBatch) {
+ DataAndVectorGenerator generator,
+ int numExprs,
+ int maxRowsInBatch) {
this.projector = projector;
this.generator = generator;
this.numExprs = numExprs;
@@ -66,7 +69,7 @@ class ProjectEvaluator implements BaseEvaluator {
@Override
public void evaluate(ArrowRecordBatch recordBatch,
- BufferAllocator allocator) throws GandivaException {
+ BufferAllocator allocator) throws GandivaException {
// set up output vectors
// for each expression, generate the output vector
for (int i = 0; i < numExprs; i++) {
@@ -94,6 +97,7 @@ class ProjectEvaluator implements BaseEvaluator {
}
class FilterEvaluator implements BaseEvaluator {
+
private Filter filter;
private long elapsedTime = 0;
@@ -103,7 +107,7 @@ class FilterEvaluator implements BaseEvaluator {
@Override
public void evaluate(ArrowRecordBatch recordBatch,
- BufferAllocator allocator) throws GandivaException {
+ BufferAllocator allocator) throws GandivaException {
ArrowBuf selectionBuffer = allocator.buffer(recordBatch.getLength() * 2);
SelectionVectorInt16 selectionVector = new
SelectionVectorInt16(selectionBuffer);
@@ -124,11 +128,14 @@ class FilterEvaluator implements BaseEvaluator {
}
interface DataAndVectorGenerator {
+
public void writeData(ArrowBuf buffer);
+
public ValueVector generateOutputVector(int numRowsInBatch);
}
class Int32DataAndVectorGenerator implements DataAndVectorGenerator {
+
protected final BufferAllocator allocator;
protected final Random rand;
@@ -151,6 +158,7 @@ class Int32DataAndVectorGenerator implements
DataAndVectorGenerator {
}
class BoundedInt32DataAndVectorGenerator extends Int32DataAndVectorGenerator {
+
private final int upperBound;
BoundedInt32DataAndVectorGenerator(BufferAllocator allocator, int
upperBound) {
@@ -165,10 +173,11 @@ class BoundedInt32DataAndVectorGenerator extends
Int32DataAndVectorGenerator {
}
class BaseEvaluatorTest {
- protected final static int THOUSAND = 1000;
- protected final static int MILLION = THOUSAND * THOUSAND;
- protected final static String EMPTY_SCHEMA_PATH = "";
+ protected static final int THOUSAND = 1000;
+ protected static final int MILLION = THOUSAND * THOUSAND;
+
+ protected static final String EMPTY_SCHEMA_PATH = "";
protected BufferAllocator allocator;
protected ArrowType boolType;
@@ -206,7 +215,7 @@ class BaseEvaluatorTest {
ArrowBuf arrowBufWithAllValid(int size) {
int bufLen = (size + 7) / 8;
ArrowBuf buffer = allocator.buffer(bufLen);
- for(int i = 0; i < bufLen; i++) {
+ for (int i = 0; i < bufLen; i++) {
buffer.writeByte(255);
}
@@ -240,7 +249,7 @@ class BaseEvaluatorTest {
ArrowBuf stringToMillis(String[] dates) {
ArrowBuf buffer = allocator.buffer(dates.length * 8);
- for(int i = 0; i < dates.length; i++) {
+ for (int i = 0; i < dates.length; i++) {
Instant instant = Instant.parse(dates[i]);
buffer.writeLong(instant.getMillis());
}
@@ -254,29 +263,29 @@ class BaseEvaluatorTest {
// One in the allocator - release that explicitly
List<ArrowBuf> buffers = recordBatch.getBuffers();
recordBatch.close();
- for(ArrowBuf buf : buffers) {
+ for (ArrowBuf buf : buffers) {
buf.release();
}
}
void releaseValueVectors(List<ValueVector> valueVectors) {
- for(ValueVector valueVector : valueVectors) {
+ for (ValueVector valueVector : valueVectors) {
valueVector.close();
}
}
void generateData(DataAndVectorGenerator generator, int numRecords, ArrowBuf
buffer) {
- for(int i = 0; i < numRecords; i++) {
+ for (int i = 0; i < numRecords; i++) {
generator.writeData(buffer);
}
}
private void generateDataAndEvaluate(DataAndVectorGenerator generator,
- BaseEvaluator evaluator,
- int numFields,
- int numRows, int maxRowsInBatch,
- int inputFieldSize)
- throws GandivaException, Exception {
+ BaseEvaluator evaluator,
+ int numFields,
+ int numRows, int maxRowsInBatch,
+ int inputFieldSize)
+ throws GandivaException, Exception {
int numRemaining = numRows;
List<ArrowBuf> inputData = new ArrayList<ArrowBuf>();
List<ArrowFieldNode> fieldNodes = new ArrayList<ArrowFieldNode>();
@@ -316,16 +325,16 @@ class BaseEvaluatorTest {
}
long timedProject(DataAndVectorGenerator generator,
- Schema schema, List<ExpressionTree> exprs,
- int numRows, int maxRowsInBatch,
- int inputFieldSize)
- throws GandivaException, Exception {
+ Schema schema, List<ExpressionTree> exprs,
+ int numRows, int maxRowsInBatch,
+ int inputFieldSize)
+ throws GandivaException, Exception {
Projector projector = Projector.make(schema, exprs);
try {
ProjectEvaluator evaluator =
- new ProjectEvaluator(projector, generator, exprs.size(),
maxRowsInBatch);
+ new ProjectEvaluator(projector, generator, exprs.size(),
maxRowsInBatch);
generateDataAndEvaluate(generator, evaluator,
- schema.getFields().size(), numRows, maxRowsInBatch, inputFieldSize);
+ schema.getFields().size(), numRows, maxRowsInBatch, inputFieldSize);
return evaluator.getElapsedMillis();
} finally {
projector.close();
@@ -333,16 +342,16 @@ class BaseEvaluatorTest {
}
long timedFilter(DataAndVectorGenerator generator,
- Schema schema, Condition condition,
- int numRows, int maxRowsInBatch,
- int inputFieldSize)
- throws GandivaException, Exception {
+ Schema schema, Condition condition,
+ int numRows, int maxRowsInBatch,
+ int inputFieldSize)
+ throws GandivaException, Exception {
Filter filter = Filter.make(schema, condition);
try {
FilterEvaluator evaluator = new FilterEvaluator(filter);
generateDataAndEvaluate(generator, evaluator,
- schema.getFields().size(), numRows, maxRowsInBatch, inputFieldSize);
+ schema.getFields().size(), numRows, maxRowsInBatch, inputFieldSize);
return evaluator.getElapsedMillis();
} finally {
filter.close();
diff --git
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistryTest.java
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistryTest.java
index 95cecc9..1fc2713 100644
---
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistryTest.java
+++
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ExpressionRegistryTest.java
@@ -18,14 +18,14 @@
package org.apache.arrow.gandiva.evaluator;
-import com.google.common.collect.Lists;
+import java.util.Set;
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.junit.Assert;
import org.junit.Test;
-import java.util.Set;
+import com.google.common.collect.Lists;
public class ExpressionRegistryTest {
@@ -34,13 +34,13 @@ public class ExpressionRegistryTest {
Set<ArrowType> types =
ExpressionRegistry.getInstance().getSupportedTypes();
ArrowType.Int UINT8 = new ArrowType.Int(8, false);
Assert.assertTrue(types.contains(UINT8));
-
}
@Test
public void testFunctions() throws GandivaException {
ArrowType.Int UINT8 = new ArrowType.Int(8, false);
- FunctionSignature signature = new FunctionSignature("add",
UINT8,Lists.newArrayList(UINT8,UINT8));
+ FunctionSignature signature =
+ new FunctionSignature("add", UINT8, Lists.newArrayList(UINT8, UINT8));
Set<FunctionSignature> functions =
ExpressionRegistry.getInstance().getSupportedFunctions();
Assert.assertTrue(functions.contains(signature));
}
diff --git
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/FilterTest.java
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/FilterTest.java
index 8c89fe7..fc6c767 100644
---
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/FilterTest.java
+++
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/FilterTest.java
@@ -48,7 +48,7 @@ public class FilterTest extends BaseEvaluatorTest {
private int[] selectionVectorToArray(SelectionVector vector) {
int[] actual = new int[vector.getRecordCount()];
- for (int i = 0; i < vector.getRecordCount(); ++i ) {
+ for (int i = 0; i < vector.getRecordCount(); ++i) {
actual[i] = vector.getIndex(i);
}
return actual;
@@ -66,10 +66,10 @@ public class FilterTest extends BaseEvaluatorTest {
Filter filter = Filter.make(schema, condition);
int numRows = 16;
- byte[] validity = new byte[]{(byte) 255, 0};
+ byte[] validity = new byte[] {(byte) 255, 0};
// second half is "undefined"
- int[] values_a = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16};
- int[] values_b = new int[]{2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13,
14, 15};
+ int[] values_a = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16};
+ int[] values_b = new int[] {2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13,
14, 15};
int[] expected = {0, 2, 4, 6};
verifyTestCase(filter, numRows, validity, values_a, values_b, expected);
@@ -88,15 +88,15 @@ public class FilterTest extends BaseEvaluatorTest {
int numRows = 32;
- byte [] validity= new byte[numRows/8];
+ byte[] validity = new byte[numRows / 8];
- IntStream.range(0,numRows/8).forEach(i -> validity[i] = (byte)255);
+ IntStream.range(0, numRows / 8).forEach(i -> validity[i] = (byte) 255);
int[] values_a = new int[numRows];
IntStream.range(0, numRows).forEach(i -> values_a[i] = i);
int[] values_b = new int[numRows];
- IntStream.range(0, numRows).forEach(i -> values_b[i] = i+1);
+ IntStream.range(0, numRows).forEach(i -> values_b[i] = i + 1);
int[] expected = new int[numRows];
IntStream.range(0, numRows).forEach(i -> expected[i] = i);
@@ -117,15 +117,15 @@ public class FilterTest extends BaseEvaluatorTest {
int numRows = 1000;
- byte [] validity= new byte[numRows/8];
+ byte[] validity = new byte[numRows / 8];
- IntStream.range(0,numRows/8).forEach(i -> validity[i] = (byte)255);
+ IntStream.range(0, numRows / 8).forEach(i -> validity[i] = (byte) 255);
int[] values_a = new int[numRows];
IntStream.range(0, numRows).forEach(i -> values_a[i] = i);
int[] values_b = new int[numRows];
- IntStream.range(0, numRows).forEach(i -> values_b[i] = i+1);
+ IntStream.range(0, numRows).forEach(i -> values_b[i] = i + 1);
values_a[0] = 5;
values_b[0] = 0;
@@ -147,22 +147,24 @@ public class FilterTest extends BaseEvaluatorTest {
Filter filter = Filter.make(schema, condition);
int numRows = 16;
- byte[] validity = new byte[]{(byte) 255, 0};
+ byte[] validity = new byte[] {(byte) 255, 0};
// second half is "undefined"
- int[] values_a = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16};
- int[] values_b = new int[]{2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13,
14, 15};
+ int[] values_a = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16};
+ int[] values_b = new int[] {2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13,
14, 15};
int[] expected = {0, 2, 4, 6};
verifyTestCase(filter, numRows, validity, values_a, values_b, expected);
}
- private void verifyTestCase(Filter filter, int numRows, byte[] validity,
- int[] values_a, int[] values_b, int[] expected)
throws GandivaException {
+ private void verifyTestCase(
+ Filter filter, int numRows, byte[] validity, int[] values_a, int[]
values_b, int[] expected)
+ throws GandivaException {
ArrowBuf validitya = buf(validity);
ArrowBuf valuesa = intBuf(values_a);
ArrowBuf validityb = buf(validity);
ArrowBuf valuesb = intBuf(values_b);
- ArrowRecordBatch batch = new ArrowRecordBatch(
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
numRows,
Lists.newArrayList(new ArrowFieldNode(numRows, 0), new
ArrowFieldNode(numRows, 0)),
Lists.newArrayList(validitya, valuesa, validityb, valuesb));
diff --git
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/MicroBenchmarkTest.java
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/MicroBenchmarkTest.java
index c860963..a14f596 100644
---
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/MicroBenchmarkTest.java
+++
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/MicroBenchmarkTest.java
@@ -18,7 +18,7 @@
package org.apache.arrow.gandiva.evaluator;
-import com.google.common.collect.Lists;
+import java.util.List;
import org.apache.arrow.gandiva.expression.Condition;
import org.apache.arrow.gandiva.expression.ExpressionTree;
@@ -29,9 +29,10 @@ import org.apache.arrow.vector.types.pojo.Schema;
import org.junit.Assert;
import org.junit.Test;
-import java.util.List;
+import com.google.common.collect.Lists;
public class MicroBenchmarkTest extends BaseEvaluatorTest {
+
private double toleranceRatio = 4.0;
@Test
@@ -41,18 +42,22 @@ public class MicroBenchmarkTest extends BaseEvaluatorTest {
Field N3x = Field.nullable("N3x", int32);
// x + N2x + N3x
- TreeNode add1 = TreeBuilder.makeFunction("add",
Lists.newArrayList(TreeBuilder.makeField(x), TreeBuilder.makeField(N2x)),
int32);
- TreeNode add = TreeBuilder.makeFunction("add", Lists.newArrayList(add1,
TreeBuilder.makeField(N3x)), int32);
+ TreeNode add1 =
+ TreeBuilder.makeFunction(
+ "add", Lists.newArrayList(TreeBuilder.makeField(x),
TreeBuilder.makeField(N2x)), int32);
+ TreeNode add =
+ TreeBuilder.makeFunction(
+ "add", Lists.newArrayList(add1, TreeBuilder.makeField(N3x)),
int32);
ExpressionTree expr = TreeBuilder.makeExpression(add, x);
List<Field> cols = Lists.newArrayList(x, N2x, N3x);
Schema schema = new Schema(cols);
long timeTaken = timedProject(new Int32DataAndVectorGenerator(allocator),
- schema,
- Lists.newArrayList(expr),
- 1 * MILLION, 16 * THOUSAND,
- 4);
+ schema,
+ Lists.newArrayList(expr),
+ 1 * MILLION, 16 * THOUSAND,
+ 4);
System.out.println("Time taken for projecting 1m records of add3 is " +
timeTaken + "ms");
Assert.assertTrue(timeTaken <= 10 * toleranceRatio);
}
@@ -91,13 +96,16 @@ public class MicroBenchmarkTest extends BaseEvaluatorTest {
int compareWith = 200;
while (compareWith >= 10) {
// cond (x < compareWith)
- TreeNode condNode = TreeBuilder.makeFunction("less_than",
+ TreeNode condNode =
+ TreeBuilder.makeFunction(
+ "less_than",
Lists.newArrayList(x_node, TreeBuilder.makeLiteral(compareWith)),
boolType);
- topNode = TreeBuilder.makeIf(
- condNode, // cond (x < compareWith)
+ topNode =
+ TreeBuilder.makeIf(
+ condNode, // cond (x < compareWith)
TreeBuilder.makeLiteral(returnValue), // then returnValue
- topNode, // else topNode
+ topNode, // else topNode
int32);
compareWith -= 10;
returnValue--;
@@ -107,10 +115,10 @@ public class MicroBenchmarkTest extends BaseEvaluatorTest
{
Schema schema = new Schema(Lists.newArrayList(x));
long timeTaken = timedProject(new
BoundedInt32DataAndVectorGenerator(allocator, 250),
- schema,
- Lists.newArrayList(expr),
- 1 * MILLION, 16 * THOUSAND,
- 4);
+ schema,
+ Lists.newArrayList(expr),
+ 1 * MILLION, 16 * THOUSAND,
+ 4);
System.out.println("Time taken for projecting 10m records of nestedIf is "
+ timeTaken + "ms");
Assert.assertTrue(timeTaken <= 15 * toleranceRatio);
}
@@ -122,20 +130,21 @@ public class MicroBenchmarkTest extends BaseEvaluatorTest
{
Field N3x = Field.nullable("N3x", int32);
// x + N2x < N3x
- TreeNode add = TreeBuilder.makeFunction("add",
Lists.newArrayList(TreeBuilder.makeField(x), TreeBuilder.makeField(N2x)),
int32);
- TreeNode less_than = TreeBuilder.makeFunction("less_than",
Lists.newArrayList(add, TreeBuilder.makeField(N3x)), boolType);
+ TreeNode add = TreeBuilder.makeFunction("add",
+ Lists.newArrayList(TreeBuilder.makeField(x),
TreeBuilder.makeField(N2x)), int32);
+ TreeNode less_than = TreeBuilder
+ .makeFunction("less_than", Lists.newArrayList(add,
TreeBuilder.makeField(N3x)), boolType);
Condition condition = TreeBuilder.makeCondition(less_than);
List<Field> cols = Lists.newArrayList(x, N2x, N3x);
Schema schema = new Schema(cols);
long timeTaken = timedFilter(new Int32DataAndVectorGenerator(allocator),
- schema,
- condition,
- 1 * MILLION, 16 * THOUSAND,
- 4);
+ schema,
+ condition,
+ 1 * MILLION, 16 * THOUSAND,
+ 4);
System.out.println("Time taken for filtering 10m records of a+b<c is " +
timeTaken + "ms");
Assert.assertTrue(timeTaken <= 12 * toleranceRatio);
}
-
-}
\ No newline at end of file
+}
diff --git
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ProjectorTest.java
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ProjectorTest.java
index 6ed3d56..f75fe78 100644
---
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ProjectorTest.java
+++
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ProjectorTest.java
@@ -18,8 +18,19 @@
package org.apache.arrow.gandiva.evaluator;
-import com.google.common.collect.Lists;
-import io.netty.buffer.ArrowBuf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.IntStream;
+
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.gandiva.expression.ExpressionTree;
import org.apache.arrow.gandiva.expression.TreeBuilder;
@@ -40,20 +51,12 @@ import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.IntStream;
+import com.google.common.collect.Lists;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import io.netty.buffer.ArrowBuf;
public class ProjectorTest extends BaseEvaluatorTest {
+
private Charset utf8Charset = Charset.forName("UTF-8");
private Charset utf16Charset = Charset.forName("UTF-16");
@@ -88,17 +91,18 @@ public class ProjectorTest extends BaseEvaluatorTest {
List<Schema> schemas = Lists.newArrayList();
Field a = Field.nullable("a", int64);
Field b = Field.nullable("b", int64);
- IntStream.range(0, 1000).forEach(i -> {
- Field c = Field.nullable("" + i, int64);
- List<Field> cols = Lists.newArrayList(a, b, c);
- schemas.add(new Schema(cols));
- });
+ IntStream.range(0, 1000)
+ .forEach(
+ i -> {
+ Field c = Field.nullable("" + i, int64);
+ List<Field> cols = Lists.newArrayList(a, b, c);
+ schemas.add(new Schema(cols));
+ });
TreeNode aNode = TreeBuilder.makeField(a);
TreeNode bNode = TreeBuilder.makeField(b);
List<TreeNode> args = Lists.newArrayList(aNode, bNode);
-
TreeNode cond = TreeBuilder.makeFunction("greater_than", args, boolType);
TreeNode ifNode = TreeBuilder.makeIf(cond, aNode, bNode, int64);
@@ -110,17 +114,20 @@ public class ProjectorTest extends BaseEvaluatorTest {
// any threading issues.
ExecutorService executors = Executors.newFixedThreadPool(16);
- IntStream.range(0, 1000).forEach(i -> {
- executors.submit(() -> {
- try {
- Projector evaluator = Projector.make(schemas.get((int)
(Math.random() * 100)),
- exprs);
- evaluator.close();
- } catch (GandivaException e) {
- e.printStackTrace();
- }
- });
- });
+ IntStream.range(0, 1000)
+ .forEach(
+ i -> {
+ executors.submit(
+ () -> {
+ try {
+ Projector evaluator =
+ Projector.make(schemas.get((int) (Math.random() *
100)), exprs);
+ evaluator.close();
+ } catch (GandivaException e) {
+ e.printStackTrace();
+ }
+ });
+ });
executors.shutdown();
executors.awaitTermination(100, java.util.concurrent.TimeUnit.SECONDS);
}
@@ -144,10 +151,12 @@ public class ProjectorTest extends BaseEvaluatorTest {
long startTime = System.currentTimeMillis();
Projector evaluator1 = Projector.make(schema, exprs);
- System.out.println("Projector build: iteration 1 took " +
(System.currentTimeMillis() - startTime) + " ms");
+ System.out.println(
+ "Projector build: iteration 1 took " + (System.currentTimeMillis() -
startTime) + " ms");
startTime = System.currentTimeMillis();
Projector evaluator2 = Projector.make(schema, exprs);
- System.out.println("Projector build: iteration 2 took " +
(System.currentTimeMillis() - startTime) + " ms");
+ System.out.println(
+ "Projector build: iteration 2 took " + (System.currentTimeMillis() -
startTime) + " ms");
startTime = System.currentTimeMillis();
Projector evaluator3 = Projector.make(schema, exprs);
long timeToMakeProjector = (System.currentTimeMillis() - startTime);
@@ -186,7 +195,7 @@ public class ProjectorTest extends BaseEvaluatorTest {
// allow GC to collect any temp resources.
Thread.sleep(1000);
-
+
// try again to ensure no temporary resources.
exceptionThrown = false;
try {
@@ -222,7 +231,8 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf valuesa = intBuf(values_a);
ArrowBuf validityb = buf(validity);
ArrowBuf valuesb = intBuf(values_b);
- ArrowRecordBatch batch = new ArrowRecordBatch(
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
numRows,
Lists.newArrayList(new ArrowFieldNode(numRows, 8), new
ArrowFieldNode(numRows, 8)),
Lists.newArrayList(validitya, valuesa, validityb, valuesb));
@@ -273,9 +283,9 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf validityb = buf(validity);
ArrowBuf valuesb = intBuf(values_b);
ArrowRecordBatch batch = new ArrowRecordBatch(
- numRows,
- Lists.newArrayList(new ArrowFieldNode(numRows, 0), new
ArrowFieldNode(numRows, 0)),
- Lists.newArrayList(validitya, valuesa, validityb, valuesb));
+ numRows,
+ Lists.newArrayList(new ArrowFieldNode(numRows, 0), new
ArrowFieldNode(numRows, 0)),
+ Lists.newArrayList(validitya, valuesa, validityb, valuesb));
IntVector intVector = new IntVector(EMPTY_SCHEMA_PATH, allocator);
intVector.allocateNew(numRows);
@@ -307,7 +317,6 @@ public class ProjectorTest extends BaseEvaluatorTest {
List<Field> args = Lists.newArrayList(a, b);
-
ExpressionTree expr = TreeBuilder.makeExpression("divide", args, c);
List<ExpressionTree> exprs = Lists.newArrayList(expr);
@@ -326,7 +335,7 @@ public class ProjectorTest extends BaseEvaluatorTest {
byte[] validity = new byte[]{(byte) 255};
int[] values_a = new int[]{2, 2};
int[] values_b;
- if (i%2 == 0) {
+ if (i % 2 == 0) {
errorCountExp.incrementAndGet();
values_b = new int[]{1, 0};
} else {
@@ -338,10 +347,10 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf validityb = buf(validity);
ArrowBuf valuesb = intBuf(values_b);
ArrowRecordBatch batch = new ArrowRecordBatch(
- numRows,
- Lists.newArrayList(new ArrowFieldNode(numRows, 0), new
ArrowFieldNode(numRows,
- 0)),
- Lists.newArrayList(validitya, valuesa, validityb, valuesb));
+ numRows,
+ Lists.newArrayList(new ArrowFieldNode(numRows, 0), new
ArrowFieldNode(numRows,
+ 0)),
+ Lists.newArrayList(validitya, valuesa, validityb, valuesb));
IntVector intVector = new IntVector(EMPTY_SCHEMA_PATH, allocator);
intVector.allocateNew(numRows);
@@ -375,8 +384,12 @@ public class ProjectorTest extends BaseEvaluatorTest {
List<TreeNode> args = new ArrayList<TreeNode>();
// x + N2x + N3x
- TreeNode add1 = TreeBuilder.makeFunction("add",
Lists.newArrayList(TreeBuilder.makeField(x), TreeBuilder.makeField(N2x)),
int32);
- TreeNode add = TreeBuilder.makeFunction("add", Lists.newArrayList(add1,
TreeBuilder.makeField(N3x)), int32);
+ TreeNode add1 =
+ TreeBuilder.makeFunction(
+ "add", Lists.newArrayList(TreeBuilder.makeField(x),
TreeBuilder.makeField(N2x)), int32);
+ TreeNode add =
+ TreeBuilder.makeFunction(
+ "add", Lists.newArrayList(add1, TreeBuilder.makeField(N3x)),
int32);
ExpressionTree expr = TreeBuilder.makeExpression(add, x);
List<Field> cols = Lists.newArrayList(x, N2x, N3x);
@@ -401,7 +414,8 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf data_N3x = intBuf(values_N3x);
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 8);
- ArrowRecordBatch batch = new ArrowRecordBatch(
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
numRows,
Lists.newArrayList(fieldNode, fieldNode, fieldNode),
Lists.newArrayList(validity_x, data_x, validity_N2x, data_N2x,
validity_N3x, data_N3x));
@@ -439,18 +453,20 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowType retType = new ArrowType.Int(32, true);
- TreeNode cond = TreeBuilder.makeFunction("less_than",
- Lists.newArrayList(TreeBuilder.makeField(x),
TreeBuilder.makeStringLiteral("hello")),
- boolType);
- TreeNode octetLenFuncNode = TreeBuilder.makeFunction("octet_length",
- Lists.newArrayList(TreeBuilder.makeField(x)),
- retType);
- TreeNode octetLenPlusANode = TreeBuilder.makeFunction("add",
- Lists.newArrayList(TreeBuilder.makeField(a), octetLenFuncNode),
- retType);
- TreeNode octetLenPlusBNode = TreeBuilder.makeFunction("add",
- Lists.newArrayList(TreeBuilder.makeField(b), octetLenFuncNode),
- retType);
+ TreeNode cond =
+ TreeBuilder.makeFunction(
+ "less_than",
+ Lists.newArrayList(TreeBuilder.makeField(x),
TreeBuilder.makeStringLiteral("hello")),
+ boolType);
+ TreeNode octetLenFuncNode =
+ TreeBuilder.makeFunction(
+ "octet_length", Lists.newArrayList(TreeBuilder.makeField(x)),
retType);
+ TreeNode octetLenPlusANode =
+ TreeBuilder.makeFunction(
+ "add", Lists.newArrayList(TreeBuilder.makeField(a),
octetLenFuncNode), retType);
+ TreeNode octetLenPlusBNode =
+ TreeBuilder.makeFunction(
+ "add", Lists.newArrayList(TreeBuilder.makeField(b),
octetLenFuncNode), retType);
TreeNode ifHello = TreeBuilder.makeIf(cond, octetLenPlusANode,
octetLenPlusBNode, retType);
@@ -461,7 +477,7 @@ public class ProjectorTest extends BaseEvaluatorTest {
int numRows = 5;
byte[] validity = new byte[]{(byte) 255, 0};
// "A função" means "The function" in portugese
- String[] valuesX = new String[]{"hell", "abc", "hellox", "ijk", "A função"
};
+ String[] valuesX = new String[]{"hell", "abc", "hellox", "ijk", "A
função"};
int[] valuesA = new int[]{10, 20, 30, 40, 50};
int[] valuesB = new int[]{110, 120, 130, 140, 150};
int[] expected = new int[]{14, 23, 136, 143, 60};
@@ -473,10 +489,12 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf validityB = buf(validity);
ArrowBuf dataB = intBuf(valuesB);
- ArrowRecordBatch batch = new ArrowRecordBatch(
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
numRows,
Lists.newArrayList(new ArrowFieldNode(numRows, 0), new
ArrowFieldNode(numRows, 0)),
- Lists.newArrayList(validityA, dataA, validityX, dataBufsX.get(0),
dataBufsX.get(1), validityB, dataB));
+ Lists.newArrayList(
+ validityA, dataA, validityX, dataBufsX.get(0),
dataBufsX.get(1), validityB, dataB));
IntVector intVector = new IntVector(EMPTY_SCHEMA_PATH, allocator);
intVector.allocateNew(numRows);
@@ -503,22 +521,25 @@ public class ProjectorTest extends BaseEvaluatorTest {
Field x = Field.nullable("x", new ArrowType.Utf8());
- TreeNode cond = TreeBuilder.makeFunction("like",
- Lists.newArrayList(TreeBuilder.makeField(x),
TreeBuilder.makeStringLiteral("map%")),
- boolType);
+ TreeNode cond =
+ TreeBuilder.makeFunction(
+ "like",
+ Lists.newArrayList(TreeBuilder.makeField(x),
TreeBuilder.makeStringLiteral("map%")),
+ boolType);
ExpressionTree expr = TreeBuilder.makeExpression(cond,
Field.nullable("res", boolType));
Schema schema = new Schema(Lists.newArrayList(x));
Projector eval = Projector.make(schema, Lists.newArrayList(expr));
int numRows = 5;
byte[] validity = new byte[]{(byte) 255, 0};
- String[] valuesX = new String[]{"mapD", "maps", "google maps", "map",
"MapR" };
+ String[] valuesX = new String[]{"mapD", "maps", "google maps", "map",
"MapR"};
boolean[] expected = new boolean[]{true, true, false, true, false};
ArrowBuf validityX = buf(validity);
List<ArrowBuf> dataBufsX = stringBufs(valuesX);
- ArrowRecordBatch batch = new ArrowRecordBatch(
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
numRows,
Lists.newArrayList(new ArrowFieldNode(numRows, 0)),
Lists.newArrayList(validityX, dataBufsX.get(0), dataBufsX.get(1)));
@@ -547,8 +568,7 @@ public class ProjectorTest extends BaseEvaluatorTest {
List<Field> args = Lists.newArrayList(a, b);
ArrowType retType = new ArrowType.Bool();
- ExpressionTree expr = TreeBuilder.makeExpression("equal", args,
- Field.nullable("res", retType));
+ ExpressionTree expr = TreeBuilder.makeExpression("equal", args,
Field.nullable("res", retType));
Schema schema = new Schema(Lists.newArrayList(args));
Projector eval = Projector.make(schema, Lists.newArrayList(expr));
@@ -564,10 +584,17 @@ public class ProjectorTest extends BaseEvaluatorTest {
List<ArrowBuf> inBufsA = binaryBufs(valuesA);
List<ArrowBuf> inBufsB = binaryBufs(valuesB);
- ArrowRecordBatch batch = new ArrowRecordBatch(
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
numRows,
Lists.newArrayList(new ArrowFieldNode(numRows, 8), new
ArrowFieldNode(numRows, 8)),
- Lists.newArrayList(validitya, inBufsA.get(0), inBufsA.get(1),
validityb, inBufsB.get(0), inBufsB.get(1)));
+ Lists.newArrayList(
+ validitya,
+ inBufsA.get(0),
+ inBufsA.get(1),
+ validityb,
+ inBufsB.get(0),
+ inBufsB.get(1)));
BitVector bitVector = new BitVector(EMPTY_SCHEMA_PATH, allocator);
bitVector.allocateNew(numRows);
@@ -587,23 +614,19 @@ public class ProjectorTest extends BaseEvaluatorTest {
}
private TreeNode makeLongLessThanCond(TreeNode arg, long value) {
- return TreeBuilder.makeFunction("less_than",
- Lists.newArrayList(arg, TreeBuilder.makeLiteral(value)),
- boolType);
+ return TreeBuilder.makeFunction(
+ "less_than", Lists.newArrayList(arg, TreeBuilder.makeLiteral(value)),
boolType);
}
private TreeNode makeLongGreaterThanCond(TreeNode arg, long value) {
- return TreeBuilder.makeFunction("greater_than",
- Lists.newArrayList(arg, TreeBuilder.makeLiteral(value)),
- boolType);
+ return TreeBuilder.makeFunction(
+ "greater_than", Lists.newArrayList(arg,
TreeBuilder.makeLiteral(value)), boolType);
}
- private TreeNode ifLongLessThanElse(TreeNode arg, long value, long
then_value, TreeNode elseNode, ArrowType type) {
+ private TreeNode ifLongLessThanElse(
+ TreeNode arg, long value, long then_value, TreeNode elseNode, ArrowType
type) {
return TreeBuilder.makeIf(
- makeLongLessThanCond(arg, value),
- TreeBuilder.makeLiteral(then_value),
- elseNode,
- type);
+ makeLongLessThanCond(arg, value), TreeBuilder.makeLiteral(then_value),
elseNode, type);
}
@Test
@@ -658,10 +681,9 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf data_x = longBuf(values_x);
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
- ArrowRecordBatch batch = new ArrowRecordBatch(
- numRows,
- Lists.newArrayList(fieldNode),
- Lists.newArrayList(validity_buf, data_x));
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
+ numRows, Lists.newArrayList(fieldNode),
Lists.newArrayList(validity_buf, data_x));
BigIntVector bigIntVector = new BigIntVector(EMPTY_SCHEMA_PATH, allocator);
bigIntVector.allocateNew(numRows);
@@ -708,10 +730,9 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf data_x = longBuf(values_x);
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
- ArrowRecordBatch batch = new ArrowRecordBatch(
- numRows,
- Lists.newArrayList(fieldNode),
- Lists.newArrayList(validity_buf, data_x));
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
+ numRows, Lists.newArrayList(fieldNode),
Lists.newArrayList(validity_buf, data_x));
BitVector bitVector = new BitVector(EMPTY_SCHEMA_PATH, allocator);
bitVector.allocateNew(numRows);
@@ -758,10 +779,9 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf data_x = longBuf(values_x);
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
- ArrowRecordBatch batch = new ArrowRecordBatch(
- numRows,
- Lists.newArrayList(fieldNode),
- Lists.newArrayList(validity_buf, data_x));
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
+ numRows, Lists.newArrayList(fieldNode),
Lists.newArrayList(validity_buf, data_x));
BitVector bitVector = new BitVector(EMPTY_SCHEMA_PATH, allocator);
bitVector.allocateNew(numRows);
@@ -807,10 +827,9 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf data_x = longBuf(values_x);
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
- ArrowRecordBatch batch = new ArrowRecordBatch(
- numRows,
- Lists.newArrayList(fieldNode),
- Lists.newArrayList(validity_buf, data_x));
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
+ numRows, Lists.newArrayList(fieldNode),
Lists.newArrayList(validity_buf, data_x));
BigIntVector bigIntVector = new BigIntVector(EMPTY_SCHEMA_PATH, allocator);
bigIntVector.allocateNew(numRows);
@@ -851,10 +870,9 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf data_x = intBuf(values_x);
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
- ArrowRecordBatch batch = new ArrowRecordBatch(
- numRows,
- Lists.newArrayList(fieldNode),
- Lists.newArrayList(validity_buf, data_x));
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
+ numRows, Lists.newArrayList(fieldNode),
Lists.newArrayList(validity_buf, data_x));
BigIntVector bigIntVector = new BigIntVector(EMPTY_SCHEMA_PATH, allocator);
bigIntVector.allocateNew(numRows);
@@ -883,13 +901,13 @@ public class ProjectorTest extends BaseEvaluatorTest {
TreeNode y_node = TreeBuilder.makeField(y);
// if isnotnull(x) then x else y
- TreeNode condition =
TreeBuilder.makeFunction("isnotnull",Lists.newArrayList(x_node) ,
- boolType);
+ TreeNode condition = TreeBuilder.makeFunction("isnotnull",
Lists.newArrayList(x_node),
+ boolType);
TreeNode if_coalesce = TreeBuilder.makeIf(
- condition,
- x_node,
- y_node,
- new ArrowType.Time(TimeUnit.MILLISECOND, 32));
+ condition,
+ x_node,
+ y_node,
+ new ArrowType.Time(TimeUnit.MILLISECOND, 32));
ExpressionTree expr = TreeBuilder.makeExpression(if_coalesce, x);
Schema schema = new Schema(Lists.newArrayList(x, y));
@@ -905,15 +923,14 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf validity_buf = buf(validity);
ArrowBuf data_x = intBuf(values_x);
-
ArrowBuf validity_buf_y = buf(validity_y);
ArrowBuf data_y = intBuf(values_y);
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
ArrowRecordBatch batch = new ArrowRecordBatch(
- numRows,
- Lists.newArrayList(fieldNode),
- Lists.newArrayList(validity_buf, data_x, validity_buf_y, data_y));
+ numRows,
+ Lists.newArrayList(fieldNode),
+ Lists.newArrayList(validity_buf, data_x, validity_buf_y, data_y));
IntVector intVector = new IntVector(EMPTY_SCHEMA_PATH, allocator);
intVector.allocateNew(numRows);
@@ -944,16 +961,18 @@ public class ProjectorTest extends BaseEvaluatorTest {
int numRows = 16;
byte[] validity = new byte[]{(byte) 255, 0};
- double[] values_x = new double[]{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0};
+ double[] values_x =
+ new double[]{
+ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0,
13.0, 14.0, 15.0, 16.0
+ };
ArrowBuf validity_buf = buf(validity);
ArrowBuf data_x = doubleBuf(values_x);
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
- ArrowRecordBatch batch = new ArrowRecordBatch(
- numRows,
- Lists.newArrayList(fieldNode),
- Lists.newArrayList(validity_buf, data_x));
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
+ numRows, Lists.newArrayList(fieldNode),
Lists.newArrayList(validity_buf, data_x));
BitVector bitVector = new BitVector(EMPTY_SCHEMA_PATH, allocator);
bitVector.allocateNew(numRows);
@@ -981,7 +1000,8 @@ public class ProjectorTest extends BaseEvaluatorTest {
TreeNode c1_Node = TreeBuilder.makeField(c1);
TreeNode c2_Node = TreeBuilder.makeField(c2);
- TreeNode equals = TreeBuilder.makeFunction("equal",
Lists.newArrayList(c1_Node, c2_Node), boolType);
+ TreeNode equals =
+ TreeBuilder.makeFunction("equal", Lists.newArrayList(c1_Node,
c2_Node), boolType);
ExpressionTree expr = TreeBuilder.makeExpression(equals,
Field.nullable("result", boolType));
Schema schema = new Schema(Lists.newArrayList(c1, c2));
Projector eval = Projector.make(schema, Lists.newArrayList(expr));
@@ -997,7 +1017,8 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf data_c2 = intBuf(values_c2);
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
- ArrowRecordBatch batch = new ArrowRecordBatch(
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
numRows,
Lists.newArrayList(fieldNode, fieldNode),
Lists.newArrayList(validity_c1, data_c1, validity_c2, data_c2));
@@ -1048,7 +1069,8 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf data_a = intBuf(values_a);
ArrowBuf validity_b = buf(validity);
ArrowBuf data_b = intBuf(values_b);
- ArrowRecordBatch batch = new ArrowRecordBatch(
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
numRows,
Lists.newArrayList(new ArrowFieldNode(numRows, 8), new
ArrowFieldNode(numRows, 8)),
Lists.newArrayList(validity_a, data_a, validity_b, data_b));
@@ -1080,11 +1102,11 @@ public class ProjectorTest extends BaseEvaluatorTest {
@Test
public void testDateTime() throws GandivaException, Exception {
ArrowType date64 = new ArrowType.Date(DateUnit.MILLISECOND);
- //ArrowType time32 = new ArrowType.Time(TimeUnit.MILLISECOND, 32);
+ // ArrowType time32 = new ArrowType.Time(TimeUnit.MILLISECOND, 32);
ArrowType timeStamp = new ArrowType.Timestamp(TimeUnit.MILLISECOND, "TZ");
Field dateField = Field.nullable("date", date64);
- //Field timeField = Field.nullable("time", time32);
+ // Field timeField = Field.nullable("time", time32);
Field tsField = Field.nullable("timestamp", timeStamp);
TreeNode dateNode = TreeBuilder.makeField(dateField);
@@ -1105,7 +1127,8 @@ public class ProjectorTest extends BaseEvaluatorTest {
TreeNode tsToMin = TreeBuilder.makeFunction("extractMinute", tsArgs,
int64);
Field resultField = Field.nullable("result", int64);
- List<ExpressionTree> exprs = Lists.newArrayList(
+ List<ExpressionTree> exprs =
+ Lists.newArrayList(
TreeBuilder.makeExpression(dateToYear, resultField),
TreeBuilder.makeExpression(dateToMonth, resultField),
TreeBuilder.makeExpression(dateToDay, resultField),
@@ -1115,15 +1138,15 @@ public class ProjectorTest extends BaseEvaluatorTest {
TreeBuilder.makeExpression(tsToMonth, resultField),
TreeBuilder.makeExpression(tsToDay, resultField),
TreeBuilder.makeExpression(tsToHour, resultField),
- TreeBuilder.makeExpression(tsToMin, resultField)
- );
+ TreeBuilder.makeExpression(tsToMin, resultField));
Schema schema = new Schema(Lists.newArrayList(dateField, tsField));
Projector eval = Projector.make(schema, exprs);
int numRows = 8;
byte[] validity = new byte[]{(byte) 255};
- String[] values = new String[]{
+ String[] values =
+ new String[]{
"2007-01-01T01:00:00.00Z",
"2007-03-05T03:40:00.00Z",
"2008-05-31T13:55:00.00Z",
@@ -1132,20 +1155,17 @@ public class ProjectorTest extends BaseEvaluatorTest {
"2000-08-20T00:14:00.00Z",
"2000-09-30T02:29:00.00Z",
"2000-10-31T05:33:00.00Z"
- };
+ };
long[] expYearFromDate = new long[]{2007, 2007, 2008, 2000, 2000, 2000,
2000, 2000};
long[] expMonthFromDate = new long[]{1, 3, 5, 6, 7, 8, 9, 10};
long[] expDayFromDate = new long[]{1, 5, 31, 30, 10, 20, 30, 31};
long[] expHourFromDate = new long[]{1, 3, 13, 23, 20, 0, 2, 5};
long[] expMinFromDate = new long[]{0, 40, 55, 20, 30, 14, 29, 33};
- long[][] expValues = new long[][]{
- expYearFromDate,
- expMonthFromDate,
- expDayFromDate,
- expHourFromDate,
- expMinFromDate
- };
+ long[][] expValues =
+ new long[][]{
+ expYearFromDate, expMonthFromDate, expDayFromDate,
expHourFromDate, expMinFromDate
+ };
ArrowBuf validity_buf = buf(validity);
ArrowBuf data_millis = stringToMillis(values);
@@ -1153,13 +1173,14 @@ public class ProjectorTest extends BaseEvaluatorTest {
ArrowBuf data_millis2 = stringToMillis(values);
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
- ArrowRecordBatch batch = new ArrowRecordBatch(
+ ArrowRecordBatch batch =
+ new ArrowRecordBatch(
numRows,
Lists.newArrayList(fieldNode, fieldNode),
Lists.newArrayList(validity_buf, data_millis, validity_buf2,
data_millis2));
List<ValueVector> output = new ArrayList<ValueVector>();
- for(int i = 0; i < exprs.size(); i++) {
+ for (int i = 0; i < exprs.size(); i++) {
BigIntVector bigIntVector = new BigIntVector(EMPTY_SCHEMA_PATH,
allocator);
bigIntVector.allocateNew(numRows);
output.add(bigIntVector);
@@ -1167,9 +1188,9 @@ public class ProjectorTest extends BaseEvaluatorTest {
eval.evaluate(batch, output);
eval.close();
- for(int i = 0; i < output.size(); i++) {
+ for (int i = 0; i < output.size(); i++) {
long[] expected = expValues[i % 5];
- BigIntVector bigIntVector = (BigIntVector)output.get(i);
+ BigIntVector bigIntVector = (BigIntVector) output.get(i);
for (int j = 0; j < numRows; j++) {
assertFalse(bigIntVector.isNull(j));
@@ -1189,7 +1210,8 @@ public class ProjectorTest extends BaseEvaluatorTest {
TreeNode c1_Node = TreeBuilder.makeField(c1);
TreeNode c2_Node = TreeBuilder.makeField(c2);
- TreeNode unknown = TreeBuilder.makeFunction("xxx_yyy",
Lists.newArrayList(c1_Node, c2_Node), int8);
+ TreeNode unknown =
+ TreeBuilder.makeFunction("xxx_yyy", Lists.newArrayList(c1_Node,
c2_Node), int8);
ExpressionTree expr = TreeBuilder.makeExpression(unknown,
Field.nullable("result", int8));
Schema schema = new Schema(Lists.newArrayList(c1, c2));
boolean caughtException = false;
diff --git
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/expression/ArrowTypeHelperTest.java
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/expression/ArrowTypeHelperTest.java
index a79922c..c8a52b9 100644
---
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/expression/ArrowTypeHelperTest.java
+++
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/expression/ArrowTypeHelperTest.java
@@ -18,6 +18,11 @@
package org.apache.arrow.gandiva.expression;
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.gandiva.ipc.GandivaTypes;
import org.apache.arrow.vector.types.FloatingPointPrecision;
@@ -26,11 +31,6 @@ import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.Schema;
import org.junit.Test;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
public class ArrowTypeHelperTest {
private void testInt(int width, boolean isSigned, int expected) throws
GandivaException {
@@ -104,4 +104,3 @@ public class ArrowTypeHelperTest {
}
}
}
-
diff --git
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/expression/TreeBuilderTest.java
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/expression/TreeBuilderTest.java
index aa90e4a..390d720 100644
---
a/java/gandiva/src/test/java/org/apache/arrow/gandiva/expression/TreeBuilderTest.java
+++
b/java/gandiva/src/test/java/org/apache/arrow/gandiva/expression/TreeBuilderTest.java
@@ -18,6 +18,12 @@
package org.apache.arrow.gandiva.expression;
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.gandiva.ipc.GandivaTypes;
import org.apache.arrow.vector.types.FloatingPointPrecision;
@@ -25,12 +31,6 @@ import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.Field;
import org.junit.Test;
-import java.util.Arrays;
-import java.util.List;
-import java.util.ArrayList;
-
-import static org.junit.Assert.*;
-
public class TreeBuilderTest {
@Test
@@ -73,19 +73,23 @@ public class TreeBuilderTest {
public void testMakeNull() throws GandivaException {
TreeNode n = TreeBuilder.makeNull(new ArrowType.Bool());
GandivaTypes.TreeNode node = n.toProtobuf();
- assertEquals(GandivaTypes.GandivaType.BOOL_VALUE,
node.getNullNode().getType().getType().getNumber());
+ assertEquals(
+ GandivaTypes.GandivaType.BOOL_VALUE,
node.getNullNode().getType().getType().getNumber());
n = TreeBuilder.makeNull(new ArrowType.Int(32, true));
node = n.toProtobuf();
- assertEquals(GandivaTypes.GandivaType.INT32_VALUE,
node.getNullNode().getType().getType().getNumber());
+ assertEquals(
+ GandivaTypes.GandivaType.INT32_VALUE,
node.getNullNode().getType().getType().getNumber());
n = TreeBuilder.makeNull(new ArrowType.Int(64, false));
node = n.toProtobuf();
- assertEquals(GandivaTypes.GandivaType.UINT64_VALUE,
node.getNullNode().getType().getType().getNumber());
+ assertEquals(
+ GandivaTypes.GandivaType.UINT64_VALUE,
node.getNullNode().getType().getType().getNumber());
n = TreeBuilder.makeNull(new
ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE));
node = n.toProtobuf();
- assertEquals(GandivaTypes.GandivaType.FLOAT_VALUE,
node.getNullNode().getType().getType().getNumber());
+ assertEquals(
+ GandivaTypes.GandivaType.FLOAT_VALUE,
node.getNullNode().getType().getType().getNumber());
}
@Test
@@ -94,7 +98,9 @@ public class TreeBuilderTest {
GandivaTypes.TreeNode node = n.toProtobuf();
assertEquals("a", node.getFieldNode().getField().getName());
- assertEquals(GandivaTypes.GandivaType.INT32_VALUE,
node.getFieldNode().getField().getType().getType().getNumber());
+ assertEquals(
+ GandivaTypes.GandivaType.INT32_VALUE,
+ node.getFieldNode().getField().getType().getType().getNumber());
}
@Test
@@ -112,7 +118,9 @@ public class TreeBuilderTest {
assertEquals("add", node.getFnNode().getFunctionName());
assertEquals("a",
node.getFnNode().getInArgsList().get(0).getFieldNode().getField().getName());
assertEquals("b",
node.getFnNode().getInArgsList().get(1).getFieldNode().getField().getName());
- assertEquals(GandivaTypes.GandivaType.UINT64_VALUE,
node.getFnNode().getReturnType().getType().getNumber());
+ assertEquals(
+ GandivaTypes.GandivaType.UINT64_VALUE,
+ node.getFnNode().getReturnType().getType().getNumber());
}
@Test
@@ -135,7 +143,9 @@ public class TreeBuilderTest {
assertEquals("greater_than",
node.getIfNode().getCond().getFnNode().getFunctionName());
assertEquals(a.getName(),
node.getIfNode().getThenNode().getFieldNode().getField().getName());
assertEquals(b.getName(),
node.getIfNode().getElseNode().getFieldNode().getField().getName());
- assertEquals(GandivaTypes.GandivaType.BOOL_VALUE,
node.getIfNode().getReturnType().getType().getNumber());
+ assertEquals(
+ GandivaTypes.GandivaType.BOOL_VALUE,
+ node.getIfNode().getReturnType().getType().getNumber());
}
@Test
@@ -191,9 +201,11 @@ public class TreeBuilderTest {
GandivaTypes.ExpressionRoot root = expr.toProtobuf();
assertTrue(root.getRoot().hasIfNode());
- assertEquals("greater_than",
root.getRoot().getIfNode().getCond().getFnNode().getFunctionName());
+ assertEquals(
+ "greater_than",
root.getRoot().getIfNode().getCond().getFnNode().getFunctionName());
assertEquals("c", root.getResultType().getName());
- assertEquals(GandivaTypes.GandivaType.BOOL_VALUE,
root.getResultType().getType().getType().getNumber());
+ assertEquals(
+ GandivaTypes.GandivaType.BOOL_VALUE,
root.getResultType().getType().getType().getNumber());
}
@Test
@@ -215,7 +227,9 @@ public class TreeBuilderTest {
assertEquals("add", node.getFnNode().getFunctionName());
assertEquals("a",
node.getFnNode().getInArgsList().get(0).getFieldNode().getField().getName());
assertEquals("b",
node.getFnNode().getInArgsList().get(1).getFieldNode().getField().getName());
- assertEquals(GandivaTypes.GandivaType.UINT64_VALUE,
node.getFnNode().getReturnType().getType().getNumber());
+ assertEquals(
+ GandivaTypes.GandivaType.UINT64_VALUE,
+ node.getFnNode().getReturnType().getType().getNumber());
}
@Test
@@ -227,14 +241,18 @@ public class TreeBuilderTest {
args.add(b);
TreeNode andNode = TreeBuilder.makeAnd(args);
- ExpressionTree expr = TreeBuilder.makeExpression(andNode,
Field.nullable("c", new ArrowType.Bool()));
+ ExpressionTree expr =
+ TreeBuilder.makeExpression(andNode, Field.nullable("c", new
ArrowType.Bool()));
GandivaTypes.ExpressionRoot root = expr.toProtobuf();
assertTrue(root.getRoot().hasAndNode());
- assertEquals("a",
root.getRoot().getAndNode().getArgsList().get(0).getFieldNode().getField().getName());
- assertEquals("b",
root.getRoot().getAndNode().getArgsList().get(1).getFieldNode().getField().getName());
+ assertEquals(
+ "a",
root.getRoot().getAndNode().getArgsList().get(0).getFieldNode().getField().getName());
+ assertEquals(
+ "b",
root.getRoot().getAndNode().getArgsList().get(1).getFieldNode().getField().getName());
assertEquals("c", root.getResultType().getName());
- assertEquals(GandivaTypes.GandivaType.BOOL_VALUE,
root.getResultType().getType().getType().getNumber());
+ assertEquals(
+ GandivaTypes.GandivaType.BOOL_VALUE,
root.getResultType().getType().getType().getNumber());
}
@Test
@@ -246,14 +264,18 @@ public class TreeBuilderTest {
args.add(b);
TreeNode orNode = TreeBuilder.makeOr(args);
- ExpressionTree expr = TreeBuilder.makeExpression(orNode,
Field.nullable("c", new ArrowType.Bool()));
+ ExpressionTree expr =
+ TreeBuilder.makeExpression(orNode, Field.nullable("c", new
ArrowType.Bool()));
GandivaTypes.ExpressionRoot root = expr.toProtobuf();
assertTrue(root.getRoot().hasOrNode());
- assertEquals("a",
root.getRoot().getOrNode().getArgsList().get(0).getFieldNode().getField().getName());
- assertEquals("b",
root.getRoot().getOrNode().getArgsList().get(1).getFieldNode().getField().getName());
+ assertEquals(
+ "a",
root.getRoot().getOrNode().getArgsList().get(0).getFieldNode().getField().getName());
+ assertEquals(
+ "b",
root.getRoot().getOrNode().getArgsList().get(1).getFieldNode().getField().getName());
assertEquals("c", root.getResultType().getName());
- assertEquals(GandivaTypes.GandivaType.BOOL_VALUE,
root.getResultType().getType().getType().getNumber());
+ assertEquals(
+ GandivaTypes.GandivaType.BOOL_VALUE,
root.getResultType().getType().getType().getNumber());
}
@Test
@@ -273,8 +295,26 @@ public class TreeBuilderTest {
GandivaTypes.Condition conditionProto = condition.toProtobuf();
assertTrue(conditionProto.getRoot().hasFnNode());
assertEquals("greater_than",
conditionProto.getRoot().getFnNode().getFunctionName());
- assertEquals("a",
conditionProto.getRoot().getFnNode().getInArgsList().get(0).getFieldNode().getField().getName());
- assertEquals("b",
conditionProto.getRoot().getFnNode().getInArgsList().get(1).getFieldNode().getField().getName());
+ assertEquals(
+ "a",
+ conditionProto
+ .getRoot()
+ .getFnNode()
+ .getInArgsList()
+ .get(0)
+ .getFieldNode()
+ .getField()
+ .getName());
+ assertEquals(
+ "b",
+ conditionProto
+ .getRoot()
+ .getFnNode()
+ .getInArgsList()
+ .get(1)
+ .getFieldNode()
+ .getField()
+ .getName());
}
@Test
@@ -287,8 +327,25 @@ public class TreeBuilderTest {
GandivaTypes.Condition conditionProto = condition.toProtobuf();
assertTrue(conditionProto.getRoot().hasFnNode());
assertEquals("greater_than",
conditionProto.getRoot().getFnNode().getFunctionName());
- assertEquals("a",
conditionProto.getRoot().getFnNode().getInArgsList().get(0).getFieldNode().getField().getName());
- assertEquals("b",
conditionProto.getRoot().getFnNode().getInArgsList().get(1).getFieldNode().getField().getName());
+ assertEquals(
+ "a",
+ conditionProto
+ .getRoot()
+ .getFnNode()
+ .getInArgsList()
+ .get(0)
+ .getFieldNode()
+ .getField()
+ .getName());
+ assertEquals(
+ "b",
+ conditionProto
+ .getRoot()
+ .getFnNode()
+ .getInArgsList()
+ .get(1)
+ .getFieldNode()
+ .getField()
+ .getName());
}
}
-
diff --git a/java/gandiva/src/test/resources/logback.xml
b/java/gandiva/src/test/resources/logback.xml
new file mode 100644
index 0000000..9e23b55
--- /dev/null
+++ b/java/gandiva/src/test/resources/logback.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- 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. -->
+
+<configuration>
+ <logger name="org.apache.arrow" additivity="false">
+ <level value="info" />
+ <appender-ref ref="FILE" />
+ </logger>
+
+</configuration>
diff --git a/java/pom.xml b/java/pom.xml
index de35ff2..f6847ae 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -643,6 +643,21 @@
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
</profile>
+
+ <profile>
+ <!-- gandiva java depends on gandiva cpp, and gandiva cpp isn't enabled
by default yet -->
+ <id>gandiva</id>
+ <modules>
+ <module>format</module>
+ <module>memory</module>
+ <module>vector</module>
+ <module>tools</module>
+ <module>adapter/jdbc</module>
+ <module>plasma</module>
+ <module>flight</module>
+ <module>gandiva</module>
+ </modules>
+ </profile>
</profiles>
</project>