veritas-optimizer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.rvmrc +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +20 -10
- data/Guardfile +22 -0
- data/README.rdoc +2 -0
- data/Rakefile +4 -2
- data/TODO +43 -2
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/roodi.yml +4 -4
- data/lib/veritas/optimizer/aggregate/count.rb +17 -0
- data/lib/veritas/optimizer/aggregate/maximum.rb +17 -0
- data/lib/veritas/optimizer/aggregate/mean.rb +17 -0
- data/lib/veritas/optimizer/aggregate/minimum.rb +17 -0
- data/lib/veritas/optimizer/aggregate/standard_deviation.rb +17 -0
- data/lib/veritas/optimizer/aggregate/sum.rb +17 -0
- data/lib/veritas/optimizer/aggregate/variance.rb +17 -0
- data/lib/veritas/optimizer/aggregate.rb +16 -0
- data/lib/veritas/optimizer/algebra/difference.rb +3 -1
- data/lib/veritas/optimizer/algebra/extension.rb +58 -3
- data/lib/veritas/optimizer/algebra/intersection.rb +3 -1
- data/lib/veritas/optimizer/algebra/join.rb +6 -4
- data/lib/veritas/optimizer/algebra/product.rb +3 -1
- data/lib/veritas/optimizer/algebra/projection.rb +23 -54
- data/lib/veritas/optimizer/algebra/rename.rb +55 -80
- data/lib/veritas/optimizer/algebra/restriction.rb +33 -66
- data/lib/veritas/optimizer/algebra/summarization.rb +161 -3
- data/lib/veritas/optimizer/algebra/union.rb +3 -1
- data/lib/veritas/optimizer/function/binary.rb +124 -0
- data/lib/veritas/optimizer/{logic → function}/connective/binary.rb +48 -102
- data/lib/veritas/optimizer/{logic → function}/connective/conjunction.rb +12 -11
- data/lib/veritas/optimizer/{logic → function}/connective/disjunction.rb +15 -14
- data/lib/veritas/optimizer/function/connective/negation.rb +65 -0
- data/lib/veritas/optimizer/function/numeric/absolute.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/addition.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/division.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/exponentiation.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/modulo.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/multiplication.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/square_root.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/subtraction.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/unary_minus.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/unary_plus.rb +20 -0
- data/lib/veritas/optimizer/function/numeric.rb +34 -0
- data/lib/veritas/optimizer/{logic → function}/predicate/comparable.rb +6 -4
- data/lib/veritas/optimizer/{logic → function}/predicate/enumerable.rb +24 -26
- data/lib/veritas/optimizer/{logic → function}/predicate/equality.rb +6 -6
- data/lib/veritas/optimizer/{logic → function}/predicate/exclusion.rb +6 -16
- data/lib/veritas/optimizer/{logic → function}/predicate/greater_than.rb +6 -5
- data/lib/veritas/optimizer/{logic → function}/predicate/greater_than_or_equal_to.rb +6 -6
- data/lib/veritas/optimizer/{logic → function}/predicate/inclusion.rb +6 -16
- data/lib/veritas/optimizer/{logic → function}/predicate/inequality.rb +6 -6
- data/lib/veritas/optimizer/{logic → function}/predicate/less_than.rb +6 -5
- data/lib/veritas/optimizer/{logic → function}/predicate/less_than_or_equal_to.rb +6 -6
- data/lib/veritas/optimizer/{logic → function}/predicate/match.rb +5 -4
- data/lib/veritas/optimizer/{logic → function}/predicate/no_match.rb +5 -4
- data/lib/veritas/optimizer/function/predicate.rb +61 -0
- data/lib/veritas/optimizer/function/string/length.rb +31 -0
- data/lib/veritas/optimizer/function/unary.rb +86 -0
- data/lib/veritas/optimizer/function.rb +87 -0
- data/lib/veritas/optimizer/optimizable.rb +6 -3
- data/lib/veritas/optimizer/relation/operation/binary.rb +36 -70
- data/lib/veritas/optimizer/relation/operation/limit.rb +1 -9
- data/lib/veritas/optimizer/relation/operation/offset.rb +1 -9
- data/lib/veritas/optimizer/relation/operation/order.rb +1 -9
- data/lib/veritas/optimizer/relation/operation/reverse.rb +1 -9
- data/lib/veritas/optimizer/relation/operation/unary.rb +50 -13
- data/lib/veritas/optimizer/version.rb +1 -1
- data/lib/veritas/optimizer.rb +43 -16
- data/spec/integration/veritas/algebra/difference/optimize_spec.rb +6 -4
- data/spec/integration/veritas/algebra/intersection/optimize_spec.rb +6 -4
- data/spec/integration/veritas/algebra/join/optimize_spec.rb +4 -2
- data/spec/integration/veritas/algebra/product/optimize_spec.rb +2 -0
- data/spec/integration/veritas/algebra/projection/optimize_spec.rb +6 -4
- data/spec/integration/veritas/algebra/rename/optimize_spec.rb +2 -0
- data/spec/integration/veritas/algebra/restriction/optimize_spec.rb +9 -7
- data/spec/integration/veritas/algebra/summarization/optimize_spec.rb +49 -0
- data/spec/integration/veritas/algebra/union/optimize_spec.rb +6 -4
- data/spec/integration/veritas/{logic → function}/connective/conjunction/optimize_spec.rb +33 -31
- data/spec/integration/veritas/{logic → function}/connective/disjunction/optimize_spec.rb +30 -28
- data/spec/integration/veritas/{logic → function}/connective/negation/optimize_spec.rb +7 -5
- data/spec/integration/veritas/{logic/expression → function}/optimize_spec.rb +5 -3
- data/spec/integration/veritas/{logic → function}/predicate/equality/optimize_spec.rb +9 -7
- data/spec/integration/veritas/{logic → function}/predicate/exclusion/optimize_spec.rb +13 -11
- data/spec/integration/veritas/{logic → function}/predicate/greater_than/optimize_spec.rb +17 -15
- data/spec/integration/veritas/{logic → function}/predicate/greater_than_or_equal_to/optimize_spec.rb +17 -15
- data/spec/integration/veritas/{logic → function}/predicate/inclusion/optimize_spec.rb +13 -11
- data/spec/integration/veritas/{logic → function}/predicate/inequality/optimize_spec.rb +9 -7
- data/spec/integration/veritas/{logic → function}/predicate/less_than/optimize_spec.rb +17 -15
- data/spec/integration/veritas/{logic → function}/predicate/less_than_or_equal_to/optimize_spec.rb +17 -15
- data/spec/integration/veritas/relation/empty/optimize_spec.rb +2 -0
- data/spec/integration/veritas/relation/materialized/optimize_spec.rb +2 -0
- data/spec/integration/veritas/relation/operation/limit/optimize_spec.rb +3 -1
- data/spec/integration/veritas/relation/operation/offset/optimize_spec.rb +3 -1
- data/spec/integration/veritas/relation/operation/order/optimize_spec.rb +4 -2
- data/spec/integration/veritas/relation/operation/reverse/optimize_spec.rb +4 -2
- data/spec/integration/veritas/relation/optimize_spec.rb +2 -0
- data/spec/shared/{logic_connective_binary_optimize_behavior.rb → function_connective_binary_optimize_behavior.rb} +14 -12
- data/spec/shared/idempotent_method_behavior.rb +2 -0
- data/spec/shared/optimize_method_behavior.rb +2 -0
- data/spec/support/add_method_missing.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/difference/empty_left/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/difference/empty_right/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/difference/equal_operands/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/extension/extensions_spec.rb +31 -0
- data/spec/unit/veritas/optimizer/algebra/extension/order_operand/optimizable_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/algebra/extension/order_operand/optimize_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimizable_spec.rb +18 -8
- data/spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimize_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/algebra/intersection/empty_left/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/intersection/empty_right/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/intersection/equal_operands/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/join/equal_headers/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/join/equal_headers/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_left/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_left/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_right/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_right/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/projection/empty_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/projection/empty_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/projection/projection_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/projection/projection_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/projection/{set_operand → union_operand}/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/projection/{set_operand → union_operand}/optimize_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/algebra/projection/unoptimized_operand/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/projection/unoptimized_operand/optimize_spec.rb +6 -4
- data/spec/unit/veritas/optimizer/algebra/rename/aliases_spec.rb +5 -13
- data/spec/unit/veritas/optimizer/algebra/rename/empty_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/empty_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/limit_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/limit_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/offset_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/offset_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/order_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/order_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/projection_operand/optimizable_spec.rb +17 -7
- data/spec/unit/veritas/optimizer/algebra/rename/projection_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/restriction_operand/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/rename/restriction_operand/optimize_spec.rb +7 -5
- data/spec/unit/veritas/optimizer/algebra/rename/reverse_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/reverse_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/set_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/set_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/unoptimized_operand/optimizable_spec.rb +7 -20
- data/spec/unit/veritas/optimizer/algebra/rename/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/contradiction/optimizable_spec.rb +23 -3
- data/spec/unit/veritas/optimizer/algebra/restriction/contradiction/optimize_spec.rb +7 -5
- data/spec/unit/veritas/optimizer/algebra/restriction/order_operand/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/restriction/order_operand/optimize_spec.rb +7 -3
- data/spec/unit/veritas/optimizer/algebra/restriction/predicate_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/restriction/restriction_operand/optimizable_spec.rb +5 -3
- data/spec/unit/veritas/optimizer/algebra/restriction/restriction_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/algebra/restriction/set_operand/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/restriction/set_operand/optimize_spec.rb +5 -3
- data/spec/unit/veritas/optimizer/algebra/restriction/tautology/optimizable_spec.rb +11 -3
- data/spec/unit/veritas/optimizer/algebra/restriction/tautology/optimize_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimizable_spec.rb +7 -5
- data/spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/empty_operand/class_methods/extension_default_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/empty_operand/optimizable_spec.rb +29 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/empty_operand/optimize_spec.rb +47 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/empty_summarize_per/optimizable_spec.rb +29 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/empty_summarize_per/optimize_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/order_operand/optimizable_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/order_operand/optimize_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/summarize_per_spec.rb +29 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/summarizers_spec.rb +31 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/unoptimized_operand/optimizable_spec.rb +30 -8
- data/spec/unit/veritas/optimizer/algebra/summarization/unoptimized_operand/optimize_spec.rb +12 -9
- data/spec/unit/veritas/optimizer/algebra/union/empty_left/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/union/empty_right/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/union/equal_operands/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/class_methods/chain_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/function/binary/constant_operands/optimizable_spec.rb +36 -0
- data/spec/unit/veritas/optimizer/function/binary/constant_operands/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/function/binary/left_spec.rb +28 -0
- data/spec/unit/veritas/optimizer/function/binary/right_spec.rb +28 -0
- data/spec/unit/veritas/optimizer/function/binary/unoptimized_operands/optimizable_spec.rb +37 -0
- data/spec/unit/veritas/optimizer/function/binary/unoptimized_operands/optimize_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/function/class_methods/optimize_functions_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/function/class_methods/optimize_operand_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/function/connective/binary/constant_operands/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/equal_operands/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/equal_operands/optimize_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/left_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_left_operand/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_left_operand/optimize_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_right_operand/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_right_operand/optimize_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/right_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/function/connective/conjunction/contradiction/optimizable_spec.rb +64 -0
- data/spec/unit/veritas/optimizer/function/connective/conjunction/contradiction/optimize_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/{logic/connective/disjunction/contradiction_left_operand → function/connective/conjunction/left_operand_tautology}/optimizable_spec.rb +9 -7
- data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/left_operand_tautology/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/optimizable_to_exclusion/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/optimizable_to_exclusion/optimize_spec.rb +5 -3
- data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/right_operand_tautology/optimizable_spec.rb +6 -4
- data/spec/unit/veritas/optimizer/function/connective/conjunction/right_operand_tautology/optimize_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/{logic/connective/conjunction/left_operand_tautology → function/connective/disjunction/contradiction_left_operand}/optimizable_spec.rb +9 -7
- data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/contradiction_left_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/contradiction_right_operand/optimizable_spec.rb +6 -4
- data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/contradiction_right_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/optimizable_to_inclusion/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/optimizable_to_inclusion/optimize_spec.rb +5 -3
- data/spec/unit/veritas/optimizer/function/connective/disjunction/tautology/optimizable_spec.rb +64 -0
- data/spec/unit/veritas/optimizer/function/connective/disjunction/tautology/optimize_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/function/connective/negation/constant_operand/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/function/connective/negation/invertible_operand/optimizable_spec.rb +28 -0
- data/spec/unit/veritas/optimizer/function/connective/negation/invertible_operand/optimize_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/{logic → function}/connective/negation/operand_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/never_comparable/optimizable_spec.rb +23 -7
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/never_equivalent/optimizable_spec.rb +23 -7
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/normalizable_operands/optimizable_spec.rb +7 -5
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/normalizable_operands/optimize_spec.rb +7 -5
- data/spec/unit/veritas/optimizer/function/predicate/constant_operands/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/function/predicate/contradiction/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/function/predicate/enumerable/class_methods/sort_by_value_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/enumerable/empty_right_operand/optimizable_spec.rb +6 -4
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/enumerable/one_right_operand/optimizable_spec.rb +9 -7
- data/spec/unit/veritas/optimizer/{logic/predicate/enumerable/unoptimized_operand → function/predicate/enumerable/unoptimized_operands}/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic/predicate/enumerable/unoptimized_operand → function/predicate/enumerable/unoptimized_operands}/optimize_spec.rb +18 -5
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/equality/tautology/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/exclusion/empty_right_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/exclusion/one_right_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than/contradiction/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than/tautology/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than_or_equal_to/contradiction/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than_or_equal_to/tautology/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/inclusion/empty_right_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/inclusion/one_right_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/inequality/contradiction/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than/contradiction/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than/tautology/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than_or_equal_to/contradiction/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than_or_equal_to/tautology/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/function/predicate/tautology/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/function/unary/constant_operand/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/function/unary/constant_operand/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/function/unary/operand_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/function/unary/unoptimized_operand/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/function/unary/unoptimized_operand/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/{logic/predicate → function}/util/class_methods/attribute_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic/predicate → function}/util/class_methods/constant_spec.rb +13 -5
- data/spec/unit/veritas/optimizer/function/util/class_methods/max_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/function/util/class_methods/min_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/operation_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/optimizable/class_methods/optimizer_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/optimizable/optimize_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/materialized/empty_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/materialized/empty_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/empty_left/optimizable_spec.rb +2 -4
- data/spec/unit/veritas/optimizer/relation/operation/binary/empty_right/optimizable_spec.rb +2 -4
- data/spec/unit/veritas/optimizer/relation/operation/binary/equal_operands/optimizable_spec.rb +2 -5
- data/spec/unit/veritas/optimizer/relation/operation/binary/left_order_operand/optimizable_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/left_order_operand/optimize_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/left_spec.rb +2 -4
- data/spec/unit/veritas/optimizer/relation/operation/binary/materialized_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/materialized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/right_order_operand/optimizable_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/right_order_operand/optimize_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/right_spec.rb +2 -4
- data/spec/unit/veritas/optimizer/relation/operation/binary/{unoptimized_operand → unoptimized_operands}/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/relation/operation/binary/{unoptimized_operand → unoptimized_operands}/optimize_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/relation/operation/combination/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/equal_limit_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/equal_limit_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/limit_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/limit_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/unoptimized_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/zero_limit/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/zero_limit/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/offset_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/offset_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/unoptimized_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/zero_offset/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/zero_offset/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/one_limit_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/one_limit_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/order_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/order_operand/optimize_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/relation/operation/order/unoptimized_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/order_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/order_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/reverse_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/reverse_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/unoptimized_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/empty_operand/optimizable_spec.rb +5 -2
- data/spec/unit/veritas/optimizer/relation/operation/unary/empty_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/header_spec.rb +15 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/materialized_operand/optimizable_spec.rb +5 -2
- data/spec/unit/veritas/optimizer/relation/operation/unary/materialized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/operand_spec.rb +8 -5
- data/spec/unit/veritas/optimizer/relation/operation/unary/order_operand/optimizable_spec.rb +28 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/order_operand/optimize_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/unchanged_header/optimizable_spec.rb +24 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/unchanged_header/optimize_spec.rb +14 -0
- data/tasks/metrics/ci.rake +7 -0
- data/tasks/{quality → metrics}/flay.rake +0 -0
- data/tasks/{quality → metrics}/flog.rake +0 -0
- data/tasks/{quality → metrics}/heckle.rake +1 -0
- data/tasks/{quality → metrics}/metric_fu.rake +3 -0
- data/tasks/{quality → metrics}/reek.rake +0 -0
- data/tasks/{quality → metrics}/roodi.rake +0 -0
- data/tasks/{quality → metrics}/yardstick.rake +0 -0
- data/tasks/spec.rake +1 -0
- data/veritas-optimizer.gemspec +183 -352
- metadata +232 -357
- data/lib/veritas/optimizer/logic/connective/negation.rb +0 -71
- data/lib/veritas/optimizer/logic/predicate.rb +0 -177
- data/spec/unit/veritas/optimizer/algebra/projection/header_spec.rb +0 -16
- data/spec/unit/veritas/optimizer/algebra/projection/unchanged_header/optimizable_spec.rb +0 -26
- data/spec/unit/veritas/optimizer/algebra/projection/unchanged_header/optimize_spec.rb +0 -16
- data/spec/unit/veritas/optimizer/algebra/rename/class_methods/union_aliases_spec.rb +0 -27
- data/spec/unit/veritas/optimizer/algebra/rename/header_spec.rb +0 -19
- data/spec/unit/veritas/optimizer/algebra/rename/unchanged_header/optimizable_spec.rb +0 -26
- data/spec/unit/veritas/optimizer/algebra/rename/unchanged_header/optimize_spec.rb +0 -16
- data/spec/unit/veritas/optimizer/algebra/restriction/class_methods/optimize_predicate_spec.rb +0 -31
- data/spec/unit/veritas/optimizer/algebra/restriction/reverse_operand/optimizable_spec.rb +0 -26
- data/spec/unit/veritas/optimizer/algebra/restriction/reverse_operand/optimize_spec.rb +0 -18
- data/spec/unit/veritas/optimizer/logic/connective/binary/unoptimized_operand/optimizable_spec.rb +0 -34
- data/spec/unit/veritas/optimizer/logic/connective/binary/unoptimized_operand/optimize_spec.rb +0 -21
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/contradiction/optimizable_spec.rb +0 -41
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/contradiction/optimize_spec.rb +0 -17
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/right_operand_tautology/optimize_spec.rb +0 -17
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/tautology/optimizable_spec.rb +0 -41
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/tautology/optimize_spec.rb +0 -17
- data/spec/unit/veritas/optimizer/logic/connective/negation/invertible_operand/optimizable_spec.rb +0 -26
- data/spec/unit/veritas/optimizer/logic/connective/negation/invertible_operand/optimize_spec.rb +0 -20
- data/spec/unit/veritas/optimizer/logic/predicate/class_methods/optimize_operand_spec.rb +0 -20
- data/spec/unit/veritas/optimizer/logic/predicate/constant_operands/optimizable_spec.rb +0 -29
- data/spec/unit/veritas/optimizer/logic/predicate/constant_operands/optimize_spec.rb +0 -14
- data/spec/unit/veritas/optimizer/logic/predicate/contradiction/optimize_spec.rb +0 -16
- data/spec/unit/veritas/optimizer/logic/predicate/left_spec.rb +0 -25
- data/spec/unit/veritas/optimizer/logic/predicate/right_spec.rb +0 -25
- data/spec/unit/veritas/optimizer/logic/predicate/tautology/optimize_spec.rb +0 -16
- data/spec/unit/veritas/optimizer/logic/predicate/util/class_methods/max_spec.rb +0 -19
- data/spec/unit/veritas/optimizer/logic/predicate/util/class_methods/min_spec.rb +0 -19
- data/tasks/quality/ci.rake +0 -2
@@ -1,10 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Optimizer::Algebra::Restriction::Tautology, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
8
|
let(:base) { Relation.new([ [ :id, Integer ] ], [ [ 1 ] ].each) }
|
7
|
-
let(:relation) { base.restrict
|
9
|
+
let(:relation) { base.restrict { predicate } }
|
8
10
|
let(:object) { described_class.new(relation) }
|
9
11
|
|
10
12
|
before do
|
@@ -12,14 +14,20 @@ describe Optimizer::Algebra::Restriction::Tautology, '#optimizable?' do
|
|
12
14
|
end
|
13
15
|
|
14
16
|
context 'when the predicate is a tautology' do
|
15
|
-
let(:predicate) {
|
17
|
+
let(:predicate) { Function::Proposition::Tautology.instance }
|
16
18
|
|
17
19
|
it { should be(true) }
|
18
20
|
end
|
19
21
|
|
20
22
|
context 'when the predicate is not a tautology' do
|
21
|
-
let(:predicate) {
|
23
|
+
let(:predicate) { Function::Proposition::Contradiction.instance }
|
22
24
|
|
23
25
|
it { should be(false) }
|
24
26
|
end
|
27
|
+
|
28
|
+
context 'when the predicate is true' do
|
29
|
+
let(:predicate) { true }
|
30
|
+
|
31
|
+
it { should be(true) }
|
32
|
+
end
|
25
33
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Optimizer::Algebra::Restriction::Tautology, '#optimize' do
|
@@ -5,8 +7,8 @@ describe Optimizer::Algebra::Restriction::Tautology, '#optimize' do
|
|
5
7
|
|
6
8
|
let(:header) { Relation::Header.new([ [ :id, Integer ] ]) }
|
7
9
|
let(:base) { Relation.new(header, [ [ 1 ] ].each) }
|
8
|
-
let(:predicate) {
|
9
|
-
let(:relation) { base.restrict
|
10
|
+
let(:predicate) { Function::Proposition::Tautology.instance }
|
11
|
+
let(:relation) { base.restrict { predicate } }
|
10
12
|
let(:object) { described_class.new(relation) }
|
11
13
|
|
12
14
|
before do
|
data/spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimizable_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Optimizer::Algebra::Restriction::UnoptimizedOperand, '#optimizable?' do
|
@@ -5,7 +7,7 @@ describe Optimizer::Algebra::Restriction::UnoptimizedOperand, '#optimizable?' do
|
|
5
7
|
|
6
8
|
let(:header) { Relation::Header.new([ [ :id, Integer ] ]) }
|
7
9
|
let(:base) { Relation.new(header, [ [ 1 ] ].each) }
|
8
|
-
let(:relation) { operand.restrict
|
10
|
+
let(:relation) { operand.restrict { predicate } }
|
9
11
|
let(:object) { described_class.new(relation) }
|
10
12
|
|
11
13
|
before do
|
@@ -13,8 +15,8 @@ describe Optimizer::Algebra::Restriction::UnoptimizedOperand, '#optimizable?' do
|
|
13
15
|
end
|
14
16
|
|
15
17
|
context 'when the operand and predicate is optimizable' do
|
16
|
-
let(:predicate) {
|
17
|
-
let(:operand) { base.rename({})
|
18
|
+
let(:predicate) { Function::Connective::Negation.new(header[:id].eq(1)) }
|
19
|
+
let(:operand) { base.rename({}) }
|
18
20
|
|
19
21
|
it { should be(true) }
|
20
22
|
end
|
@@ -27,8 +29,8 @@ describe Optimizer::Algebra::Restriction::UnoptimizedOperand, '#optimizable?' do
|
|
27
29
|
end
|
28
30
|
|
29
31
|
context 'when the operand is not optimizable, but the predicate is optimizable' do
|
30
|
-
let(:predicate) {
|
31
|
-
let(:operand) { base
|
32
|
+
let(:predicate) { Function::Connective::Negation.new(header[:id].eq(1)) }
|
33
|
+
let(:operand) { base }
|
32
34
|
|
33
35
|
it { should be(true) }
|
34
36
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Algebra::Summarization::EmptyOperand, '.extension_default' do
|
6
|
+
subject { object.extension_default(function) }
|
7
|
+
|
8
|
+
let(:object) { described_class }
|
9
|
+
|
10
|
+
context 'when the function has a default' do
|
11
|
+
let(:operand) { mock('Operand') }
|
12
|
+
let(:function) { Aggregate::Count.new(operand) }
|
13
|
+
|
14
|
+
it { should eql(0) }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when the function does not have a default' do
|
18
|
+
let(:function) { proc {} }
|
19
|
+
|
20
|
+
it { should be_nil }
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Algebra::Summarization::EmptyOperand, '#optimizable?' do
|
6
|
+
subject { object.optimizable? }
|
7
|
+
|
8
|
+
let(:header) { Relation::Header.new([ [ :id, Integer ], [ :name, String ] ]) }
|
9
|
+
let(:base) { Relation.new(header, [ [ 1, 'Dan Kubb' ] ].each) }
|
10
|
+
let(:relation) { operand.summarize(summarize_per) {} }
|
11
|
+
let(:summarize_per) { TABLE_DEE }
|
12
|
+
let(:object) { described_class.new(relation) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
object.operation.should be_kind_of(Algebra::Summarization)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when the operand is empty' do
|
19
|
+
let(:operand) { base.restrict { false } }
|
20
|
+
|
21
|
+
it { should be(true) }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when the operand is not empty' do
|
25
|
+
let(:operand) { base }
|
26
|
+
|
27
|
+
it { should be(false) }
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Algebra::Summarization::EmptyOperand, '#optimize' do
|
6
|
+
subject { object.optimize }
|
7
|
+
|
8
|
+
let(:header) { Relation::Header.new([ [ :id, Integer ] ]) }
|
9
|
+
let(:base) { Relation.new(header, [ [ 1 ] ].each) }
|
10
|
+
let(:attribute) { Attribute::Object.new(:test) }
|
11
|
+
let(:operand) { base.restrict { false } }
|
12
|
+
let(:summarize_per) { TABLE_DEE }
|
13
|
+
let(:object) { described_class.new(relation) }
|
14
|
+
|
15
|
+
context 'when the function has a default' do
|
16
|
+
let(:relation) { operand.summarize(summarize_per) { |r| r.add(attribute, r[:id].count) } }
|
17
|
+
|
18
|
+
before do
|
19
|
+
object.should be_optimizable
|
20
|
+
end
|
21
|
+
|
22
|
+
it { should be_kind_of(Algebra::Extension) }
|
23
|
+
|
24
|
+
it { should_not equal(operand) }
|
25
|
+
|
26
|
+
its(:operand) { should equal(summarize_per) }
|
27
|
+
|
28
|
+
its(:extensions) { should == { attribute => 0 } }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when the function does not have a default' do
|
32
|
+
let(:function) { lambda { |acc, tuple| 1 } }
|
33
|
+
let(:relation) { operand.summarize(summarize_per) { |r| r.add(attribute, function) } }
|
34
|
+
|
35
|
+
before do
|
36
|
+
object.should be_optimizable
|
37
|
+
end
|
38
|
+
|
39
|
+
it { should be_kind_of(Algebra::Extension) }
|
40
|
+
|
41
|
+
it { should_not equal(operand) }
|
42
|
+
|
43
|
+
its(:operand) { should equal(summarize_per) }
|
44
|
+
|
45
|
+
its(:extensions) { should == { attribute => nil } }
|
46
|
+
end
|
47
|
+
end
|
data/spec/unit/veritas/optimizer/algebra/summarization/empty_summarize_per/optimizable_spec.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Algebra::Summarization::EmptySummarizePer, '#optimizable?' do
|
6
|
+
subject { object.optimizable? }
|
7
|
+
|
8
|
+
let(:header) { Relation::Header.new([ [ :id, Integer ], [ :name, String ] ]) }
|
9
|
+
let(:base) { Relation.new(header, [ [ 1, 'Dan Kubb' ] ].each) }
|
10
|
+
let(:operand) { base }
|
11
|
+
let(:relation) { operand.summarize(summarize_per) {} }
|
12
|
+
let(:object) { described_class.new(relation) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
object.operation.should be_kind_of(Algebra::Summarization)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when the summarize_per is empty' do
|
19
|
+
let(:summarize_per) { base.project([ :id ]).restrict { false } }
|
20
|
+
|
21
|
+
it { should be(true) }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when the summarize_per is not empty' do
|
25
|
+
let(:summarize_per) { base.project([ :id ]) }
|
26
|
+
|
27
|
+
it { should be(false) }
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Algebra::Summarization::EmptySummarizePer, '#optimize' do
|
6
|
+
subject { object.optimize }
|
7
|
+
|
8
|
+
let(:header) { Relation::Header.new([ [ :id, Integer ], [ :name, String ] ]) }
|
9
|
+
let(:base) { Relation.new(header, [ [ 1, 'Dan Kubb' ] ].each) }
|
10
|
+
let(:attribute) { Attribute::Object.new(:test) }
|
11
|
+
let(:operand) { base }
|
12
|
+
let(:summarize_per) { base.project([ :id ]).restrict { false } }
|
13
|
+
let(:relation) { operand.summarize(summarize_per) { |r| r.add(attribute, r[:name].count) } }
|
14
|
+
let(:object) { described_class.new(relation) }
|
15
|
+
|
16
|
+
before do
|
17
|
+
object.should be_optimizable
|
18
|
+
end
|
19
|
+
|
20
|
+
it { should be_kind_of(Relation::Empty) }
|
21
|
+
|
22
|
+
its(:header) { should == [ [ :id, Integer ], [ :test, Object ] ] }
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Algebra::Summarization::OrderOperand, '#optimizable?' do
|
6
|
+
subject { object.optimizable? }
|
7
|
+
|
8
|
+
let(:base) { Relation.new([ [ :id, Integer ] ], [].each) }
|
9
|
+
let(:relation) { operand.summarize([]) {} }
|
10
|
+
let(:object) { described_class.new(relation) }
|
11
|
+
|
12
|
+
context 'when operand is an order' do
|
13
|
+
let(:operand) { base.order }
|
14
|
+
|
15
|
+
it { should be(true) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when operand is not an order' do
|
19
|
+
let(:operand) { base }
|
20
|
+
|
21
|
+
it { should be(false) }
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Algebra::Summarization::OrderOperand, '#optimize' do
|
6
|
+
subject { object.optimize }
|
7
|
+
|
8
|
+
let(:base) { Relation.new([ [ :id, Integer ] ], [].each) }
|
9
|
+
let(:operand) { base.order }
|
10
|
+
let(:relation) { operand.summarize([]) {} }
|
11
|
+
let(:object) { described_class.new(relation) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
object.should be_optimizable
|
15
|
+
end
|
16
|
+
|
17
|
+
it { should be_kind_of(Algebra::Summarization) }
|
18
|
+
|
19
|
+
its(:operand) { should equal(base) }
|
20
|
+
|
21
|
+
its(:summarizers) { should eql(relation.summarizers) }
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Algebra::Summarization, '#summarize_per' do
|
6
|
+
subject { object.summarize_per }
|
7
|
+
|
8
|
+
let(:base) { Relation.new([ [ :id, Integer ] ], [ [ 1 ] ]) }
|
9
|
+
let(:relation) { base.summarize(summarize_per) {} }
|
10
|
+
let(:object) { described_class.new(relation) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
object.operation.should be_kind_of(Algebra::Summarization)
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when summarize_per is optimized' do
|
17
|
+
let(:summarize_per) { TABLE_DEE }
|
18
|
+
|
19
|
+
it { should equal(summarize_per) }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when summarize_per is not not optimized' do
|
23
|
+
let(:summarize_per) { TABLE_DEE.rename({}) }
|
24
|
+
|
25
|
+
it { should_not equal(summarize_per) }
|
26
|
+
|
27
|
+
it { should equal(TABLE_DEE) }
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Algebra::Summarization, '#summarizers' do
|
6
|
+
subject { object.summarizers }
|
7
|
+
|
8
|
+
let(:base) { Relation.new([ [ :id, Integer ] ], [ [ 1 ] ]) }
|
9
|
+
let(:attribute) { Attribute::Object.new(:test) }
|
10
|
+
let(:summarize_per) { TABLE_DEE }
|
11
|
+
let(:relation) { base.summarize(summarize_per) { |r| r.add(attribute, function) } }
|
12
|
+
let(:object) { described_class.new(relation) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
object.operation.should be_kind_of(Algebra::Summarization)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when summarizers are optimized' do
|
19
|
+
let(:function) { base[:id].sum }
|
20
|
+
|
21
|
+
it { should eql(relation.summarizers) }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when summarizers are not optimized' do
|
25
|
+
let(:function) { Aggregate::Sum.new(Function::Numeric::Absolute.new(1)) }
|
26
|
+
|
27
|
+
it { should_not equal(relation.summarizers) }
|
28
|
+
|
29
|
+
it { should eql(attribute => Aggregate::Sum.new(1)) }
|
30
|
+
end
|
31
|
+
end
|
data/spec/unit/veritas/optimizer/algebra/summarization/unoptimized_operand/optimizable_spec.rb
CHANGED
@@ -1,26 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Optimizer::Algebra::Summarization::UnoptimizedOperand, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
|
-
let(:header)
|
7
|
-
let(:base)
|
8
|
-
let(:
|
9
|
-
let(:relation)
|
10
|
-
let(:object)
|
8
|
+
let(:header) { Relation::Header.new([ [ :id, Integer ], [ :name, String ] ]) }
|
9
|
+
let(:base) { Relation.new(header, [ [ 1, 'Dan Kubb' ] ].each) }
|
10
|
+
let(:attribute) { Attribute::Object.new(:test) }
|
11
|
+
let(:relation) { operand.summarize(summarize_per) { |r| r.add(attribute, function) } }
|
12
|
+
let(:object) { described_class.new(relation) }
|
11
13
|
|
12
14
|
before do
|
13
15
|
object.operation.should be_kind_of(Algebra::Summarization)
|
14
16
|
end
|
15
17
|
|
16
18
|
context 'when the operand is optimizable' do
|
17
|
-
let(:operand)
|
19
|
+
let(:operand) { base.rename({}) }
|
20
|
+
let(:summarize_per) { TABLE_DEE }
|
21
|
+
let(:function) { Aggregate::Sum.new(1) }
|
22
|
+
|
23
|
+
it { should be(true) }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when summarize_per is optimizable' do
|
27
|
+
let(:operand) { base }
|
28
|
+
let(:summarize_per) { TABLE_DEE.rename({}) }
|
29
|
+
let(:function) { Aggregate::Sum.new(1) }
|
30
|
+
|
31
|
+
it { should be(true) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when summarizers are optimizable' do
|
35
|
+
let(:operand) { base }
|
36
|
+
let(:summarize_per) { TABLE_DEE.rename({}) }
|
37
|
+
let(:function) { Aggregate::Sum.new(Function::Numeric::Absolute.new(1)) }
|
18
38
|
|
19
39
|
it { should be(true) }
|
20
40
|
end
|
21
41
|
|
22
|
-
context 'when the operand
|
23
|
-
let(:operand)
|
42
|
+
context 'when the operand, summarize_per and summarizers are not optimizable' do
|
43
|
+
let(:operand) { base }
|
44
|
+
let(:summarize_per) { TABLE_DEE }
|
45
|
+
let(:function) { Aggregate::Sum.new(1) }
|
24
46
|
|
25
47
|
it { should be(false) }
|
26
48
|
end
|
@@ -1,15 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Optimizer::Algebra::Summarization::UnoptimizedOperand, '#optimize' do
|
4
6
|
subject { object.optimize }
|
5
7
|
|
6
|
-
let(:header)
|
7
|
-
let(:base)
|
8
|
-
let(:attribute)
|
9
|
-
let(:function)
|
10
|
-
let(:operand)
|
11
|
-
let(:
|
12
|
-
let(:
|
8
|
+
let(:header) { Relation::Header.new([ [ :id, Integer ] ]) }
|
9
|
+
let(:base) { Relation.new(header, [ [ 1 ] ].each) }
|
10
|
+
let(:attribute) { Attribute::Object.new(:text) }
|
11
|
+
let(:function) { Aggregate::Sum.new(Function::Numeric::Absolute.new(1)) }
|
12
|
+
let(:operand) { base.rename({}) }
|
13
|
+
let(:summarize_per) { TABLE_DEE.project([]) }
|
14
|
+
let(:relation) { operand.summarize(summarize_per) { |r| r.add(attribute, function) } }
|
15
|
+
let(:object) { described_class.new(relation) }
|
13
16
|
|
14
17
|
before do
|
15
18
|
object.should be_optimizable
|
@@ -21,7 +24,7 @@ describe Optimizer::Algebra::Summarization::UnoptimizedOperand, '#optimize' do
|
|
21
24
|
|
22
25
|
its(:operand) { should equal(base) }
|
23
26
|
|
24
|
-
its(:
|
27
|
+
its(:summarize_per) { should equal(TABLE_DEE) }
|
25
28
|
|
26
|
-
its(:summarizers) { should == { attribute =>
|
29
|
+
its(:summarizers) { pending { should == { attribute => Aggregate::Sum.new(1) } } }
|
27
30
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Binary::ConstantOperands, '#optimizable?' do
|
6
|
+
subject { object.optimizable? }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(Optimizer) { include Optimizer::Function::Binary } }
|
9
|
+
let(:function) { Class.new(Veritas::Function) { include Veritas::Function::Binary }.new(left, right) }
|
10
|
+
let(:object) { described_class.new(function) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
described_class.class_eval { include Optimizer::Function::Binary::ConstantOperands }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when left and right are constants' do
|
17
|
+
let(:left) { 1 }
|
18
|
+
let(:right) { 1 }
|
19
|
+
|
20
|
+
it { should be(true) }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when left is a constant, and right is not a constant' do
|
24
|
+
let(:left) { 1 }
|
25
|
+
let(:right) { proc {} }
|
26
|
+
|
27
|
+
it { should be(false) }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when left is not a constant, and right is a constant' do
|
31
|
+
let(:left) { proc {} }
|
32
|
+
let(:right) { 1 }
|
33
|
+
|
34
|
+
it { should be(false) }
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Binary::ConstantOperands, '#optimize' do
|
6
|
+
subject { object.optimize }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(Optimizer) { include Optimizer::Function::Binary } }
|
9
|
+
let(:function) { Function::Numeric::Addition.new(2, 2) }
|
10
|
+
let(:object) { described_class.new(function) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
described_class.class_eval { include Optimizer::Function::Binary::ConstantOperands }
|
14
|
+
object.should be_optimizable
|
15
|
+
end
|
16
|
+
|
17
|
+
it { should be(4) }
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Binary, '#left' do
|
6
|
+
subject { object.left }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(Optimizer) { include Optimizer::Function::Binary } }
|
9
|
+
let(:right) { 'Right' }
|
10
|
+
let(:function) { Class.new(Veritas::Function) { include Veritas::Function::Binary }.new(left, right) }
|
11
|
+
let(:object) { described_class.new(function) }
|
12
|
+
|
13
|
+
context 'when left operand is frozen' do
|
14
|
+
let(:left) { 'Left'.freeze }
|
15
|
+
|
16
|
+
it { should equal(left) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when left operand is not frozen' do
|
20
|
+
let(:left) { 'Left' }
|
21
|
+
|
22
|
+
it { should_not equal(left) }
|
23
|
+
|
24
|
+
it { should be_frozen }
|
25
|
+
|
26
|
+
it { should == left }
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Binary, '#right' do
|
6
|
+
subject { object.right }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(Optimizer) { include Optimizer::Function::Binary } }
|
9
|
+
let(:left) { 'Left' }
|
10
|
+
let(:function) { Class.new(Veritas::Function) { include Veritas::Function::Binary }.new(left, right) }
|
11
|
+
let(:object) { described_class.new(function) }
|
12
|
+
|
13
|
+
context 'when right operand is frozen' do
|
14
|
+
let(:right) { 'Right'.freeze }
|
15
|
+
|
16
|
+
it { should equal(right) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when right operand is not frozen' do
|
20
|
+
let(:right) { 'Right' }
|
21
|
+
|
22
|
+
it { should_not equal(right) }
|
23
|
+
|
24
|
+
it { should be_frozen }
|
25
|
+
|
26
|
+
it { should == right }
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Binary::UnoptimizedOperands, '#optimizable?' do
|
6
|
+
subject { object.optimizable? }
|
7
|
+
|
8
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
9
|
+
let(:described_class) { Class.new(Optimizer) { include Optimizer::Function::Binary } }
|
10
|
+
let(:function) { Class.new(Veritas::Function) { include Veritas::Function::Binary }.new(left, right) }
|
11
|
+
let(:object) { described_class.new(function) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
described_class.class_eval { include Optimizer::Function::Binary::UnoptimizedOperands }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when left is optimizable' do
|
18
|
+
let(:left) { attribute.include([ 1 ]) }
|
19
|
+
let(:right) { attribute.ne(2) }
|
20
|
+
|
21
|
+
it { should be(true) }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when right is optimizable' do
|
25
|
+
let(:left) { attribute.eq(1) }
|
26
|
+
let(:right) { attribute.exclude([ 2 ]) }
|
27
|
+
|
28
|
+
it { should be(true) }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when left and right are not optimizable' do
|
32
|
+
let(:left) { attribute.eq(1) }
|
33
|
+
let(:right) { attribute.ne(2) }
|
34
|
+
|
35
|
+
it { should be(false) }
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Binary::UnoptimizedOperands, '#optimize' do
|
6
|
+
subject { object.optimize }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(Optimizer) { include Optimizer::Function::Binary } }
|
9
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
10
|
+
let(:left) { attribute.include([ 1 ]) }
|
11
|
+
let(:right) { attribute.exclude([ 2 ]) }
|
12
|
+
let(:function) { Class.new(Veritas::Function) { include Veritas::Function::Binary }.new(left, right) }
|
13
|
+
let(:object) { described_class.new(function) }
|
14
|
+
|
15
|
+
before do
|
16
|
+
described_class.class_eval { include Optimizer::Function::Binary::UnoptimizedOperands }
|
17
|
+
object.should be_optimizable
|
18
|
+
end
|
19
|
+
|
20
|
+
its(:left) { should eql(attribute.eq(1)) }
|
21
|
+
|
22
|
+
its(:right) { should eql(attribute.ne(2)) }
|
23
|
+
end
|