Class: Axiom::Relation::Materialized

Inherits:
Axiom::Relation show all
Defined in:
lib/axiom/relation/materialized.rb

Overview

A materialized relation

Direct Known Subclasses

Empty

Instance Attribute Summary collapse

Attributes inherited from Axiom::Relation

#header

Instance Method Summary collapse

Methods inherited from Axiom::Relation

#==, #[], #each, #empty?, #include?, new, #one, #replace

Methods included from Visitable

#accept

Constructor Details

#initialize(header, tuples, directions = Operation::Order::DirectionSet::EMPTY) ⇒ 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 materialized Relation

Parameters:

  • header (Header, #to_ary)

    the relation header

  • tuples (Enumerable)

    the relation tuples

  • directions (Operation::Order::DirectionSet) (defaults to: Operation::Order::DirectionSet::EMPTY)

    optional directions to sort the relation by



28
29
30
31
# File 'lib/axiom/relation/materialized.rb', line 28

def initialize(header, tuples, directions = Operation::Order::DirectionSet::EMPTY)
  super(header, tuples)
  @directions = Operation::Order::DirectionSet.coerce(directions)
end

Instance Attribute Details

#directionsOperation::Order::DirectionSet (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 sort order



14
15
16
# File 'lib/axiom/relation/materialized.rb', line 14

def directions
  @directions
end

Instance Method Details

#materializeself

A noop for Materialized relations

Examples:

materialized.materialize  # (Always returns self)

Returns:

  • (self)


41
42
43
# File 'lib/axiom/relation/materialized.rb', line 41

def materialize
  self
end

#materialized?true

Return true for a Materialized relation

Examples:

relation.materialized?  # => true

Returns:

  • (true)


53
54
55
# File 'lib/axiom/relation/materialized.rb', line 53

def materialized?
  true
end

#sizeInteger

Return the number of tuples

Examples:

materialized.size  # => 10

Returns:

  • (Integer)


65
66
67
# File 'lib/axiom/relation/materialized.rb', line 65

def size
  tuples.size
end