class Axiom::Adapter::Arango::Visitor::For::Summarization

Visitor for axiom summarizations

Constants

COLLECT_NAME
LOCAL_NAME

Private Instance Methods

assignments() click to toggle source

Return collection assignments

@return [Enumerable<AQL::Node::Operator::Assignment>]

@api private

# File lib/axiom/adapter/arango/visitor/for/summarization.rb, line 34
def assignments
  input.summarize_per.header.map do |attribute|
    name = AQL::Node::Name.new(attribute.name.to_s)
    value = AQL::Node::Attribute.new(LOCAL_NAME, name)
    AQL::Node::Operator::Assignment.new(
      name,
      value
    )
  end
end
body() click to toggle source

Return body of for operation

@return [AQL::Node::Block]

@api private

# File lib/axiom/adapter/arango/visitor/for/summarization.rb, line 21
def body
  AQL::Node::Block.new([
    collect_operation,
    return_operation
  ])
end
collect_operation() click to toggle source

Return collect operation

@return [AQL::Node::Operation::Nary::Collect::Into]

@api private

# File lib/axiom/adapter/arango/visitor/for/summarization.rb, line 104
def collect_operation
  AQL::Node::Operation::Nary::Collect::Into.new(assignments, COLLECT_NAME)
end
extension_document_attribute(attribute, summarizer) click to toggle source

Return extension document attribute

@param [Attribute] attribute @param [Aggregate] summarizer

@return [AQL::Node::Literal::Composed::Document::Attribute]

@api private

# File lib/axiom/adapter/arango/visitor/for/summarization.rb, line 77
def extension_document_attribute(attribute, summarizer)
  key = AQL::Node::Literal::Primitive::String.new(attribute.name.to_s)
  value = visit(summarizer)
  AQL::Node::Literal::Composed::Document::Attribute.new(key, value)
end
extension_document_attributes() click to toggle source

Return extension document attributes

@return [Enumerable<AQL::Node::Literal::Composed::Document::Attribute>]

@api private

# File lib/axiom/adapter/arango/visitor/for/summarization.rb, line 62
def extension_document_attributes
  input.summarizers.map do |attribute, summarizer|
    extension_document_attribute(attribute, summarizer)
  end
end
projected_document_attributes() click to toggle source

Return projected document attributes

@return [Enumerable<AQL::Node::Literal::Composed::Document::Attribute>]

@api private

# File lib/axiom/adapter/arango/visitor/for/summarization.rb, line 89
def projected_document_attributes
  assignments.map do |assignment|
    value = assignment.name
    key   = AQL::Node::Literal::Primitive::String.new(value.name)
    AQL::Node::Literal::Composed::Document::Attribute.new(key, value)
  end
end
return_value() click to toggle source

Return AQL return value

@return [AQL::Node::Literal::Composed::Document]

@api private

# File lib/axiom/adapter/arango/visitor/for/summarization.rb, line 52
def return_value
  AQL::Node::Literal::Composed::Document.new(projected_document_attributes + extension_document_attributes)
end