Navigation Menu

Skip to content

Commit

Permalink
mruby: support regexp pattern for estimating size
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 2, 2015
1 parent 5f42bd9 commit 147c4af
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/mrb/scripts/expression_size_estimator.rb
Expand Up @@ -55,6 +55,8 @@ def estimate_data(data)
case data.op
when Operator::MATCH
size = estimate_match(data, search_index)
when Operator::REGEXP
size = estimate_regexp(data, search_index)
when Operator::EQUAL
size = estimate_equal(data, search_index)
when Operator::LESS,
Expand Down Expand Up @@ -82,6 +84,18 @@ def estimate_match(data, search_index)
index_column.estimate_size(:query => data.query.value)
end

def estimate_regexp(data, search_index)
index_column = search_index.index_column
while index_column.is_a?(Accessor)
index_info = index_column.find_index(Operator::REGEXP)
return nil if index_info.nil?
index_column = index_info.index
end

index_column.estimate_size(:query => data.query.value,
:mode => Operator::REGEXP)
end

def estimate_equal(data, search_index)
index_column = search_index.index_column
if index_column.is_a?(Accessor)
Expand Down

0 comments on commit 147c4af

Please sign in to comment.