| 1 |
module Groonga |
| 2 |
class IndexColumn |
| 3 |
private :estimate_size_for_term_id |
| 4 |
private :estimate_size_for_query |
| 5 |
private :estimate_size_for_lexicon_cursor |
| 6 |
|
| 7 |
# Estimate the number of matched records for term ID or query. |
| 8 |
# |
| 9 |
# @overload estimate_size(:term_id => term_id) |
| 10 |
# @return [Integer] the number of matched records for the term ID. |
| 11 |
# |
| 12 |
# @overload estimate_size(:query => query) |
| 13 |
# @return [Integer] the number of matched records for the query. |
| 14 |
# |
| 15 |
# @overload estimate_size(:lexicon_cursor => lexicon_cursor) |
| 16 |
# @return [Integer] the number of matched records for the lexicon cursor. |
| 17 |
# |
| 18 |
def estimate_size(parameters) |
| 19 |
term_id = parameters[:term_id] |
| 20 |
if term_id |
| 21 |
return estimate_size_for_term_id(term_id) |
| 22 |
end |
| 23 |
|
| 24 |
query = parameters[:query] |
| 25 |
if query |
| 26 |
return estimate_size_for_query(query, parameters) |
| 27 |
end |
| 28 |
|
| 29 |
lexicon_cursor = parameters[:lexicon_cursor] |
| 30 |
if lexicon_cursor |
| 31 |
return estimate_size_for_lexicon_cursor(lexicon_cursor) |
| 32 |
end |
| 33 |
|
| 34 |
message = |
| 35 |
"must specify :term_id, :query, :lexicon_cursor: #{parameters.inspect}" |
| 36 |
raise InvalidArgument, message |
| 37 |
end |
| 38 |
end |
| 39 |
end |