veritas-optimizer 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +33 -0
- data/LICENSE +20 -0
- data/README.rdoc +27 -0
- data/Rakefile +25 -0
- data/TODO +75 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/roodi.yml +16 -0
- data/config/site.reek +91 -0
- data/config/yardstick.yml +2 -0
- data/lib/veritas/optimizer/algebra/difference.rb +66 -0
- data/lib/veritas/optimizer/algebra/extension.rb +42 -0
- data/lib/veritas/optimizer/algebra/intersection.rb +66 -0
- data/lib/veritas/optimizer/algebra/join.rb +44 -0
- data/lib/veritas/optimizer/algebra/product.rb +70 -0
- data/lib/veritas/optimizer/algebra/projection.rb +174 -0
- data/lib/veritas/optimizer/algebra/rename.rb +396 -0
- data/lib/veritas/optimizer/algebra/restriction.rb +259 -0
- data/lib/veritas/optimizer/algebra/summarization.rb +42 -0
- data/lib/veritas/optimizer/algebra/union.rb +66 -0
- data/lib/veritas/optimizer/logic/connective/binary.rb +254 -0
- data/lib/veritas/optimizer/logic/connective/conjunction.rb +122 -0
- data/lib/veritas/optimizer/logic/connective/disjunction.rb +122 -0
- data/lib/veritas/optimizer/logic/connective/negation.rb +71 -0
- data/lib/veritas/optimizer/logic/predicate/comparable.rb +134 -0
- data/lib/veritas/optimizer/logic/predicate/enumerable.rb +141 -0
- data/lib/veritas/optimizer/logic/predicate/equality.rb +44 -0
- data/lib/veritas/optimizer/logic/predicate/exclusion.rb +53 -0
- data/lib/veritas/optimizer/logic/predicate/greater_than.rb +54 -0
- data/lib/veritas/optimizer/logic/predicate/greater_than_or_equal_to.rb +56 -0
- data/lib/veritas/optimizer/logic/predicate/inclusion.rb +53 -0
- data/lib/veritas/optimizer/logic/predicate/inequality.rb +44 -0
- data/lib/veritas/optimizer/logic/predicate/less_than.rb +54 -0
- data/lib/veritas/optimizer/logic/predicate/less_than_or_equal_to.rb +56 -0
- data/lib/veritas/optimizer/logic/predicate/match.rb +19 -0
- data/lib/veritas/optimizer/logic/predicate/no_match.rb +19 -0
- data/lib/veritas/optimizer/logic/predicate.rb +177 -0
- data/lib/veritas/optimizer/optimizable.rb +59 -0
- data/lib/veritas/optimizer/relation/materialized.rb +40 -0
- data/lib/veritas/optimizer/relation/operation/binary.rb +168 -0
- data/lib/veritas/optimizer/relation/operation/combination.rb +33 -0
- data/lib/veritas/optimizer/relation/operation/limit.rb +149 -0
- data/lib/veritas/optimizer/relation/operation/offset.rb +114 -0
- data/lib/veritas/optimizer/relation/operation/order.rb +96 -0
- data/lib/veritas/optimizer/relation/operation/reverse.rb +94 -0
- data/lib/veritas/optimizer/relation/operation/unary.rb +88 -0
- data/lib/veritas/optimizer/version.rb +7 -0
- data/lib/veritas/optimizer.rb +136 -0
- data/lib/veritas-optimizer.rb +3 -0
- data/spec/integration/veritas/algebra/difference/optimize_spec.rb +152 -0
- data/spec/integration/veritas/algebra/intersection/optimize_spec.rb +152 -0
- data/spec/integration/veritas/algebra/join/optimize_spec.rb +110 -0
- data/spec/integration/veritas/algebra/product/optimize_spec.rb +176 -0
- data/spec/integration/veritas/algebra/projection/optimize_spec.rb +237 -0
- data/spec/integration/veritas/algebra/rename/optimize_spec.rb +440 -0
- data/spec/integration/veritas/algebra/restriction/optimize_spec.rb +216 -0
- data/spec/integration/veritas/algebra/union/optimize_spec.rb +192 -0
- data/spec/integration/veritas/logic/connective/conjunction/optimize_spec.rb +234 -0
- data/spec/integration/veritas/logic/connective/disjunction/optimize_spec.rb +235 -0
- data/spec/integration/veritas/logic/connective/negation/optimize_spec.rb +41 -0
- data/spec/integration/veritas/logic/expression/optimize_spec.rb +42 -0
- data/spec/integration/veritas/logic/predicate/equality/optimize_spec.rb +90 -0
- data/spec/integration/veritas/logic/predicate/exclusion/optimize_spec.rb +131 -0
- data/spec/integration/veritas/logic/predicate/greater_than/optimize_spec.rb +100 -0
- data/spec/integration/veritas/logic/predicate/greater_than_or_equal_to/optimize_spec.rb +100 -0
- data/spec/integration/veritas/logic/predicate/inclusion/optimize_spec.rb +131 -0
- data/spec/integration/veritas/logic/predicate/inequality/optimize_spec.rb +90 -0
- data/spec/integration/veritas/logic/predicate/less_than/optimize_spec.rb +100 -0
- data/spec/integration/veritas/logic/predicate/less_than_or_equal_to/optimize_spec.rb +100 -0
- data/spec/integration/veritas/relation/empty/optimize_spec.rb +11 -0
- data/spec/integration/veritas/relation/materialized/optimize_spec.rb +37 -0
- data/spec/integration/veritas/relation/operation/limit/optimize_spec.rb +140 -0
- data/spec/integration/veritas/relation/operation/offset/optimize_spec.rb +98 -0
- data/spec/integration/veritas/relation/operation/order/optimize_spec.rb +103 -0
- data/spec/integration/veritas/relation/operation/reverse/optimize_spec.rb +113 -0
- data/spec/integration/veritas/relation/optimize_spec.rb +33 -0
- data/spec/rcov.opts +6 -0
- data/spec/shared/idempotent_method_behavior.rb +5 -0
- data/spec/shared/logic_connective_binary_optimize_behavior.rb +100 -0
- data/spec/shared/optimize_method_behavior.rb +14 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/add_method_missing.rb +13 -0
- data/spec/unit/veritas/optimizer/algebra/difference/empty_left/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/algebra/difference/empty_right/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/algebra/difference/equal_operands/optimize_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimize_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/algebra/intersection/empty_left/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/algebra/intersection/empty_right/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/algebra/intersection/equal_operands/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/algebra/join/equal_headers/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/algebra/join/equal_headers/optimize_spec.rb +21 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_left/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_left/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_right/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_right/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/algebra/projection/empty_operand/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/algebra/projection/empty_operand/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/algebra/projection/header_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/algebra/projection/projection_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/algebra/projection/projection_operand/optimize_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/algebra/projection/set_operand/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/algebra/projection/set_operand/optimize_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/algebra/projection/unchanged_header/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/algebra/projection/unchanged_header/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/algebra/projection/unoptimized_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/algebra/projection/unoptimized_operand/optimize_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/algebra/rename/aliases_spec.rb +31 -0
- data/spec/unit/veritas/optimizer/algebra/rename/class_methods/union_aliases_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/algebra/rename/empty_operand/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/algebra/rename/empty_operand/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/algebra/rename/header_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/algebra/rename/limit_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/algebra/rename/limit_operand/optimize_spec.rb +21 -0
- data/spec/unit/veritas/optimizer/algebra/rename/offset_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/algebra/rename/offset_operand/optimize_spec.rb +21 -0
- data/spec/unit/veritas/optimizer/algebra/rename/order_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/algebra/rename/order_operand/optimize_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/algebra/rename/projection_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/algebra/rename/projection_operand/optimize_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand/optimizable_spec.rb +28 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand/optimize_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimizable_spec.rb +35 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/algebra/rename/restriction_operand/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/algebra/rename/restriction_operand/optimize_spec.rb +21 -0
- data/spec/unit/veritas/optimizer/algebra/rename/reverse_operand/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/algebra/rename/reverse_operand/optimize_spec.rb +21 -0
- data/spec/unit/veritas/optimizer/algebra/rename/set_operand/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/algebra/rename/set_operand/optimize_spec.rb +21 -0
- data/spec/unit/veritas/optimizer/algebra/rename/unchanged_header/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/algebra/rename/unchanged_header/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/algebra/rename/unoptimized_operand/optimizable_spec.rb +42 -0
- data/spec/unit/veritas/optimizer/algebra/rename/unoptimized_operand/optimize_spec.rb +21 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/class_methods/optimize_predicate_spec.rb +31 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/contradiction/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/contradiction/optimize_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/order_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/order_operand/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/predicate_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/restriction_operand/optimizable_spec.rb +28 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/restriction_operand/optimize_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/reverse_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/reverse_operand/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/set_operand/optimizable_spec.rb +28 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/set_operand/optimize_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/tautology/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/tautology/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimizable_spec.rb +42 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimize_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/unoptimized_operand/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/unoptimized_operand/optimize_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/algebra/union/empty_left/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/algebra/union/empty_right/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/algebra/union/equal_operands/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/class_methods/chain_spec.rb +54 -0
- data/spec/unit/veritas/optimizer/logic/connective/binary/equal_operands/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/logic/connective/binary/equal_operands/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/logic/connective/binary/left_spec.rb +14 -0
- data/spec/unit/veritas/optimizer/logic/connective/binary/redundant_left_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/logic/connective/binary/redundant_left_operand/optimize_spec.rb +21 -0
- data/spec/unit/veritas/optimizer/logic/connective/binary/redundant_right_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/logic/connective/binary/redundant_right_operand/optimize_spec.rb +21 -0
- data/spec/unit/veritas/optimizer/logic/connective/binary/right_spec.rb +14 -0
- data/spec/unit/veritas/optimizer/logic/connective/binary/unoptimized_operand/optimizable_spec.rb +34 -0
- data/spec/unit/veritas/optimizer/logic/connective/binary/unoptimized_operand/optimize_spec.rb +21 -0
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/contradiction/optimizable_spec.rb +41 -0
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/contradiction/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/left_operand_tautology/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/left_operand_tautology/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/optimizable_to_exclusion/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/optimizable_to_exclusion/optimize_spec.rb +36 -0
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/right_operand_tautology/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/right_operand_tautology/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/contradiction_left_operand/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/contradiction_left_operand/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/contradiction_right_operand/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/contradiction_right_operand/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/optimizable_to_inclusion/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/optimizable_to_inclusion/optimize_spec.rb +36 -0
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/tautology/optimizable_spec.rb +41 -0
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/tautology/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/logic/connective/negation/invertible_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/logic/connective/negation/invertible_operand/optimize_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/logic/connective/negation/operand_spec.rb +12 -0
- data/spec/unit/veritas/optimizer/logic/predicate/class_methods/optimize_operand_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/logic/predicate/comparable/never_comparable/optimizable_spec.rb +58 -0
- data/spec/unit/veritas/optimizer/logic/predicate/comparable/never_equivalent/optimizable_spec.rb +58 -0
- data/spec/unit/veritas/optimizer/logic/predicate/comparable/normalizable_operands/optimizable_spec.rb +41 -0
- data/spec/unit/veritas/optimizer/logic/predicate/comparable/normalizable_operands/optimize_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/logic/predicate/constant_operands/optimizable_spec.rb +29 -0
- data/spec/unit/veritas/optimizer/logic/predicate/constant_operands/optimize_spec.rb +14 -0
- data/spec/unit/veritas/optimizer/logic/predicate/contradiction/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/logic/predicate/enumerable/empty_right_operand/optimizable_spec.rb +76 -0
- data/spec/unit/veritas/optimizer/logic/predicate/enumerable/one_right_operand/optimizable_spec.rb +76 -0
- data/spec/unit/veritas/optimizer/logic/predicate/enumerable/unoptimized_operand/optimizable_spec.rb +49 -0
- data/spec/unit/veritas/optimizer/logic/predicate/enumerable/unoptimized_operand/optimize_spec.rb +53 -0
- data/spec/unit/veritas/optimizer/logic/predicate/equality/tautology/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/logic/predicate/exclusion/empty_right_operand/optimize_spec.rb +43 -0
- data/spec/unit/veritas/optimizer/logic/predicate/exclusion/one_right_operand/optimize_spec.rb +63 -0
- data/spec/unit/veritas/optimizer/logic/predicate/greater_than/contradiction/optimizable_spec.rb +41 -0
- data/spec/unit/veritas/optimizer/logic/predicate/greater_than/tautology/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/logic/predicate/greater_than_or_equal_to/contradiction/optimizable_spec.rb +41 -0
- data/spec/unit/veritas/optimizer/logic/predicate/greater_than_or_equal_to/tautology/optimizable_spec.rb +41 -0
- data/spec/unit/veritas/optimizer/logic/predicate/inclusion/empty_right_operand/optimize_spec.rb +43 -0
- data/spec/unit/veritas/optimizer/logic/predicate/inclusion/one_right_operand/optimize_spec.rb +64 -0
- data/spec/unit/veritas/optimizer/logic/predicate/inequality/contradiction/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/logic/predicate/left_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/logic/predicate/less_than/contradiction/optimizable_spec.rb +41 -0
- data/spec/unit/veritas/optimizer/logic/predicate/less_than/tautology/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/logic/predicate/less_than_or_equal_to/contradiction/optimizable_spec.rb +41 -0
- data/spec/unit/veritas/optimizer/logic/predicate/less_than_or_equal_to/tautology/optimizable_spec.rb +41 -0
- data/spec/unit/veritas/optimizer/logic/predicate/right_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/logic/predicate/tautology/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/logic/predicate/util/class_methods/attribute_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/logic/predicate/util/class_methods/constant_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/logic/predicate/util/class_methods/max_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/logic/predicate/util/class_methods/min_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/operation_spec.rb +11 -0
- data/spec/unit/veritas/optimizer/optimizable/class_methods/optimizer_spec.rb +32 -0
- data/spec/unit/veritas/optimizer/optimizable/optimize_spec.rb +36 -0
- data/spec/unit/veritas/optimizer/optimizable_spec.rb +15 -0
- data/spec/unit/veritas/optimizer/optimize_spec.rb +15 -0
- data/spec/unit/veritas/optimizer/relation/materialized/empty_operand/optimizable_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/relation/materialized/empty_operand/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/empty_left/optimizable_spec.rb +30 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/empty_right/optimizable_spec.rb +30 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/equal_operands/optimizable_spec.rb +34 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/left_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/materialized_operand/optimizable_spec.rb +35 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/materialized_operand/optimize_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/right_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/unoptimized_operand/optimizable_spec.rb +38 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/unoptimized_operand/optimize_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/relation/operation/combination/optimize_spec.rb +14 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/equal_limit_operand/optimizable_spec.rb +31 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/equal_limit_operand/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/limit_operand/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/limit_operand/optimize_spec.rb +33 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/unoptimized_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/unoptimized_operand/optimize_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/zero_limit/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/zero_limit/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/offset_operand/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/offset_operand/optimize_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/unoptimized_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/unoptimized_operand/optimize_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/zero_offset/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/zero_offset/optimize_spec.rb +15 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/one_limit_operand/optimizable_spec.rb +31 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/one_limit_operand/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/order_operand/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/order_operand/optimize_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/unoptimized_operand/optimizable_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/unoptimized_operand/optimize_spec.rb +21 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/order_operand/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/order_operand/optimize_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/reverse_operand/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/reverse_operand/optimize_spec.rb +17 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/unoptimized_operand/optimizable_spec.rb +25 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/unoptimized_operand/optimize_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/empty_operand/optimizable_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/empty_operand/optimize_spec.rb +15 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/materialized_operand/optimizable_spec.rb +20 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/materialized_operand/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/operand_spec.rb +13 -0
- data/tasks/quality/ci.rake +2 -0
- data/tasks/quality/flay.rake +41 -0
- data/tasks/quality/flog.rake +45 -0
- data/tasks/quality/heckle.rake +203 -0
- data/tasks/quality/metric_fu.rake +26 -0
- data/tasks/quality/reek.rake +9 -0
- data/tasks/quality/roodi.rake +15 -0
- data/tasks/quality/yardstick.rake +23 -0
- data/tasks/spec.rake +38 -0
- data/tasks/yard.rake +9 -0
- data/veritas-optimizer.gemspec +550 -0
- metadata +613 -0
@@ -0,0 +1,174 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Veritas
|
4
|
+
class Optimizer
|
5
|
+
module Algebra
|
6
|
+
|
7
|
+
# Abstract base class representing Projection optimizations
|
8
|
+
class Projection < Relation::Operation::Unary
|
9
|
+
|
10
|
+
# The projected header
|
11
|
+
#
|
12
|
+
# @return [Header]
|
13
|
+
#
|
14
|
+
# @api private
|
15
|
+
attr_reader :header
|
16
|
+
|
17
|
+
# Initialize an Projection optimizer
|
18
|
+
#
|
19
|
+
# @return [undefined]
|
20
|
+
#
|
21
|
+
# @api private
|
22
|
+
def initialize(*)
|
23
|
+
super
|
24
|
+
@header = operation.header
|
25
|
+
end
|
26
|
+
|
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
|
+
# Optimize when the operand is a Projection
|
51
|
+
class ProjectionOperand < self
|
52
|
+
|
53
|
+
# Test if the operand is a Projection
|
54
|
+
#
|
55
|
+
# @return [Boolean]
|
56
|
+
#
|
57
|
+
# @api private
|
58
|
+
def optimizable?
|
59
|
+
operand.kind_of?(operation.class)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Flatten nested Projections into a single Projection
|
63
|
+
#
|
64
|
+
# @return [Projection]
|
65
|
+
#
|
66
|
+
# @api private
|
67
|
+
def optimize
|
68
|
+
operation.class.new(operand.operand, header)
|
69
|
+
end
|
70
|
+
|
71
|
+
end # class ProjectionOperand
|
72
|
+
|
73
|
+
# Optimize when the operand is a Set
|
74
|
+
class SetOperand < self
|
75
|
+
|
76
|
+
# Test if the operand is a Set
|
77
|
+
#
|
78
|
+
# @return [Boolean]
|
79
|
+
#
|
80
|
+
# @api private
|
81
|
+
def optimizable?
|
82
|
+
operand.kind_of?(Veritas::Relation::Operation::Set)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Wrap each operand in the Set in a Projection
|
86
|
+
#
|
87
|
+
# @return [Set]
|
88
|
+
#
|
89
|
+
# @api private
|
90
|
+
def optimize
|
91
|
+
operand.class.new(wrap_left, wrap_right)
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
# Utility method to wrap the left operand in a Projection
|
97
|
+
#
|
98
|
+
# @return [Projection]
|
99
|
+
#
|
100
|
+
# @api private
|
101
|
+
def wrap_left
|
102
|
+
operation.class.new(operand.left, header)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Utility method to wrap the right operand in a Projection
|
106
|
+
#
|
107
|
+
# @return [Projection]
|
108
|
+
#
|
109
|
+
# @api private
|
110
|
+
def wrap_right
|
111
|
+
operation.class.new(operand.right, header)
|
112
|
+
end
|
113
|
+
|
114
|
+
end # class SetOperand
|
115
|
+
|
116
|
+
# Optimize when the operand is Empty
|
117
|
+
class EmptyOperand < self
|
118
|
+
|
119
|
+
# Test if the operand is empty
|
120
|
+
#
|
121
|
+
# @return [Boolean]
|
122
|
+
#
|
123
|
+
# @api private
|
124
|
+
def optimizable?
|
125
|
+
operand.kind_of?(Veritas::Relation::Empty)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Return a new Empty relation with the operation's headers
|
129
|
+
#
|
130
|
+
# @return [Empty]
|
131
|
+
#
|
132
|
+
# @api private
|
133
|
+
def optimize
|
134
|
+
Veritas::Relation::Empty.new(header)
|
135
|
+
end
|
136
|
+
|
137
|
+
end # class EmptyOperand
|
138
|
+
|
139
|
+
# Optimize when operand is optimizable
|
140
|
+
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
|
150
|
+
|
151
|
+
# Return a Projection with an optimized operand
|
152
|
+
#
|
153
|
+
# @return [Projection]
|
154
|
+
#
|
155
|
+
# @api private
|
156
|
+
def optimize
|
157
|
+
operation.class.new(operand, header)
|
158
|
+
end
|
159
|
+
|
160
|
+
end # class UnoptimizedOperand
|
161
|
+
|
162
|
+
Veritas::Algebra::Projection.optimizer = chain(
|
163
|
+
UnchangedHeader,
|
164
|
+
ProjectionOperand,
|
165
|
+
SetOperand,
|
166
|
+
EmptyOperand,
|
167
|
+
MaterializedOperand,
|
168
|
+
UnoptimizedOperand
|
169
|
+
)
|
170
|
+
|
171
|
+
end # class Projection
|
172
|
+
end # module Algebra
|
173
|
+
end # class Optimizer
|
174
|
+
end # module Veritas
|
@@ -0,0 +1,396 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Veritas
|
4
|
+
class Optimizer
|
5
|
+
module Algebra
|
6
|
+
|
7
|
+
# Abstract base class representing Rename optimizations
|
8
|
+
class Rename < Relation::Operation::Unary
|
9
|
+
|
10
|
+
# The renamed header
|
11
|
+
#
|
12
|
+
# @return [Header]
|
13
|
+
#
|
14
|
+
# @api private
|
15
|
+
attr_reader :header
|
16
|
+
|
17
|
+
# The optimized aliases
|
18
|
+
#
|
19
|
+
# @return [Rename::Aliases]
|
20
|
+
#
|
21
|
+
# @api private
|
22
|
+
attr_reader :aliases
|
23
|
+
|
24
|
+
# Initialize an Rename optimizer
|
25
|
+
#
|
26
|
+
# @param [Relation] operation
|
27
|
+
#
|
28
|
+
# @return [undefined]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def initialize(operation)
|
32
|
+
super
|
33
|
+
@header = operation.header
|
34
|
+
@aliases = self.class.union_aliases(operation.aliases, operand)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# Wrap the operand's operand in a Rename
|
40
|
+
#
|
41
|
+
# @return [Rename]
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
def wrap_operand
|
45
|
+
operation.class.new(operand.operand, aliases)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Union the operation aliases with any operand aliases
|
49
|
+
#
|
50
|
+
# @param [Rename::Aliases]
|
51
|
+
# the original aliases
|
52
|
+
# @param [Relation]
|
53
|
+
# the operand
|
54
|
+
#
|
55
|
+
# @return [Rename::Aliases]
|
56
|
+
#
|
57
|
+
# @api private
|
58
|
+
def self.union_aliases(aliases, operand)
|
59
|
+
if operand.respond_to?(:aliases)
|
60
|
+
aliases.union(operand.aliases)
|
61
|
+
else
|
62
|
+
aliases
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Optimize when the headers are not changed
|
67
|
+
class UnchangedHeader < self
|
68
|
+
|
69
|
+
# Test if the renamed headers are the same as the operand's
|
70
|
+
#
|
71
|
+
# @return [Boolean]
|
72
|
+
#
|
73
|
+
# @api private
|
74
|
+
def optimizable?
|
75
|
+
header.to_a == operand.header.to_a
|
76
|
+
end
|
77
|
+
|
78
|
+
# A Rename with unchanged headers is a noop
|
79
|
+
#
|
80
|
+
# @return [Relation]
|
81
|
+
#
|
82
|
+
# @api private
|
83
|
+
def optimize
|
84
|
+
operand
|
85
|
+
end
|
86
|
+
|
87
|
+
end # class UnchangedHeader
|
88
|
+
|
89
|
+
# Optimize when the operand is a Rename with aliases that cancel out
|
90
|
+
class RenameOperandAndEmptyAliases < self
|
91
|
+
|
92
|
+
# Test if the operand is a Rename with aliases that cancel out
|
93
|
+
#
|
94
|
+
# @return [Boolean]
|
95
|
+
#
|
96
|
+
# @api private
|
97
|
+
def optimizable?
|
98
|
+
operand.kind_of?(operation.class) && aliases.empty?
|
99
|
+
end
|
100
|
+
|
101
|
+
# A Rename wrapping a Rename with aliases that cancel out is a noop
|
102
|
+
#
|
103
|
+
# @return [Relation]
|
104
|
+
#
|
105
|
+
# @api private
|
106
|
+
def optimize
|
107
|
+
operand.operand
|
108
|
+
end
|
109
|
+
|
110
|
+
end # class RenameOperandAndEmptyAliases
|
111
|
+
|
112
|
+
# Optimize when the operand is a Rename
|
113
|
+
class RenameOperand < self
|
114
|
+
|
115
|
+
# Test if the operand is a Rename
|
116
|
+
#
|
117
|
+
# @return [Boolean]
|
118
|
+
#
|
119
|
+
# @api private
|
120
|
+
def optimizable?
|
121
|
+
operand.kind_of?(operation.class)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Flatten nested Renames into a single Rename
|
125
|
+
#
|
126
|
+
# @return [Projection]
|
127
|
+
#
|
128
|
+
# @api private
|
129
|
+
def optimize
|
130
|
+
operation.class.new(operand.operand, aliases)
|
131
|
+
end
|
132
|
+
|
133
|
+
end # class RenameOperand
|
134
|
+
|
135
|
+
# Optimize when the operand is a Projection
|
136
|
+
class ProjectionOperand < self
|
137
|
+
|
138
|
+
# Test if the operand is a Projection
|
139
|
+
#
|
140
|
+
# @return [Boolean]
|
141
|
+
#
|
142
|
+
# @api private
|
143
|
+
def optimizable?
|
144
|
+
operand.kind_of?(Veritas::Algebra::Projection)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Wrap the Rename in a Projection
|
148
|
+
#
|
149
|
+
# @return [Projection]
|
150
|
+
#
|
151
|
+
# @api private
|
152
|
+
def optimize
|
153
|
+
operand.class.new(wrap_operand, header)
|
154
|
+
end
|
155
|
+
|
156
|
+
end # class ProjectionOperand
|
157
|
+
|
158
|
+
# Optimize when the operand is a Restriction
|
159
|
+
class RestrictionOperand < self
|
160
|
+
|
161
|
+
# Test if the operand is a Restriction
|
162
|
+
#
|
163
|
+
# @return [Boolean]
|
164
|
+
#
|
165
|
+
# @api private
|
166
|
+
def optimizable?
|
167
|
+
operand.kind_of?(Veritas::Algebra::Restriction)
|
168
|
+
end
|
169
|
+
|
170
|
+
# Wrap the Rename in a Restriction
|
171
|
+
#
|
172
|
+
# @return [Restriction]
|
173
|
+
#
|
174
|
+
# @api private
|
175
|
+
def optimize
|
176
|
+
operand.class.new(wrap_operand, rename_predicate)
|
177
|
+
end
|
178
|
+
|
179
|
+
private
|
180
|
+
|
181
|
+
# Rename the operand predicate
|
182
|
+
#
|
183
|
+
# @return [Expression]
|
184
|
+
#
|
185
|
+
# @api private
|
186
|
+
def rename_predicate
|
187
|
+
operand.predicate.rename(aliases)
|
188
|
+
end
|
189
|
+
|
190
|
+
end # class RestrictionOperand
|
191
|
+
|
192
|
+
# Optimize when the operand is a Set
|
193
|
+
class SetOperand < self
|
194
|
+
|
195
|
+
# Test if the operand is a Set
|
196
|
+
#
|
197
|
+
# @return [Boolean]
|
198
|
+
#
|
199
|
+
# @api private
|
200
|
+
def optimizable?
|
201
|
+
operand.kind_of?(Veritas::Relation::Operation::Set)
|
202
|
+
end
|
203
|
+
|
204
|
+
# Wrap each operand in the Set in a Rename
|
205
|
+
#
|
206
|
+
# @return [Set]
|
207
|
+
#
|
208
|
+
# @api private
|
209
|
+
def optimize
|
210
|
+
operand.class.new(wrap_left, wrap_right)
|
211
|
+
end
|
212
|
+
|
213
|
+
private
|
214
|
+
|
215
|
+
# Utility method to wrap the left operand in a Rename
|
216
|
+
#
|
217
|
+
# @return [Rename]
|
218
|
+
#
|
219
|
+
# @api private
|
220
|
+
def wrap_left
|
221
|
+
operation.class.new(operand.left, aliases)
|
222
|
+
end
|
223
|
+
|
224
|
+
# Utility method to wrap the right operand in a Rename
|
225
|
+
#
|
226
|
+
# @return [Rename]
|
227
|
+
#
|
228
|
+
# @api private
|
229
|
+
def wrap_right
|
230
|
+
operation.class.new(operand.right, aliases)
|
231
|
+
end
|
232
|
+
|
233
|
+
end # class SetOperand
|
234
|
+
|
235
|
+
# Optimize when the operand is a Reverse
|
236
|
+
class ReverseOperand < self
|
237
|
+
|
238
|
+
# Test if the operand is a Reverse
|
239
|
+
#
|
240
|
+
# @return [Boolean]
|
241
|
+
#
|
242
|
+
# @api private
|
243
|
+
def optimizable?
|
244
|
+
operand.kind_of?(Veritas::Relation::Operation::Reverse)
|
245
|
+
end
|
246
|
+
|
247
|
+
# Wrap the Rename in a Reverse
|
248
|
+
#
|
249
|
+
# @return [Reverse]
|
250
|
+
#
|
251
|
+
# @api private
|
252
|
+
def optimize
|
253
|
+
operand.class.new(wrap_operand)
|
254
|
+
end
|
255
|
+
|
256
|
+
end # class ReverseOperand
|
257
|
+
|
258
|
+
# Optimize when the operand is an Order
|
259
|
+
class OrderOperand < self
|
260
|
+
|
261
|
+
# Test if the operand is an Order
|
262
|
+
#
|
263
|
+
# @return [Boolean]
|
264
|
+
#
|
265
|
+
# @api private
|
266
|
+
def optimizable?
|
267
|
+
operand.kind_of?(Veritas::Relation::Operation::Order)
|
268
|
+
end
|
269
|
+
|
270
|
+
# Wrap the Rename in an Order
|
271
|
+
#
|
272
|
+
# @return [Order]
|
273
|
+
#
|
274
|
+
# @api private
|
275
|
+
def optimize
|
276
|
+
operand.class.new(wrap_operand, operation.directions)
|
277
|
+
end
|
278
|
+
|
279
|
+
end # class OrderOperand
|
280
|
+
|
281
|
+
# Optimize when the operand is a Limit
|
282
|
+
class LimitOperand < self
|
283
|
+
|
284
|
+
# Test if the operand is a Limit
|
285
|
+
#
|
286
|
+
# @return [Boolean]
|
287
|
+
#
|
288
|
+
# @api private
|
289
|
+
def optimizable?
|
290
|
+
operand.kind_of?(Veritas::Relation::Operation::Limit)
|
291
|
+
end
|
292
|
+
|
293
|
+
# Wrap the Rename in a Limit
|
294
|
+
#
|
295
|
+
# @return [Limit]
|
296
|
+
#
|
297
|
+
# @api private
|
298
|
+
def optimize
|
299
|
+
operand = self.operand
|
300
|
+
operand.class.new(wrap_operand, operand.limit)
|
301
|
+
end
|
302
|
+
|
303
|
+
end # class LimitOperand
|
304
|
+
|
305
|
+
# Optimize when the operand is an Offset
|
306
|
+
class OffsetOperand < self
|
307
|
+
|
308
|
+
# Test if the operand is an Offset
|
309
|
+
#
|
310
|
+
# @return [Boolean]
|
311
|
+
#
|
312
|
+
# @api private
|
313
|
+
def optimizable?
|
314
|
+
operand.kind_of?(Veritas::Relation::Operation::Offset)
|
315
|
+
end
|
316
|
+
|
317
|
+
# Wrap the Rename in an Offset
|
318
|
+
#
|
319
|
+
# @return [Offset]
|
320
|
+
#
|
321
|
+
# @api private
|
322
|
+
def optimize
|
323
|
+
operand = self.operand
|
324
|
+
operand.class.new(wrap_operand, operand.offset)
|
325
|
+
end
|
326
|
+
|
327
|
+
end # class OffsetOperand
|
328
|
+
|
329
|
+
# Optimize when the operand is Empty
|
330
|
+
class EmptyOperand < self
|
331
|
+
|
332
|
+
# Test if the operand is empty
|
333
|
+
#
|
334
|
+
# @return [Boolean]
|
335
|
+
#
|
336
|
+
# @api private
|
337
|
+
def optimizable?
|
338
|
+
operand.kind_of?(Veritas::Relation::Empty)
|
339
|
+
end
|
340
|
+
|
341
|
+
# Return a new Empty relation with the operation's headers
|
342
|
+
#
|
343
|
+
# @return [Empty]
|
344
|
+
#
|
345
|
+
# @api private
|
346
|
+
def optimize
|
347
|
+
Veritas::Relation::Empty.new(header)
|
348
|
+
end
|
349
|
+
|
350
|
+
end # class EmptyOperand
|
351
|
+
|
352
|
+
# Optimize when operand is optimizable
|
353
|
+
class UnoptimizedOperand < self
|
354
|
+
|
355
|
+
# Test if the operand is unoptimized
|
356
|
+
#
|
357
|
+
# @return [Boolean]
|
358
|
+
#
|
359
|
+
# @api private
|
360
|
+
def optimizable?
|
361
|
+
operation = self.operation
|
362
|
+
!operand.equal?(operation.operand) ||
|
363
|
+
!aliases.equal?(operation.aliases)
|
364
|
+
end
|
365
|
+
|
366
|
+
# Return a Rename with an optimized operand
|
367
|
+
#
|
368
|
+
# @return [Rename]
|
369
|
+
#
|
370
|
+
# @api private
|
371
|
+
def optimize
|
372
|
+
operation.class.new(operand, aliases)
|
373
|
+
end
|
374
|
+
|
375
|
+
end # class UnoptimizedOperand
|
376
|
+
|
377
|
+
Veritas::Algebra::Rename.optimizer = chain(
|
378
|
+
UnchangedHeader,
|
379
|
+
RenameOperandAndEmptyAliases,
|
380
|
+
RenameOperand,
|
381
|
+
ProjectionOperand,
|
382
|
+
RestrictionOperand,
|
383
|
+
SetOperand,
|
384
|
+
ReverseOperand,
|
385
|
+
OrderOperand,
|
386
|
+
LimitOperand,
|
387
|
+
OffsetOperand,
|
388
|
+
EmptyOperand,
|
389
|
+
MaterializedOperand,
|
390
|
+
UnoptimizedOperand
|
391
|
+
)
|
392
|
+
|
393
|
+
end # class Rename
|
394
|
+
end # module Algebra
|
395
|
+
end # class Optimizer
|
396
|
+
end # module Veritas
|