Class: Clusta::Transforms::PruneEdges::Mapper

Inherits:
Wukong::Streamer::StructStreamer
  • Object
show all
Defined in:
lib/clusta/transforms/prune_edges.rb

Instance Method Summary collapse

Instance Method Details

#before_streamObject

Raises:



15
16
17
# File 'lib/clusta/transforms/prune_edges.rb', line 15

def before_stream
  raise ArgumentError.new("Must specify either a min_weight or a max_weight") if Settings[:min_weight].nil? && Settings[:max_weight].nil?
end

#process(edge, *record) ⇒ Object



25
26
27
# File 'lib/clusta/transforms/prune_edges.rb', line 25

def process edge, *record
  emit(edge) if edge.weighted? && within_weight_range?(edge)
end

#within_weight_range?(edge) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/clusta/transforms/prune_edges.rb', line 19

def within_weight_range? edge
  return false if Settings[:min_weight] && Settings[:min_weight] > edge.weight.to_f
  return false if Settings[:max_weight] && Settings[:max_weight] < edge.weight.to_f
  true
end