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



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
55
56
# File 'lib/trinamo/converter.rb', line 24

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



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

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) ⇒ Object



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

def load(ddl_yaml_path, format)
  case format
    when :hdfs then HdfsConverter.new(ddl_yaml_path)
    when :s3 then S3Converter.new(ddl_yaml_path)
    when :dynamodb then DynamodbConverter.new(ddl_yaml_path)
    when :option || :options then  load_options(ddl_yaml_path)
    else raise "[ERROR] Unknown format: #{format}" unless [:dynamodb, :hdfs, :s3].include(format)
  end
end

.load_options(options_yaml_path) ⇒ Object



20
21
22
# File 'lib/trinamo/converter.rb', line 20

def load_options(options_yaml_path)
  OptionConverter.new(options_yaml_path)
end