Created
October 6, 2014 21:51
-
-
Save alienrobotwizard/d31d1090ffe63e551c25 to your computer and use it in GitHub Desktop.
PigNode view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PigNode < Mustache | |
attr_accessor :properties | |
def initialize properties | |
@properties = properties | |
end | |
def operation | |
properties['operation'] | |
end | |
def additional_info | |
if properties['macro'] | |
return " (MACRO: #{properties['macro']})" | |
end | |
if properties['limit'] | |
return " (#{properties['limit']})" | |
end | |
if properties['join'] && | |
properties['join']['strategy'] && | |
properties['join']['type'] | |
strategy = properties['join']['strategy'] | |
type = properties['join']['type'] | |
return " (#{type}, #{strategy})" | |
end | |
end | |
def step_type_color | |
case properties['step_type'] | |
when 'mapper' then | |
return "#3299BB" | |
when 'reducer' then | |
return "#FF9900" | |
when 'tez' then | |
return "#F5D04C" | |
else | |
return "#BF0A0D" | |
end | |
end | |
def alias | |
properties['alias'] | |
end | |
def expression | |
properties['expression'] | |
end | |
def storage_location | |
properties['storage_location'] | |
end | |
def storage_function | |
properties['storage_function'] | |
end | |
def join | |
j = properties['join'] | |
if j && j['by'] | |
relations = j['by'].map{|rel| rel['alias']} | |
fields = [] | |
j['by'].first['fields'].each_with_index do |field, idx| | |
fields[idx] = [] | |
j['by'].each do |rel| | |
fields[idx] << rel['fields'][idx] | |
end | |
end | |
result = { | |
:relations => relations, | |
:by => fields.map{|field_list| {:fields => field_list}} | |
} | |
return result | |
end | |
end | |
def schema | |
properties['schema'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment