Class: Axiom::Algebra::Summarization::Summary

Inherits:
Object
  • Object
show all
Defined in:
lib/axiom/algebra/summarization/summary.rb

Overview

The summary for an aggregate function grouped by tuple

Instance Method Summary collapse

Constructor Details

#initialize(summarizer) ⇒ 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 Summary

Parameters:

  • summarizer (#call)


17
18
19
20
# File 'lib/axiom/algebra/summarization/summary.rb', line 17

def initialize(summarizer)
  @summarizer = summarizer
  @summary    = Hash.new(summary_default)
end

Instance Method Details

#call(tuple) ⇒ Object

Return the finalized summary for a tuple

Examples:

object = summary.call(tuple)

Parameters:

Returns:

  • (Object)


50
51
52
# File 'lib/axiom/algebra/summarization/summary.rb', line 50

def call(tuple)
  summary_finalize(@summary[tuple])
end

#summarize_by(projection, tuple) ⇒ self

Summarize the aggregate function by a tuple

Examples:

summary = summary.summarize_by(projection, tuple)

Parameters:

  • projection (Tuple)

    the tuple projection to summarize the results by

  • tuple (Tuple)

    the tuple to execute the aggregate function with

Returns:

  • (self)


35
36
37
38
# File 'lib/axiom/algebra/summarization/summary.rb', line 35

def summarize_by(projection, tuple)
  @summary[projection] = @summarizer.call(@summary[projection], tuple)
  self
end