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
data/.gemtest
ADDED
File without changes
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use @$(basename `pwd`) --create
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,23 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
source :rubygems
|
2
4
|
|
3
|
-
gem 'veritas', '0.0.
|
5
|
+
gem 'veritas', '0.0.4', :git => 'git://github.com/dkubb/veritas.git'
|
4
6
|
|
5
7
|
group :development do
|
6
|
-
gem 'backports', '~> 2.1
|
7
|
-
gem 'jeweler', '~> 1.
|
8
|
-
gem 'rake', '~> 0.
|
8
|
+
gem 'backports', '~> 2.2.1'
|
9
|
+
gem 'jeweler', '~> 1.6.0'
|
10
|
+
gem 'rake', '~> 0.9.0'
|
9
11
|
gem 'rspec', '~> 1.3.2'
|
10
|
-
gem 'yard', '~> 0.
|
12
|
+
gem 'yard', '~> 0.7.1'
|
13
|
+
end
|
14
|
+
|
15
|
+
group :guard do
|
16
|
+
gem 'growl', '~> 1.0.3'
|
17
|
+
gem 'guard', '~> 0.3.4'
|
18
|
+
gem 'guard-bundler', '~> 0.1.3'
|
19
|
+
gem 'guard-ego', '~> 0.0.1'
|
20
|
+
gem 'guard-rspec', '~> 0.3.1'
|
11
21
|
end
|
12
22
|
|
13
|
-
|
14
|
-
|
15
|
-
gem 'jruby-openssl', '~> 0.7.
|
23
|
+
platform :jruby do
|
24
|
+
group :jruby do
|
25
|
+
gem 'jruby-openssl', '~> 0.7.4'
|
16
26
|
end
|
17
27
|
end
|
18
28
|
|
19
29
|
platforms :mri_18 do
|
20
|
-
group :
|
30
|
+
group :metrics do
|
21
31
|
gem 'flay', '~> 1.4.2'
|
22
32
|
gem 'flog', '~> 2.5.1'
|
23
33
|
gem 'heckle', '~> 1.4.3'
|
@@ -28,6 +38,6 @@ platforms :mri_18 do
|
|
28
38
|
gem 'reek', '~> 1.2.8', :git => 'git://github.com/dkubb/reek.git'
|
29
39
|
gem 'roodi', '~> 2.1.0'
|
30
40
|
gem 'ruby2ruby', '= 1.2.2'
|
31
|
-
gem 'yardstick', '~> 0.
|
41
|
+
gem 'yardstick', '~> 0.4.0'
|
32
42
|
end
|
33
43
|
end
|
data/Guardfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
guard 'ego' do
|
4
|
+
watch('Guardfile')
|
5
|
+
end
|
6
|
+
|
7
|
+
guard 'bundler' do
|
8
|
+
watch('Gemfile')
|
9
|
+
end
|
10
|
+
|
11
|
+
guard 'rspec' do
|
12
|
+
# run all specs if the spec_helper or supporting files files are modified
|
13
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
14
|
+
watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { 'spec' }
|
15
|
+
|
16
|
+
# run unit specs if associated lib code is modified
|
17
|
+
watch(%r{\Alib/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}"] }
|
18
|
+
watch("lib/#{File.basename(File.expand_path('../', __FILE__))}.rb") { 'spec' }
|
19
|
+
|
20
|
+
# run a spec if it is modified
|
21
|
+
watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z})
|
22
|
+
end
|
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'rake'
|
2
4
|
|
3
5
|
require File.expand_path('../lib/veritas/optimizer/version', __FILE__)
|
4
6
|
|
5
7
|
begin
|
6
|
-
gem('jeweler', '~> 1.
|
8
|
+
gem('jeweler', '~> 1.6.0') if respond_to?(:gem, true)
|
7
9
|
require 'jeweler'
|
8
10
|
|
9
11
|
Jeweler::Tasks.new do |gem|
|
@@ -21,5 +23,5 @@ begin
|
|
21
23
|
|
22
24
|
FileList['tasks/**/*.rake'].each { |task| import task }
|
23
25
|
rescue LoadError
|
24
|
-
puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler -v 1.
|
26
|
+
puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler -v 1.6.0'
|
25
27
|
end
|
data/TODO
CHANGED
@@ -1,7 +1,32 @@
|
|
1
|
+
* All relations, even optimized ones, need to hold a reference to the
|
2
|
+
original (possibly optimized) operations.
|
3
|
+
* Especially "empty" relations should hold a reference to the original
|
4
|
+
relation so that insert/update can be performed on them if they are
|
5
|
+
empty not because they are valid, but because the source object is empty
|
6
|
+
* Materialized relations will need references to the original objects.
|
7
|
+
|
8
|
+
* Optimization can replace one or more AST nodes with a simpler/more efficient
|
9
|
+
structure as long as it is lossless. Just changing it to empty or
|
10
|
+
materialized, the way things are now, we lose what the original relation
|
11
|
+
was so it becomes impossible to insert/update/delete from those relations.
|
12
|
+
* A write to a materialized object should first propagate the write down
|
13
|
+
to the @operand, allowing it to raise exceptions if it's read*only,
|
14
|
+
then it should make the change in the materialized object.
|
15
|
+
|
1
16
|
* Add further optimizations:
|
2
17
|
* Projection
|
3
|
-
* When it contains a Rename, if the renamed attributes are
|
4
|
-
|
18
|
+
* When it contains a Rename, if the renamed attributes are removed,
|
19
|
+
then the rename can be removed.
|
20
|
+
* When it contains a Restriction, if the removed attributes are *not*
|
21
|
+
used in the predicate, then move the Restriction to contain the
|
22
|
+
Projection.
|
23
|
+
* When renames or extensions or summarizations are projected away and
|
24
|
+
not used in any intermediary operation, then they can be dropped
|
25
|
+
altogether. There's no point in going through all that work to
|
26
|
+
not bother using an attribute at all. It would be better to simplify
|
27
|
+
the renames/extensions/summarizations to not add the attribute, and
|
28
|
+
then call optimize again on the op to potentially remove the op altogether
|
29
|
+
(like in the case of an extension adding one attribute that is removed).
|
5
30
|
* Operation Order:
|
6
31
|
* Projection containing an Order
|
7
32
|
* Should remove the Order, since it is a noop
|
@@ -73,3 +98,19 @@
|
|
73
98
|
* Limit with a limit >= 1 can be factored out
|
74
99
|
* Offset with an offset > 0 can be transformed into an empty
|
75
100
|
relation, since at most there can be only one match.
|
101
|
+
|
102
|
+
* Summarization
|
103
|
+
* Add OrderSummarizePer for factoring out Order objects inside a Summarization
|
104
|
+
* When there are no aggregate functions, drop the Summarization and
|
105
|
+
return the summarize_per (?)
|
106
|
+
* Use the UnchangedHeader optimizer as a base class
|
107
|
+
* When summarize_per is TABLE_DEE, and it is wrapped by Order, at most only
|
108
|
+
one row can be returned, so Order can probably be dropped.
|
109
|
+
* Consider making relations that represents a 0 or 1 tuple relations
|
110
|
+
and use them in this case.
|
111
|
+
|
112
|
+
* Projection
|
113
|
+
* It does not distribute over Intersection or Difference, but see if
|
114
|
+
perhaps an exception can be made if there is a functional dependency
|
115
|
+
between the columns projected away and the one remaining. Then I *think*
|
116
|
+
it might still work, but more research will be needed.
|
data/config/flay.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
---
|
2
|
-
threshold:
|
3
|
-
total_score:
|
2
|
+
threshold: 126
|
3
|
+
total_score: 870
|
data/config/flog.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
---
|
2
|
-
threshold:
|
2
|
+
threshold: 11.6
|
data/config/roodi.yml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
---
|
2
|
-
AbcMetricMethodCheck: { score:
|
2
|
+
AbcMetricMethodCheck: { score: 8.6 }
|
3
3
|
AssignmentInConditionalCheck: { }
|
4
4
|
CaseMissingElseCheck: { }
|
5
|
-
ClassLineCountCheck: { line_count:
|
5
|
+
ClassLineCountCheck: { line_count: 396 }
|
6
6
|
ClassNameCheck: { pattern: !ruby/regexp /\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/ }
|
7
7
|
ClassVariableCheck: { }
|
8
8
|
CyclomaticComplexityBlockCheck: { complexity: 2 }
|
@@ -10,7 +10,7 @@ CyclomaticComplexityMethodCheck: { complexity: 6 }
|
|
10
10
|
EmptyRescueBodyCheck: { }
|
11
11
|
ForLoopCheck: { }
|
12
12
|
MethodLineCountCheck: { line_count: 9 }
|
13
|
-
MethodNameCheck: { pattern: !ruby/regexp /\A(?:[a-z](?:_?[a-z])+[?!=]?|\[\]=?|==|<=>|[+*&|-])\z/ }
|
14
|
-
ModuleLineCountCheck: { line_count:
|
13
|
+
MethodNameCheck: { pattern: !ruby/regexp /\A(?:[a-z\d](?:_?[a-z\d])+[?!=]?|\[\]=?|==|<=>|[+*&|-])\z/ }
|
14
|
+
ModuleLineCountCheck: { line_count: 398 }
|
15
15
|
ModuleNameCheck: { pattern: !ruby/regexp /\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/ }
|
16
16
|
ParameterNumberCheck: { parameter_count: 3 }
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Veritas
|
4
|
+
class Optimizer
|
5
|
+
class Aggregate
|
6
|
+
|
7
|
+
# Abstract base class representing Count optimizations
|
8
|
+
class Count < self
|
9
|
+
|
10
|
+
Veritas::Aggregate::Count.optimizer = chain(
|
11
|
+
UnoptimizedOperand
|
12
|
+
)
|
13
|
+
|
14
|
+
end # class Count
|
15
|
+
end # class Aggregate
|
16
|
+
end # class Optimizer
|
17
|
+
end # module Veritas
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Veritas
|
4
|
+
class Optimizer
|
5
|
+
class Aggregate
|
6
|
+
|
7
|
+
# Abstract base class representing Maximum optimizations
|
8
|
+
class Maximum < self
|
9
|
+
|
10
|
+
Veritas::Aggregate::Maximum.optimizer = chain(
|
11
|
+
UnoptimizedOperand
|
12
|
+
)
|
13
|
+
|
14
|
+
end # class Maximum
|
15
|
+
end # class Aggregate
|
16
|
+
end # class Optimizer
|
17
|
+
end # module Veritas
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Veritas
|
4
|
+
class Optimizer
|
5
|
+
class Aggregate
|
6
|
+
|
7
|
+
# Abstract base class representing Mean optimizations
|
8
|
+
class Mean < self
|
9
|
+
|
10
|
+
Veritas::Aggregate::Mean.optimizer = chain(
|
11
|
+
UnoptimizedOperand
|
12
|
+
)
|
13
|
+
|
14
|
+
end # class Mean
|
15
|
+
end # class Aggregate
|
16
|
+
end # class Optimizer
|
17
|
+
end # module Veritas
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Veritas
|
4
|
+
class Optimizer
|
5
|
+
class Aggregate
|
6
|
+
|
7
|
+
# Abstract base class representing Minimum optimizations
|
8
|
+
class Minimum < self
|
9
|
+
|
10
|
+
Veritas::Aggregate::Minimum.optimizer = chain(
|
11
|
+
UnoptimizedOperand
|
12
|
+
)
|
13
|
+
|
14
|
+
end # class Minimum
|
15
|
+
end # class Aggregate
|
16
|
+
end # class Optimizer
|
17
|
+
end # module Veritas
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Veritas
|
4
|
+
class Optimizer
|
5
|
+
class Aggregate
|
6
|
+
|
7
|
+
# Abstract base class representing StandardDeviation optimizations
|
8
|
+
class StandardDeviation < self
|
9
|
+
|
10
|
+
Veritas::Aggregate::StandardDeviation.optimizer = chain(
|
11
|
+
UnoptimizedOperand
|
12
|
+
)
|
13
|
+
|
14
|
+
end # class StandardDeviation
|
15
|
+
end # class Aggregate
|
16
|
+
end # class Optimizer
|
17
|
+
end # module Veritas
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Veritas
|
4
|
+
class Optimizer
|
5
|
+
class Aggregate
|
6
|
+
|
7
|
+
# Abstract base class representing Sum optimizations
|
8
|
+
class Sum < self
|
9
|
+
|
10
|
+
Veritas::Aggregate::Sum.optimizer = chain(
|
11
|
+
UnoptimizedOperand
|
12
|
+
)
|
13
|
+
|
14
|
+
end # class Sum
|
15
|
+
end # class Aggregate
|
16
|
+
end # class Optimizer
|
17
|
+
end # module Veritas
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Veritas
|
4
|
+
class Optimizer
|
5
|
+
class Aggregate
|
6
|
+
|
7
|
+
# Abstract base class representing Variance optimizations
|
8
|
+
class Variance < self
|
9
|
+
|
10
|
+
Veritas::Aggregate::Variance.optimizer = chain(
|
11
|
+
UnoptimizedOperand
|
12
|
+
)
|
13
|
+
|
14
|
+
end # class Variance
|
15
|
+
end # class Aggregate
|
16
|
+
end # class Optimizer
|
17
|
+
end # module Veritas
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Veritas
|
4
|
+
class Optimizer
|
5
|
+
|
6
|
+
# Abstract base class representing Aggregate optimizations
|
7
|
+
class Aggregate < Optimizer
|
8
|
+
include AbstractClass, Function::Unary
|
9
|
+
|
10
|
+
# Optimize when the operands are unoptimized
|
11
|
+
class UnoptimizedOperand < self
|
12
|
+
include Function::Unary::UnoptimizedOperand
|
13
|
+
end # class UnoptimizedOperand
|
14
|
+
end # class Aggregate
|
15
|
+
end # class Optimizer
|
16
|
+
end # module Veritas
|
@@ -7,8 +7,51 @@ module Veritas
|
|
7
7
|
# Abstract base class representing Extension optimizations
|
8
8
|
class Extension < Relation::Operation::Unary
|
9
9
|
|
10
|
+
# The optimized extensions
|
11
|
+
#
|
12
|
+
# @return [Hash{Attribute => Function}]
|
13
|
+
#
|
14
|
+
# @api private
|
15
|
+
attr_reader :extensions
|
16
|
+
|
17
|
+
# Initialize a Summarization optimizer
|
18
|
+
#
|
19
|
+
# @return [undefined]
|
20
|
+
#
|
21
|
+
# @api private
|
22
|
+
def initialize(*)
|
23
|
+
super
|
24
|
+
@extensions = optimize_extensions
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# Optimize the extensions
|
30
|
+
#
|
31
|
+
# @return [Hash{Attribute => Function}]
|
32
|
+
#
|
33
|
+
# @api private
|
34
|
+
def optimize_extensions
|
35
|
+
Function.optimize_functions(operation.extensions)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Wrap the operand's operand in an Extension
|
39
|
+
#
|
40
|
+
# @return [Extension]
|
41
|
+
#
|
42
|
+
# @api private
|
43
|
+
def wrap_operand(operand = operand.operand)
|
44
|
+
operation.class.new(operand, extensions)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Optimize when the operand is an Order
|
48
|
+
class OrderOperand < self
|
49
|
+
include Relation::Operation::Unary::OrderOperand
|
50
|
+
end # class OrderOperand
|
51
|
+
|
10
52
|
# Optimize when operands are optimizable
|
11
53
|
class UnoptimizedOperand < self
|
54
|
+
include Function::Unary::UnoptimizedOperand
|
12
55
|
|
13
56
|
# Test if the operand is unoptimized
|
14
57
|
#
|
@@ -16,7 +59,7 @@ module Veritas
|
|
16
59
|
#
|
17
60
|
# @api private
|
18
61
|
def optimizable?
|
19
|
-
|
62
|
+
super || extensions_optimizable?
|
20
63
|
end
|
21
64
|
|
22
65
|
# Return an Extension with an optimized operand
|
@@ -25,14 +68,26 @@ module Veritas
|
|
25
68
|
#
|
26
69
|
# @api private
|
27
70
|
def optimize
|
28
|
-
|
29
|
-
|
71
|
+
wrap_operand(operand)
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
# Test if the extensions are optimizable
|
77
|
+
#
|
78
|
+
# @return [Boolean]
|
79
|
+
#
|
80
|
+
# @api private
|
81
|
+
def extensions_optimizable?
|
82
|
+
!extensions.eql?(operation.extensions)
|
30
83
|
end
|
31
84
|
|
32
85
|
end # class UnoptimizedOperand
|
33
86
|
|
34
87
|
Veritas::Algebra::Extension.optimizer = chain(
|
88
|
+
UnchangedHeader,
|
35
89
|
MaterializedOperand,
|
90
|
+
OrderOperand,
|
36
91
|
UnoptimizedOperand
|
37
92
|
)
|
38
93
|
|
@@ -7,10 +7,10 @@ module Veritas
|
|
7
7
|
# Abstract base class representing Join optimizations
|
8
8
|
class Join < Relation::Operation::Combination
|
9
9
|
|
10
|
-
# Optimize when
|
10
|
+
# Optimize when operands' headers are equal
|
11
11
|
class EqualHeaders < self
|
12
12
|
|
13
|
-
# Test if the operands' headers are equal
|
13
|
+
# Test if the operands' headers are equal to the join's headers
|
14
14
|
#
|
15
15
|
# @return [Boolean]
|
16
16
|
#
|
@@ -19,7 +19,7 @@ module Veritas
|
|
19
19
|
left.header.eql?(right.header)
|
20
20
|
end
|
21
21
|
|
22
|
-
# A Join with equal
|
22
|
+
# A Join with an equal header is an Intersection
|
23
23
|
#
|
24
24
|
# @return [Algebra::Intersection]
|
25
25
|
#
|
@@ -34,8 +34,10 @@ module Veritas
|
|
34
34
|
EmptyLeft,
|
35
35
|
EmptyRight,
|
36
36
|
EqualHeaders,
|
37
|
+
LeftOrderOperand,
|
38
|
+
RightOrderOperand,
|
37
39
|
MaterializedOperand,
|
38
|
-
|
40
|
+
UnoptimizedOperands
|
39
41
|
)
|
40
42
|
|
41
43
|
end # class Join
|
@@ -7,46 +7,17 @@ module Veritas
|
|
7
7
|
# Abstract base class representing Projection optimizations
|
8
8
|
class Projection < Relation::Operation::Unary
|
9
9
|
|
10
|
-
|
11
|
-
#
|
12
|
-
# @return [Header]
|
13
|
-
#
|
14
|
-
# @api private
|
15
|
-
attr_reader :header
|
10
|
+
private
|
16
11
|
|
17
|
-
#
|
12
|
+
# Wrap the operand's operand in a Projection
|
18
13
|
#
|
19
|
-
# @return [
|
14
|
+
# @return [Projection]
|
20
15
|
#
|
21
16
|
# @api private
|
22
|
-
def
|
23
|
-
|
24
|
-
@header = operation.header
|
17
|
+
def wrap_operand(operand = operand.operand)
|
18
|
+
operation.class.new(operand, header)
|
25
19
|
end
|
26
20
|
|
27
|
-
# Optimize when the headers are not changed
|
28
|
-
class UnchangedHeader < self
|
29
|
-
|
30
|
-
# Test if the projected headers are the same as the operand's
|
31
|
-
#
|
32
|
-
# @return [Boolean]
|
33
|
-
#
|
34
|
-
# @api private
|
35
|
-
def optimizable?
|
36
|
-
header.to_a == operand.header.to_a
|
37
|
-
end
|
38
|
-
|
39
|
-
# A Projection with unchanged headers is a noop
|
40
|
-
#
|
41
|
-
# @return [Relation]
|
42
|
-
#
|
43
|
-
# @api private
|
44
|
-
def optimize
|
45
|
-
operand
|
46
|
-
end
|
47
|
-
|
48
|
-
end # class UnchangedHeader
|
49
|
-
|
50
21
|
# Optimize when the operand is a Projection
|
51
22
|
class ProjectionOperand < self
|
52
23
|
|
@@ -65,24 +36,24 @@ module Veritas
|
|
65
36
|
#
|
66
37
|
# @api private
|
67
38
|
def optimize
|
68
|
-
|
39
|
+
wrap_operand
|
69
40
|
end
|
70
41
|
|
71
42
|
end # class ProjectionOperand
|
72
43
|
|
73
|
-
# Optimize when the operand is a
|
74
|
-
class
|
44
|
+
# Optimize when the operand is a Union
|
45
|
+
class UnionOperand < self
|
75
46
|
|
76
|
-
# Test if the operand is a
|
47
|
+
# Test if the operand is a Union
|
77
48
|
#
|
78
49
|
# @return [Boolean]
|
79
50
|
#
|
80
51
|
# @api private
|
81
52
|
def optimizable?
|
82
|
-
operand.kind_of?(Veritas::
|
53
|
+
operand.kind_of?(Veritas::Algebra::Union)
|
83
54
|
end
|
84
55
|
|
85
|
-
# Wrap each operand in the
|
56
|
+
# Wrap each operand in the Union in a Projection
|
86
57
|
#
|
87
58
|
# @return [Set]
|
88
59
|
#
|
@@ -99,7 +70,7 @@ module Veritas
|
|
99
70
|
#
|
100
71
|
# @api private
|
101
72
|
def wrap_left
|
102
|
-
|
73
|
+
wrap_operand(operand.left)
|
103
74
|
end
|
104
75
|
|
105
76
|
# Utility method to wrap the right operand in a Projection
|
@@ -108,10 +79,15 @@ module Veritas
|
|
108
79
|
#
|
109
80
|
# @api private
|
110
81
|
def wrap_right
|
111
|
-
|
82
|
+
wrap_operand(operand.right)
|
112
83
|
end
|
113
84
|
|
114
|
-
end # class
|
85
|
+
end # class UnionOperand
|
86
|
+
|
87
|
+
# Optimize when the operand is an Order
|
88
|
+
class OrderOperand < self
|
89
|
+
include Relation::Operation::Unary::OrderOperand
|
90
|
+
end # class OrderOperand
|
115
91
|
|
116
92
|
# Optimize when the operand is Empty
|
117
93
|
class EmptyOperand < self
|
@@ -138,15 +114,7 @@ module Veritas
|
|
138
114
|
|
139
115
|
# Optimize when operand is optimizable
|
140
116
|
class UnoptimizedOperand < self
|
141
|
-
|
142
|
-
# Test if the operand is unoptimized
|
143
|
-
#
|
144
|
-
# @return [Boolean]
|
145
|
-
#
|
146
|
-
# @api private
|
147
|
-
def optimizable?
|
148
|
-
!operand.equal?(operation.operand)
|
149
|
-
end
|
117
|
+
include Function::Unary::UnoptimizedOperand
|
150
118
|
|
151
119
|
# Return a Projection with an optimized operand
|
152
120
|
#
|
@@ -154,7 +122,7 @@ module Veritas
|
|
154
122
|
#
|
155
123
|
# @api private
|
156
124
|
def optimize
|
157
|
-
|
125
|
+
wrap_operand(operand)
|
158
126
|
end
|
159
127
|
|
160
128
|
end # class UnoptimizedOperand
|
@@ -162,7 +130,8 @@ module Veritas
|
|
162
130
|
Veritas::Algebra::Projection.optimizer = chain(
|
163
131
|
UnchangedHeader,
|
164
132
|
ProjectionOperand,
|
165
|
-
|
133
|
+
UnionOperand,
|
134
|
+
OrderOperand,
|
166
135
|
EmptyOperand,
|
167
136
|
MaterializedOperand,
|
168
137
|
UnoptimizedOperand
|