Class: Droonga::Catalog::Schema::Table
- Inherits:
-
Object
- Object
- Droonga::Catalog::Schema::Table
- Defined in:
- lib/droonga/catalog/schema.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #flags ⇒ Object
-
#initialize(name, data) ⇒ Table
constructor
A new instance of Table.
- #key_type ⇒ Object
- #key_type_groonga ⇒ Object
- #normalizer ⇒ Object
- #to_table_create_body ⇒ Object
- #tokenizer ⇒ Object
- #type ⇒ Object
- #type_flag ⇒ Object
Constructor Details
#initialize(name, data) ⇒ Table
Returns a new instance of Table.
143 144 145 146 147 148 149 150 151 |
# File 'lib/droonga/catalog/schema.rb', line 143 def initialize(name, data) @name = name @data = data @columns = {} columns_data.each do |column_name, column_data| @columns[column_name] = Column.new(name, column_name, column_data) end end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
142 143 144 |
# File 'lib/droonga/catalog/schema.rb', line 142 def columns @columns end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
142 143 144 |
# File 'lib/droonga/catalog/schema.rb', line 142 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
142 143 144 |
# File 'lib/droonga/catalog/schema.rb', line 142 def name @name end |
Instance Method Details
#==(other) ⇒ Object
153 154 155 156 157 |
# File 'lib/droonga/catalog/schema.rb', line 153 def ==(other) self.class == other.class and name == other.name and data == other.data end |
#flags ⇒ Object
201 202 203 |
# File 'lib/droonga/catalog/schema.rb', line 201 def flags [type_flag] end |
#key_type ⇒ Object
163 164 165 |
# File 'lib/droonga/catalog/schema.rb', line 163 def key_type @data["keyType"] end |
#key_type_groonga ⇒ Object
167 168 169 170 171 172 173 174 175 176 |
# File 'lib/droonga/catalog/schema.rb', line 167 def key_type_groonga case key_type when "Integer" "Int64" when "Float", "Time", "ShortText", "TokyoGeoPoint", "WGS84GeoPoint" key_type else # TODO raise appropriate error end end |
#normalizer ⇒ Object
182 183 184 |
# File 'lib/droonga/catalog/schema.rb', line 182 def normalizer @data["normalizer"] end |
#to_table_create_body ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/droonga/catalog/schema.rb', line 205 def to_table_create_body body = { "name" => name, "key_type" => key_type_groonga, "flags" => flags.join("|") } if tokenizer body["default_tokenizer"] = tokenizer end if normalizer body["normalizer"] = normalizer end body end |
#tokenizer ⇒ Object
178 179 180 |
# File 'lib/droonga/catalog/schema.rb', line 178 def tokenizer @data["tokenizer"] end |
#type ⇒ Object
159 160 161 |
# File 'lib/droonga/catalog/schema.rb', line 159 def type @data["type"] || "Hash" end |
#type_flag ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/droonga/catalog/schema.rb', line 186 def type_flag case type when "Array" "TABLE_NO_KEY" when "Hash" "TABLE_HASH_KEY" when "PatriciaTrie" "TABLE_PAT_KEY" when "DoubleArrayTrie" "TABLE_DAT_KEY" else # TODO raise appropriate error end end |