Class: Swineherd::Script::PigScript

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/swineherd/script/pig_script.rb

Constant Summary collapse

AVRO_PIG_MAPPING =

Not guaranteeing anything.

{
  'string' => 'chararray',
  'int'    => 'int',
  'long'   => 'long',
  'float'  => 'float',
  'double' => 'double',
  'bytes'  => 'bytearray',
  'fixed'  => 'bytearray'
}

Instance Attribute Summary

Attributes included from Common

#attributes, #input, #options, #output

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

#env, #initialize, #refresh!, #run, #script

Class Method Details

.avro_to_pig(avro_type) ⇒ Object

Simple utility function for mapping avro types to pig types



21
22
23
# File 'lib/swineherd/script/pig_script.rb', line 21

def self.avro_to_pig avro_type
  AVRO_PIG_MAPPING[avro_type]
end

Instance Method Details

#cmdObject



40
41
42
43
# File 'lib/swineherd/script/pig_script.rb', line 40

def cmd
  Log.info("Launching Pig script in hadoop mode")
  "pig #{pig_args(@options)} #{script}"
end

#local_cmdObject



35
36
37
38
# File 'lib/swineherd/script/pig_script.rb', line 35

def local_cmd
  Log.info("Launching Pig script in local mode")
  "pig -x local #{pig_args(@options)} #{script}"
end

#pig_args(options) ⇒ Object

Convert a generic hash of options => ‘bar’ into command line options for pig ‘-p FOO=bar’



29
30
31
# File 'lib/swineherd/script/pig_script.rb', line 29

def pig_args options
  options.map{|opt,val| "-p #{opt.to_s.upcase}=#{val}" }.join(' ')
end