Method: NoSE::Backend::PreparedQuery#execute
- Defined in:
- lib/nose/backend.rb
#execute(conditions) ⇒ Array<Hash>
Execute the query for the given set of conditions
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/nose/backend.rb', line 371 def execute(conditions) results = nil @steps.each do |step| if step.is_a?(Backend::IndexLookupStatementStep) field_ids = step.index.all_fields.map(&:id) field_conds = conditions.select { |key| field_ids.include? key } else field_conds = conditions end results = step.process field_conds, results # The query can't return any results at this point, so we're done break if results.empty? end # Only return fields selected by the query if one is given # (we have no query to refer to for manually-defined plans) unless @query.nil? select_ids = @query.select.map(&:id).to_set results.map { |row| row.select! { |k, _| select_ids.include? k } } end results end |