You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/01 04:05:42 UTC

[GitHub] [arrow] wjones127 commented on a diff in pull request #14200: ARROW-17812: [Gandiva][Docs] Add C++ Gandiva User Guide

wjones127 commented on code in PR #14200:
URL: https://github.com/apache/arrow/pull/14200#discussion_r1010052146


##########
docs/source/cpp/gandiva.rst:
##########
@@ -0,0 +1,158 @@
+.. 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.
+
+.. default-domain:: cpp
+.. highlight:: cpp
+.. cpp:namespace:: gandiva
+
+===============================
+The Gandiva Expression Compiler
+===============================
+
+Gandiva is a runtime expression compiler that uses `LLVM`_ to generate
+efficient native code for compute on Arrow record batches.
+Gandiva only handles projections and filters; for other transformations, see
+:ref:`Compute Functions <compute-cpp>`.
+
+Gandiva was designed to take advantage of the Arrow memory format and modern
+hardware. From the Arrow memory model, since Arrow arrays have separate buffers for values and 
+validity bitmaps, values and their null status can often be processed 
+independently, allowing for better instruction pipelining. On modern hardware,
+compiling expressions using LLVM allows the execution to be optimized
+to the local runtime environment and hardware, including available SIMD
+instructions. To reduce optimization overhead, many Gandiva functions are
+pre-compiled into LLVM IR (intermediate representation).
+
+.. _LLVM: https://llvm.org/
+
+
+Building Expressions
+====================
+
+Gandiva provides a general expression representation where expressions are
+represented by a tree of nodes. The expression trees are built using
+:class:`TreeExprBuilder`. The leaves of the expression tree are typically
+field references, created by :func:`TreeExprBuilder::MakeField`, and
+literal values, created by :func:`TreeExprBuilder::MakeLiteral`. Nodes
+can be combined into more complex expression trees using:
+
+* :func:`TreeExprBuilder::MakeFunction` to create a function
+  node. (You can call :func:`GetRegisteredFunctionSignatures` to 
+  get a list of valid function signatures.)
+* :func:`TreeExprBuilder::MakeIf` to create if-else logic.
+* :func:`TreeExprBuilder::MakeAnd` and :func:`TreeExprBuilder::MakeOr`
+  to create boolean expressions. (For "not", use the ``not(bool)`` function in ``MakeFunction``.)
+* :func:`TreeExprBuilder::MakeInExpressionInt32` and the other "in expression"
+  functions to create set membership tests.
+
+Each of these functions create new composite nodes, which contain the leaf nodes
+(literals and field references) or other composite nodes as children. By 
+composing these, you can create arbitrarily complex expression trees.
+
+Once an expression tree is built, they are wrapped in either :class:`Expression`
+or :class:`Condition`, depending on how they will be used.
+``Expression`` is used in projections while ``Condition`` is used filters.

Review Comment:
   ```suggestion
   ``Expression`` is used in projections while ``Condition`` is used in filters.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org