Class: PigSpec::JavaBridge
- Inherits:
-
Object
- Object
- PigSpec::JavaBridge
- Defined in:
- lib/pigspec/javabridge.rb
Overview
bridge for java pig classies
Instance Attribute Summary collapse
-
#data_type_enum ⇒ Object
readonly
Returns the value of attribute data_type_enum.
Instance Method Summary collapse
- #cluster ⇒ Object
- #context ⇒ Object
- #create_hdfs_temp ⇒ Object
- #create_test(script, *args) ⇒ Object
-
#initialize(pig_path, pigunit_path, options) ⇒ JavaBridge
constructor
A new instance of JavaBridge.
- #schema(alias_name) ⇒ Object
- #server ⇒ Object
- #stringify(alias_values) ⇒ Object
- #unload ⇒ Object
- #upload_text(text, path) ⇒ Object
Constructor Details
#initialize(pig_path, pigunit_path, options) ⇒ JavaBridge
Returns a new instance of JavaBridge.
8 9 10 11 |
# File 'lib/pigspec/javabridge.rb', line 8 def initialize(pig_path, pigunit_path, ) load_pig pig_path, pigunit_path, import_classies end |
Instance Attribute Details
#data_type_enum ⇒ Object (readonly)
Returns the value of attribute data_type_enum.
64 65 66 |
# File 'lib/pigspec/javabridge.rb', line 64 def data_type_enum @data_type_enum end |
Instance Method Details
#cluster ⇒ Object
43 44 45 |
# File 'lib/pigspec/javabridge.rb', line 43 def cluster @pig_test_class.getCluster end |
#context ⇒ Object
31 32 33 |
# File 'lib/pigspec/javabridge.rb', line 31 def context @pig_test_class.getPigServer.getPigContext end |
#create_hdfs_temp ⇒ Object
35 36 37 |
# File 'lib/pigspec/javabridge.rb', line 35 def create_hdfs_temp @file_localizer_class.getTemporaryPath(context).toString end |
#create_test(script, *args) ⇒ Object
26 27 28 29 |
# File 'lib/pigspec/javabridge.rb', line 26 def create_test(script, *args) instance = @pig_test_class.new script, args JavaPigTest.new self, instance end |
#schema(alias_name) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/pigspec/javabridge.rb', line 51 def schema(alias_name) raw_schema = server.dumpSchema(alias_name) builder = @string_builder_class.new @schema_class.stringifySchema(builder, raw_schema, @data_type_enum.TUPLE) str_schema = builder.toString return nil if str_schema.split("\n").join('') == '()' str_schema end |
#server ⇒ Object
39 40 41 |
# File 'lib/pigspec/javabridge.rb', line 39 def server @pig_test_class.getPigServer end |
#stringify(alias_values) ⇒ Object
60 61 62 |
# File 'lib/pigspec/javabridge.rb', line 60 def stringify(alias_values) @string_util_class.join(alias_values, "\n") end |
#unload ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pigspec/javabridge.rb', line 13 def unload @pig_test_class = nil @cluster_class = nil @file_localizer_class = nil @pig_server_class = nil @schema_class = nil @string_builder_class = nil @data_type_enum = nil @string_util_class = nil Rjb.unload GC.start end |
#upload_text(text, path) ⇒ Object
47 48 49 |
# File 'lib/pigspec/javabridge.rb', line 47 def upload_text(text, path) cluster.copyFromLocalFile(text, path, true) end |