Class: Clusta::Transforms::EdgesToDegrees::Reducer

Inherits:
Wukong::Streamer::AccumulatingReducer
  • Object
show all
Includes:
Wukong::Streamer::StructRecordizer
Defined in:
lib/clusta/transforms/edges_to_degrees.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#degreeObject

Returns the value of attribute degree.



22
23
24
# File 'lib/clusta/transforms/edges_to_degrees.rb', line 22

def degree
  @degree
end

Instance Method Details

#accumulate(new_degree, *record) ⇒ Object



34
35
36
# File 'lib/clusta/transforms/edges_to_degrees.rb', line 34

def accumulate new_degree, *record
  self.degree += new_degree
end

#finalize(&block) ⇒ Object



38
39
40
# File 'lib/clusta/transforms/edges_to_degrees.rb', line 38

def finalize &block
  emit degree
end

#get_key(new_degree, *record) ⇒ Object



26
27
28
# File 'lib/clusta/transforms/edges_to_degrees.rb', line 26

def get_key new_degree, *record
  new_degree.vertex_label
end

#start!(new_degree, *record) ⇒ Object



30
31
32
# File 'lib/clusta/transforms/edges_to_degrees.rb', line 30

def start! new_degree, *record
  self.degree = (new_degree.directed? ? new_degree.class.new(key, 0, 0) : new_degree.class.new(key, 0))
end