diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
commit | a175314c3e5827eb193872241446f2f8f5c9d33c (patch) | |
tree | cd3d60ca99ae00829c52a6ca79150a5b6e62528b /storage/mroonga/vendor/groonga/lib/mrb/scripts/expression_tree/function_call.rb | |
parent | Initial commit. (diff) | |
download | mariadb-10.5-a175314c3e5827eb193872241446f2f8f5c9d33c.tar.xz mariadb-10.5-a175314c3e5827eb193872241446f2f8f5c9d33c.zip |
Adding upstream version 1:10.5.12.upstream/1%10.5.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | storage/mroonga/vendor/groonga/lib/mrb/scripts/expression_tree/function_call.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/storage/mroonga/vendor/groonga/lib/mrb/scripts/expression_tree/function_call.rb b/storage/mroonga/vendor/groonga/lib/mrb/scripts/expression_tree/function_call.rb new file mode 100644 index 00000000..0c7438d6 --- /dev/null +++ b/storage/mroonga/vendor/groonga/lib/mrb/scripts/expression_tree/function_call.rb @@ -0,0 +1,66 @@ +module Groonga + module ExpressionTree + class FunctionCall + attr_reader :procedure + attr_reader :arguments + def initialize(procedure, arguments) + @procedure = procedure + @arguments = arguments + end + + def build(expression) + @procedure.build(expression) + @arguments.each do |argument| + argument.build(expression) + end + expression.append_operator(Operator::CALL, @arguments.size) + end + + def estimate_size(table) + return table.size unless @procedure.name == "between" + + column, min, min_border, max, max_border = @arguments + + if column.is_a?(Groonga::ExpressionTree::IndexColumn) + index_column = column.object + else + index_info = column.column.find_index(Operator::CALL) + return table.size if index_info.nil? + index_column = index_info.index + end + + while index_column.is_a?(Groonga::Accessor) + if index_column.have_next? + index_column = index_column.next + else + index_column = index_column.object + index_info = index_column.find_index(Operator::CALL) + return table.size if index_info.nil? + index_column = index_info.index + end + end + + lexicon = index_column.lexicon + options = { + :min => min.value, + :max => max.value, + :flags => 0, + } + if min_border.value == "include" + options[:flags] |= TableCursorFlags::LT + else + options[:flags] |= TableCursorFlags::LE + end + if max_border.value == "include" + options[:flags] |= TableCursorFlags::GT + else + options[:flags] |= TableCursorFlags::GE + end + + TableCursor.open(lexicon, options) do |cursor| + index_column.estimate_size(:lexicon_cursor => cursor) + end + end + end + end +end |