Class: Arrow::Group
- Inherits:
-
Object
- Object
- Arrow::Group
- Defined in:
- lib/arrow/group.rb
Instance Method Summary collapse
- #aggregate(aggregation, *more_aggregations) ⇒ Object
- #count(*target_names) ⇒ Object
-
#initialize(table, keys) ⇒ Group
constructor
A new instance of Group.
- #max(*target_names) ⇒ Object
- #mean(*target_names) ⇒ Object
- #min(*target_names) ⇒ Object
- #product(*target_names) ⇒ Object
- #stddev(*target_names) ⇒ Object
- #sum(*target_names) ⇒ Object
- #variance(*target_names) ⇒ Object
Constructor Details
#initialize(table, keys) ⇒ Group
Returns a new instance of Group.
20 21 22 23 |
# File 'lib/arrow/group.rb', line 20 def initialize(table, keys) @table = table @keys = keys end |
Instance Method Details
#aggregate(aggregation, *more_aggregations) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/arrow/group.rb', line 57 def aggregate(aggregation, *more_aggregations) aggregations = [aggregation] + more_aggregations normalized_aggregations = normalize_aggregations(aggregations) plan = ExecutePlan.new source_node = plan.build_source_node(@table) aggregate_node = plan.build_aggregate_node(source_node, { aggregations: normalized_aggregations, keys: @keys }) = SinkNodeOptions.new plan.build_sink_node(aggregate_node, ) plan.validate plan.start plan.wait reader = .get_reader(aggregate_node.output_schema) reader.read_all end |
#count(*target_names) ⇒ Object
25 26 27 |
# File 'lib/arrow/group.rb', line 25 def count(*target_names) aggregate(*build_aggregations("hash_count", target_names)) end |
#max(*target_names) ⇒ Object
45 46 47 |
# File 'lib/arrow/group.rb', line 45 def max(*target_names) aggregate(*build_aggregations("hash_max", target_names)) end |
#mean(*target_names) ⇒ Object
37 38 39 |
# File 'lib/arrow/group.rb', line 37 def mean(*target_names) aggregate(*build_aggregations("hash_mean", target_names)) end |
#min(*target_names) ⇒ Object
41 42 43 |
# File 'lib/arrow/group.rb', line 41 def min(*target_names) aggregate(*build_aggregations("hash_min", target_names)) end |
#product(*target_names) ⇒ Object
33 34 35 |
# File 'lib/arrow/group.rb', line 33 def product(*target_names) aggregate(*build_aggregations("hash_product", target_names)) end |
#stddev(*target_names) ⇒ Object
49 50 51 |
# File 'lib/arrow/group.rb', line 49 def stddev(*target_names) aggregate(*build_aggregations("hash_stddev", target_names)) end |
#sum(*target_names) ⇒ Object
29 30 31 |
# File 'lib/arrow/group.rb', line 29 def sum(*target_names) aggregate(*build_aggregations("hash_sum", target_names)) end |
#variance(*target_names) ⇒ Object
53 54 55 |
# File 'lib/arrow/group.rb', line 53 def variance(*target_names) aggregate(*build_aggregations("hash_variance", target_names)) end |