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,

  # Whether the attributes on which the join is made should be kept
  # in the result or not
  preserve: false

}

Instance Attribute Summary

Attributes included from Bmg::Operator

#type

Instance Method Summary collapse

Methods included from Binary

#bind

Methods included from Relation

#bind, #count, #debug, #delete, empty, #empty?, #insert, new, #one, #one_or_nil, #to_csv, #to_json, #to_xlsx, #type, #update, #visit, #with_type, #with_type_attrlist, #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, #ungroup, #union, #unspied, #unwrap

Methods included from Algebra::Shortcuts

#exclude, #image, #images, #join, #left_join, #matching, #not_matching, #prefix, #rxmatch, #suffix, #ungroup, #unwrap, #where

Constructor Details

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

Returns a new instance of Image.



37
38
39
40
41
42
43
44
# File 'lib/bmg/operator/image.rb', line 37

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

#_countObject



166
167
168
# File 'lib/bmg/operator/image.rb', line 166

def _count
  left._count
end

#each(*args, &bl) ⇒ Object



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

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

#inspectObject



280
281
282
# File 'lib/bmg/operator/image.rb', line 280

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

#to_astObject



57
58
59
# File 'lib/bmg/operator/image.rb', line 57

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

#to_sObject



276
277
278
# File 'lib/bmg/operator/image.rb', line 276

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