Class: Trinamo::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/trinamo/converter.rb

Class Method Summary collapse

Class Method Details

.generate_ddl_template(out_file_path = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/trinamo/converter.rb', line 22

def generate_ddl_template(out_file_path = nil)
  template = "    tables:\n      - name: comments\n        s3_location: s3://path/to/s3/table/location\n        s3_partition:\n          - name: date\n            type: string\n        hash_key:\n          - name: user_id\n            type: bigint\n        range_key:\n          - name: comment_id\n            type: bigint\n        attributes:\n          - name: title\n            type: string\n          - name: content\n            type: string\n          - name: rate\n            type: double\n      - name: authors\n        hash_key:\n          - name: author_id\n            type: bigint\n        attributes:\n          - name: name\n            type: string\n  TEMPLATE\n\n  File.binwrite(out_file_path, template) if out_file_path\n  template\nend\n".unindent

.generate_options_template(out_file_path = nil) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/trinamo/converter.rb', line 56

def generate_options_template(out_file_path = nil)
  template = "    options:\n      dynamodb.throughput.read.percent: 0.5\n      hive.exec.compress.output: true\n      io.seqfile.compression.type: BLOCK\n      mapred.output.compression.codec: com.hadoop.compression.lzo.LzoCodec\n  TEMPLATE\n\n  File.binwrite(out_file_path, template) if out_file_path\n  template\nend\n".unindent

.load(ddl_yaml_path, format = nil, ddl = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/trinamo/converter.rb', line 11

def load(ddl_yaml_path, format = nil, ddl = nil)
  case format
    when :hdfs then HdfsConverter.new(ddl_yaml_path, ddl)
    when :s3 then S3Converter.new(ddl_yaml_path, ddl)
    when :dynamodb then DynamodbConverter.new(ddl_yaml_path, ddl)
    when :option then OptionConverter.new(ddl_yaml_path, ddl)
    when nil then BaseConverter.new(ddl_yaml_path, ddl)
    else raise "[ERROR] Unknown format: #{format}"
  end
end