Class: Wukong::Processor::Group
- Inherits:
-
Count
- Object
- Hanuman::Stage
- Wukong::Processor
- Accumulator
- Count
- Wukong::Processor::Group
- Includes:
- DynamicGet
- Defined in:
- lib/wukong/widget/reducers/group.rb
Overview
Groups sorted input records and emits each group with a count.
Allows you to use several ways of extracting the key that defines the group.
Note: The input records must be previously sorted by the same key used for grouping in order to ensure that groups are not split up.
A group fits nicely at the end of a dataflow. Since it requires a sort, it is blocking.
Direct Known Subclasses
Constant Summary
Constants inherited from Wukong::Processor
Instance Attribute Summary
Attributes inherited from Count
Attributes inherited from Accumulator
Instance Method Summary collapse
-
#finalize {|key, size| ... } ⇒ Object
Yields the current group along with its size.
-
#get_key(record) ⇒ Object
Get the key which defines the group for this
record
. -
#start(record) ⇒ Object
Reset the size counter for new group.
Methods included from DynamicGet
Methods inherited from Count
Methods inherited from Accumulator
Methods inherited from Wukong::Processor
configure, consumes, description, #expected_record_type, #expected_serialization, #perform_action, #process, produces, #receive_action, #setup, #stop, valid_serializer?, validate_and_set_serialization
Methods included from Logging
Methods included from Hanuman::StageClassMethods
#builder, #label, #register, #set_builder
Instance Method Details
#finalize {|key, size| ... } ⇒ Object
Yields the current group along with its size
121 122 123 |
# File 'lib/wukong/widget/reducers/group.rb', line 121 def finalize yield [key, size] end |
#get_key(record) ⇒ Object
Get the key which defines the group for this record
.
105 106 107 |
# File 'lib/wukong/widget/reducers/group.rb', line 105 def get_key(record) get(self.by, record) end |
#start(record) ⇒ Object
Reset the size counter for new group.
112 113 114 |
# File 'lib/wukong/widget/reducers/group.rb', line 112 def start record self.size = 0 end |