Class: Fluent::GroongaOutput::TableDefinition

Inherits:
Object
  • Object
show all
Includes:
DefinitionParseMethods
Defined in:
lib/fluent/plugin/out_groonga.rb

Defined Under Namespace

Classes: IndexDefinition

Instance Method Summary (collapse)

Constructor Details

- (TableDefinition) initialize(raw)

Returns a new instance of TableDefinition



147
148
149
# File 'lib/fluent/plugin/out_groonga.rb', line 147

def initialize(raw)
  @raw = raw
end

Instance Method Details

- (Object) default_tokenizer



163
164
165
# File 'lib/fluent/plugin/out_groonga.rb', line 163

def default_tokenizer
  @raw[:default_tokenizer]
end

- (Object) flags



155
156
157
# File 'lib/fluent/plugin/out_groonga.rb', line 155

def flags
  parse_flags(@raw[:flags] || "TABLE_NO_KEY")
end

- (Boolean) have_difference?(table)

Returns:

  • (Boolean)


181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/fluent/plugin/out_groonga.rb', line 181

def have_difference?(table)
  return true if table.name != name

  table_flags = (parse_flags(table.flags) - ["PERSISTENT"])
  return true if table_flags.sort != flags.sort

  return true if table.domain != key_type

  return true if table.default_tokenizer != default_tokenizer

  # TODO
  # return true if table.token_filters.sort != token_filters.sort

  return true if table.normalizer != normalizer

  false
end

- (Object) indexes



175
176
177
178
179
# File 'lib/fluent/plugin/out_groonga.rb', line 175

def indexes
  (@raw[:indexes] || []).collect do |raw|
    IndexDefinition.new(self, raw)
  end
end

- (Object) key_type



159
160
161
# File 'lib/fluent/plugin/out_groonga.rb', line 159

def key_type
  @raw[:key_type]
end

- (Object) name



151
152
153
# File 'lib/fluent/plugin/out_groonga.rb', line 151

def name
  @raw[:name]
end

- (Object) normalizer



171
172
173
# File 'lib/fluent/plugin/out_groonga.rb', line 171

def normalizer
  @raw[:normalizer]
end

- (Object) to_create_arguments



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/fluent/plugin/out_groonga.rb', line 199

def to_create_arguments
  arguments = {
    "name" => name,
    "flags" => flags.join("|"),
    "key_type" => key_type,
    "default_tokenizer" => default_tokenizer,
    # TODO
    # "token_filters" => token_filters.join("|"),
    "normalizer" => normalizer,
  }
  arguments.keys.each do |key|
    value = arguments[key]
    arguments.delete(key) if value.nil? or value.empty?
  end
  arguments
end

- (Object) token_filters



167
168
169
# File 'lib/fluent/plugin/out_groonga.rb', line 167

def token_filters
  parse_items(@raw[:token_filters] || "")
end