Class: Cascading::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/cascading/scope.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope) ⇒ Scope

Returns a new instance of Scope.



5
6
7
# File 'lib/cascading/scope.rb', line 5

def initialize(scope)
  @scope = scope
end

Instance Attribute Details

#scopeObject

Returns the value of attribute scope.



3
4
5
# File 'lib/cascading/scope.rb', line 3

def scope
  @scope
end

Class Method Details

.empty_scope(name) ⇒ Object



17
18
19
# File 'lib/cascading/scope.rb', line 17

def self.empty_scope(name)
  Scope.new(Java::CascadingFlowPlanner::Scope.new(name))
end

.flow_scope(name) ⇒ Object



13
14
15
# File 'lib/cascading/scope.rb', line 13

def self.flow_scope(name)
  Java::CascadingFlowPlanner::Scope.new(name)
end

.outgoing_scope(flow_element, incoming_scopes) ⇒ Object



30
31
32
33
# File 'lib/cascading/scope.rb', line 30

def self.outgoing_scope(flow_element, incoming_scopes)
  java_scopes = incoming_scopes.compact.map{ |s| s.scope }
  Scope.new(outgoing_scope_for(flow_element, java.util.HashSet.new(java_scopes)))
end

.source_scope(name, tap, flow_scope) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/cascading/scope.rb', line 21

def self.source_scope(name, tap, flow_scope)
  incoming_scopes = java.util.HashSet.new
  incoming_scopes.add(flow_scope)
  java_scope = outgoing_scope_for(tap, incoming_scopes)
  # Taps and Pipes don't name their outgoing scopes like other FlowElements
  java_scope.name = name
  Scope.new(java_scope)
end

Instance Method Details

#copyObject



9
10
11
# File 'lib/cascading/scope.rb', line 9

def copy
  Scope.new(Java::CascadingFlowPlanner::Scope.new(@scope))
end

#grouping_fieldsObject



39
40
41
# File 'lib/cascading/scope.rb', line 39

def grouping_fields
  @scope.out_grouping_fields
end

#scope_fields_to_s(accessor) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/cascading/scope.rb', line 43

def scope_fields_to_s(accessor)
  begin
    fields = @scope.send(accessor)
    fields.nil? ? 'null' : fields.to_s
  rescue
    'ERROR'
  end
end

#to_sObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cascading/scope.rb', line 52

def to_s
  kind = 'Unknown'
  kind = 'Tap'   if @scope.tap?
  kind = 'Group' if @scope.group?
  kind = 'Each'  if @scope.each?
  kind = 'Every' if @scope.every?
  <<-END
Scope name: #{@scope.name}
  Kind: #{kind}
  Key selectors:     #{scope_fields_to_s(:key_selectors)}
  Sorting selectors: #{scope_fields_to_s(:sorting_selectors)}
  Remainder fields:  #{scope_fields_to_s(:remainder_fields)}
  Declared fields:   #{scope_fields_to_s(:declared_fields)}
  Arguments
selector:   #{scope_fields_to_s(:arguments_selector)}
declarator: #{scope_fields_to_s(:arguments_declarator)}
  Out grouping
selector:   #{scope_fields_to_s(:out_grouping_selector)}
fields:     #{scope_fields_to_s(:out_grouping_fields)}
key fields: #{scope_fields_to_s(:key_selectors)}
  Out values
selector: #{scope_fields_to_s(:out_values_selector)}
fields:   #{scope_fields_to_s(:out_values_fields)}
END
end

#values_fieldsObject



35
36
37
# File 'lib/cascading/scope.rb', line 35

def values_fields
  @scope.out_values_fields
end