Class: Bmg::Operator::Image

Inherits:
Object
  • Object
show all
Includes:
Binary
Defined in:
lib/bmg/operator/image.rb

Overview

Image operator.

Extends each tuple with its image in right.

Constant Summary collapse

DEFAULT_OPTIONS =
{

  # Whether we need to convert each image as an Array,
  # instead of keeping a Relation instance
  array: false,

  # The strategy to use for actual image algorithm. Default is
  # :refilter_right. Possible values are:
  #
  # - :index_right : builds a memory index with tuples from right, then
  #   passes left tuples and joins them with the index values.
  #
  # - :refilter_right : the left operand is materialized and all
  #   distinct values collected. The right operand is lately restricted
  #   to only those matching values. :index_right is then applied on
  #   resulting operabds. This option only applies when (optimized) `on`
  #   contains one attribute only. ; it fallbacks on :index_right
  #   otherwise.
  strategy: :refilter_right

}

Instance Attribute Summary

Attributes included from Bmg::Operator

#type

Instance Method Summary collapse

Methods included from Binary

#bind

Methods included from Relation

#bind, #debug, #delete, empty, #empty?, #insert, new, #one, #one_or_nil, #to_csv, #to_json, #update, #visit, #with_typecheck, #without_typecheck, #y_by_x, #ys_by_x

Methods included from Algebra

#allbut, #autosummarize, #autowrap, #constants, #extend, #group, #image, #join, #left_join, #matching, #materialize, #not_matching, #page, #project, #rename, #restrict, #spied, #summarize, #transform, #union, #unspied

Methods included from Algebra::Shortcuts

#image, #join, #left_join, #matching, #not_matching, #prefix, #rxmatch, #suffix

Constructor Details

#initialize(type, left, right, as, on, options = {}) ⇒ Image

Returns a new instance of Image.



33
34
35
36
37
38
39
40
# File 'lib/bmg/operator/image.rb', line 33

def initialize(type, left, right, as, on, options = {})
  @type = type
  @left = left
  @right = right
  @as = as
  @on = on
  @options = DEFAULT_OPTIONS.merge(options)
end

Instance Method Details

#each(*args, &bl) ⇒ Object



48
49
50
# File 'lib/bmg/operator/image.rb', line 48

def each(*args, &bl)
  (options[:jit_optimized] ? self : jit_optimize)._each(*args, &bl)
end

#inspectObject



236
237
238
# File 'lib/bmg/operator/image.rb', line 236

def inspect
  options[:jit_optimized] ? super : jit_optimize.inspect
end

#to_astObject



52
53
54
# File 'lib/bmg/operator/image.rb', line 52

def to_ast
  [ :image, left.to_ast, right.to_ast, as, on, options.dup ]
end

#to_sObject



232
233
234
# File 'lib/bmg/operator/image.rb', line 232

def to_s
  options[:jit_optimized] ? super : jit_optimize.to_s
end