tree: 5371fd12447eab4e8f721c3b439f5a1a620cdced [path history] [tgz]
  1. dependency-check/
  2. lib/
  3. test/
  4. .gitignore
  5. Gemfile
  6. LICENSE.txt
  7. NOTICE.txt
  8. Rakefile
  9. README.md
  10. red-gandiva.gemspec
ruby/red-gandiva/README.md

Red Gandiva - Gandiva Ruby

Red Gandiva is the Ruby bindings of Gandiva. Red Gandiva is based on GObject Introspection.

Gandiva is a toolset for compiling and evaluating expressions on Arrow data.

GObject Introspection is a middleware for language bindings of C library. GObject Introspection can generate language bindings automatically at runtime.

Red Gandiva uses Gandiva GLib and gobject-introspection gem to generate Ruby bindings of Gandiva.

Gandiva GLib is a C wrapper for Gandiva C++. GObject Introspection can't use Gandiva C++ directly. Gandiva GLib is a bridge between Gandiva C++ and GObject Introspection.

gobject-introspection gem is a Ruby bindings of GObject Introspection. Red Gandiva uses GObject Introspection via gobject-introspection gem.

Install

Install Gandiva GLib before install Red Gandiva. See Apache Arrow install document for details.

Install Red Gandiva after you install Gandiva GLib:

% gem install red-gandiva

Usage

require "gandiva"

field1 = Arrow::Field.new("field1", Arrow::Int32DataType.new)
field2 = Arrow::Field.new("field2", Arrow::Int32DataType.new)
schema = Arrow::Schema.new([field1, field2])
add_result = Arrow::Field.new("add_result", Arrow::Int32DataType.new)
subtract_result = Arrow::Field.new("subtract_result", Arrow::Int32DataType.new)
add_expression = Gandiva::Expression.new("add", [field1, field2], add_result)
subtract_expression = Gandiva::Expression.new("subtract", [field1, field2], subtract_result)
projector = Gandiva::Projector.new(schema, [add_expression, subtract_expression])
input_arrays = [
  Arrow::Int32Array.new([1, 2, 3, 4]),
  Arrow::Int32Array.new([11, 13, 15, 17]),
]
record_batch = Arrow::RecordBatch.new(schema, 4, input_arrays)
output_arrays = projector.evaluate(record_batch)