class Grn2Drn::SchemaConverter::Table

Public Class Methods

new(table_create_command) click to toggle source
# File lib/grn2drn/schema-converter.rb, line 86
def initialize(table_create_command)
  @command = table_create_command
  @columns = {}
end

Public Instance Methods

add_column(name, column) click to toggle source
# File lib/grn2drn/schema-converter.rb, line 91
def add_column(name, column)
  @columns[name] = column
end
to_droonga_schema() click to toggle source
# File lib/grn2drn/schema-converter.rb, line 95
def to_droonga_schema
  schema = {}
  set_schema_item(schema, "type", type)
  set_schema_item(schema, "keyType", key_type)
  set_schema_item(schema, "tokenizer", tokenizer)
  set_schema_item(schema, "normalizer", normalizer)
  set_schema_item(schema, "columns", droonga_schema_columns)
  schema
end

Private Instance Methods

droonga_schema_columns() click to toggle source
# File lib/grn2drn/schema-converter.rb, line 143
def droonga_schema_columns
  return nil if @columns.empty?
  schema = {}
  @columns.each do |name, column|
    schema[name] = column.to_droonga_schema
  end
  schema
end
key_type() click to toggle source
# File lib/grn2drn/schema-converter.rb, line 125
def key_type
  type = @command.key_type
  case type
  when /\AInt/, /\AUInt/
    "Integer"
  else
    type
  end
end
normalizer() click to toggle source
# File lib/grn2drn/schema-converter.rb, line 139
def normalizer
  @command.normalizer
end
set_schema_item(schema, key, value) click to toggle source
# File lib/grn2drn/schema-converter.rb, line 106
def set_schema_item(schema, key, value)
  return if value.nil?
  schema[key] = value
end
tokenizer() click to toggle source
# File lib/grn2drn/schema-converter.rb, line 135
def tokenizer
  @command.default_tokenizer
end
type() click to toggle source
# File lib/grn2drn/schema-converter.rb, line 111
def type
  if @command.table_no_key?
    "Array"
  elsif @command.table_hash_key?
    "Hash"
  elsif @command.table_pat_key?
    "PatriciaTrie"
  elsif @command.table_dat_key?
    "DoubleArrayTrie"
  else
    "Hash"
  end
end