Class: Axiom::Algebra::Summarization

Inherits:
Relation
  • Object
show all
Includes:
Relation::Operation::Unary
Defined in:
lib/axiom/algebra/summarization.rb,
lib/axiom/algebra/summarization/summary.rb,
lib/axiom/algebra/summarization/summaries.rb

Overview

Summarize a relation by specific attributes

Defined Under Namespace

Modules: Methods Classes: Summaries, Summary

Instance Attribute Summary collapse

Attributes included from Operation::Unary

#operand

Attributes inherited from Relation

#header

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Relation

#==, #[], #directions, #empty?, #include?, #materialize, #materialized?, #replace

Methods included from Visitable

#accept

Constructor Details

#initialize(operand, summarize_per, summarizers) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a Summarization

Parameters:

  • operand (Relation)

    the relation to summarize

  • summarize_per (Relation)

    the relation to summarize with

  • summarizers (#to_hash)

    the summarizers to add



76
77
78
79
80
81
# File 'lib/axiom/algebra/summarization.rb', line 76

def initialize(operand, summarize_per, summarizers)
  super(operand)
  @summarize_per = summarize_per
  @summarizers   = summarizers
  @header        = @summarize_per.header | @summarizers.keys
end

Instance Attribute Details

#summarize_perRelation (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The relation to summarize with

Returns:



16
17
18
# File 'lib/axiom/algebra/summarization.rb', line 16

def summarize_per
  @summarize_per
end

#summarizersHash (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The summarizers for the relation

Returns:

  • (Hash)


23
24
25
# File 'lib/axiom/algebra/summarization.rb', line 23

def summarizers
  @summarizers
end

Class Method Details

.new(operand, summarize_per, _summarizers) ⇒ Summarization

Instantiate a new Summarization

Examples:

summarization = Summarization.new(operand, summarize_per, summarizers)

Parameters:

  • operand (Relation)

    the relation to summarize

  • summarize_per (Relation)

    the relation to summarize with

  • _summarizers (#to_hash)

    the summarizers to add

Returns:



40
41
42
43
# File 'lib/axiom/algebra/summarization.rb', line 40

def self.new(operand, summarize_per, _summarizers)
  assert_subset_headers(operand, summarize_per)
  super
end

Instance Method Details

#deleteundefined

Raise an exception when deleting from a Summarization

Examples:

summarization.delete(other)  # => ImmutableRelationError raised

Returns:

  • (undefined)

Raises:



129
130
131
# File 'lib/axiom/algebra/summarization.rb', line 129

def delete(*)
  fail ImmutableRelationError, 'deleting from a summarization is impossible'
end

#each {|tuple| ... } ⇒ self

Iterate over each tuple in the set

Examples:

summarization = Summarization.new(self, relation, context.functions)
summarization.each { |tuple| ... }

Yields:

  • (tuple)

Yield Parameters:

  • tuple (Tuple)

    each tuple in the set

Returns:

  • (self)


97
98
99
100
101
# File 'lib/axiom/algebra/summarization.rb', line 97

def each
  return to_enum unless block_given?
  summarize_per.extend(summaries).each { |tuple| yield tuple }
  self
end

#insertundefined

Raise an exception when inserting into a Summarization

Examples:

summarization.insert(other)  # => ImmutableRelationError raised

Returns:

  • (undefined)

Raises:



114
115
116
# File 'lib/axiom/algebra/summarization.rb', line 114

def insert(*)
  fail ImmutableRelationError, 'inserting into a summarization is impossible'
end