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.
Files changed (349) hide show
  1. data/.gemtest +0 -0
  2. data/.rvmrc +1 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +20 -10
  5. data/Guardfile +22 -0
  6. data/README.rdoc +2 -0
  7. data/Rakefile +4 -2
  8. data/TODO +43 -2
  9. data/config/flay.yml +2 -2
  10. data/config/flog.yml +1 -1
  11. data/config/roodi.yml +4 -4
  12. data/lib/veritas/optimizer/aggregate/count.rb +17 -0
  13. data/lib/veritas/optimizer/aggregate/maximum.rb +17 -0
  14. data/lib/veritas/optimizer/aggregate/mean.rb +17 -0
  15. data/lib/veritas/optimizer/aggregate/minimum.rb +17 -0
  16. data/lib/veritas/optimizer/aggregate/standard_deviation.rb +17 -0
  17. data/lib/veritas/optimizer/aggregate/sum.rb +17 -0
  18. data/lib/veritas/optimizer/aggregate/variance.rb +17 -0
  19. data/lib/veritas/optimizer/aggregate.rb +16 -0
  20. data/lib/veritas/optimizer/algebra/difference.rb +3 -1
  21. data/lib/veritas/optimizer/algebra/extension.rb +58 -3
  22. data/lib/veritas/optimizer/algebra/intersection.rb +3 -1
  23. data/lib/veritas/optimizer/algebra/join.rb +6 -4
  24. data/lib/veritas/optimizer/algebra/product.rb +3 -1
  25. data/lib/veritas/optimizer/algebra/projection.rb +23 -54
  26. data/lib/veritas/optimizer/algebra/rename.rb +55 -80
  27. data/lib/veritas/optimizer/algebra/restriction.rb +33 -66
  28. data/lib/veritas/optimizer/algebra/summarization.rb +161 -3
  29. data/lib/veritas/optimizer/algebra/union.rb +3 -1
  30. data/lib/veritas/optimizer/function/binary.rb +124 -0
  31. data/lib/veritas/optimizer/{logic → function}/connective/binary.rb +48 -102
  32. data/lib/veritas/optimizer/{logic → function}/connective/conjunction.rb +12 -11
  33. data/lib/veritas/optimizer/{logic → function}/connective/disjunction.rb +15 -14
  34. data/lib/veritas/optimizer/function/connective/negation.rb +65 -0
  35. data/lib/veritas/optimizer/function/numeric/absolute.rb +20 -0
  36. data/lib/veritas/optimizer/function/numeric/addition.rb +20 -0
  37. data/lib/veritas/optimizer/function/numeric/division.rb +20 -0
  38. data/lib/veritas/optimizer/function/numeric/exponentiation.rb +20 -0
  39. data/lib/veritas/optimizer/function/numeric/modulo.rb +20 -0
  40. data/lib/veritas/optimizer/function/numeric/multiplication.rb +20 -0
  41. data/lib/veritas/optimizer/function/numeric/square_root.rb +20 -0
  42. data/lib/veritas/optimizer/function/numeric/subtraction.rb +20 -0
  43. data/lib/veritas/optimizer/function/numeric/unary_minus.rb +20 -0
  44. data/lib/veritas/optimizer/function/numeric/unary_plus.rb +20 -0
  45. data/lib/veritas/optimizer/function/numeric.rb +34 -0
  46. data/lib/veritas/optimizer/{logic → function}/predicate/comparable.rb +6 -4
  47. data/lib/veritas/optimizer/{logic → function}/predicate/enumerable.rb +24 -26
  48. data/lib/veritas/optimizer/{logic → function}/predicate/equality.rb +6 -6
  49. data/lib/veritas/optimizer/{logic → function}/predicate/exclusion.rb +6 -16
  50. data/lib/veritas/optimizer/{logic → function}/predicate/greater_than.rb +6 -5
  51. data/lib/veritas/optimizer/{logic → function}/predicate/greater_than_or_equal_to.rb +6 -6
  52. data/lib/veritas/optimizer/{logic → function}/predicate/inclusion.rb +6 -16
  53. data/lib/veritas/optimizer/{logic → function}/predicate/inequality.rb +6 -6
  54. data/lib/veritas/optimizer/{logic → function}/predicate/less_than.rb +6 -5
  55. data/lib/veritas/optimizer/{logic → function}/predicate/less_than_or_equal_to.rb +6 -6
  56. data/lib/veritas/optimizer/{logic → function}/predicate/match.rb +5 -4
  57. data/lib/veritas/optimizer/{logic → function}/predicate/no_match.rb +5 -4
  58. data/lib/veritas/optimizer/function/predicate.rb +61 -0
  59. data/lib/veritas/optimizer/function/string/length.rb +31 -0
  60. data/lib/veritas/optimizer/function/unary.rb +86 -0
  61. data/lib/veritas/optimizer/function.rb +87 -0
  62. data/lib/veritas/optimizer/optimizable.rb +6 -3
  63. data/lib/veritas/optimizer/relation/operation/binary.rb +36 -70
  64. data/lib/veritas/optimizer/relation/operation/limit.rb +1 -9
  65. data/lib/veritas/optimizer/relation/operation/offset.rb +1 -9
  66. data/lib/veritas/optimizer/relation/operation/order.rb +1 -9
  67. data/lib/veritas/optimizer/relation/operation/reverse.rb +1 -9
  68. data/lib/veritas/optimizer/relation/operation/unary.rb +50 -13
  69. data/lib/veritas/optimizer/version.rb +1 -1
  70. data/lib/veritas/optimizer.rb +43 -16
  71. data/spec/integration/veritas/algebra/difference/optimize_spec.rb +6 -4
  72. data/spec/integration/veritas/algebra/intersection/optimize_spec.rb +6 -4
  73. data/spec/integration/veritas/algebra/join/optimize_spec.rb +4 -2
  74. data/spec/integration/veritas/algebra/product/optimize_spec.rb +2 -0
  75. data/spec/integration/veritas/algebra/projection/optimize_spec.rb +6 -4
  76. data/spec/integration/veritas/algebra/rename/optimize_spec.rb +2 -0
  77. data/spec/integration/veritas/algebra/restriction/optimize_spec.rb +9 -7
  78. data/spec/integration/veritas/algebra/summarization/optimize_spec.rb +49 -0
  79. data/spec/integration/veritas/algebra/union/optimize_spec.rb +6 -4
  80. data/spec/integration/veritas/{logic → function}/connective/conjunction/optimize_spec.rb +33 -31
  81. data/spec/integration/veritas/{logic → function}/connective/disjunction/optimize_spec.rb +30 -28
  82. data/spec/integration/veritas/{logic → function}/connective/negation/optimize_spec.rb +7 -5
  83. data/spec/integration/veritas/{logic/expression → function}/optimize_spec.rb +5 -3
  84. data/spec/integration/veritas/{logic → function}/predicate/equality/optimize_spec.rb +9 -7
  85. data/spec/integration/veritas/{logic → function}/predicate/exclusion/optimize_spec.rb +13 -11
  86. data/spec/integration/veritas/{logic → function}/predicate/greater_than/optimize_spec.rb +17 -15
  87. data/spec/integration/veritas/{logic → function}/predicate/greater_than_or_equal_to/optimize_spec.rb +17 -15
  88. data/spec/integration/veritas/{logic → function}/predicate/inclusion/optimize_spec.rb +13 -11
  89. data/spec/integration/veritas/{logic → function}/predicate/inequality/optimize_spec.rb +9 -7
  90. data/spec/integration/veritas/{logic → function}/predicate/less_than/optimize_spec.rb +17 -15
  91. data/spec/integration/veritas/{logic → function}/predicate/less_than_or_equal_to/optimize_spec.rb +17 -15
  92. data/spec/integration/veritas/relation/empty/optimize_spec.rb +2 -0
  93. data/spec/integration/veritas/relation/materialized/optimize_spec.rb +2 -0
  94. data/spec/integration/veritas/relation/operation/limit/optimize_spec.rb +3 -1
  95. data/spec/integration/veritas/relation/operation/offset/optimize_spec.rb +3 -1
  96. data/spec/integration/veritas/relation/operation/order/optimize_spec.rb +4 -2
  97. data/spec/integration/veritas/relation/operation/reverse/optimize_spec.rb +4 -2
  98. data/spec/integration/veritas/relation/optimize_spec.rb +2 -0
  99. data/spec/shared/{logic_connective_binary_optimize_behavior.rb → function_connective_binary_optimize_behavior.rb} +14 -12
  100. data/spec/shared/idempotent_method_behavior.rb +2 -0
  101. data/spec/shared/optimize_method_behavior.rb +2 -0
  102. data/spec/support/add_method_missing.rb +2 -0
  103. data/spec/unit/veritas/optimizer/algebra/difference/empty_left/optimize_spec.rb +2 -0
  104. data/spec/unit/veritas/optimizer/algebra/difference/empty_right/optimize_spec.rb +2 -0
  105. data/spec/unit/veritas/optimizer/algebra/difference/equal_operands/optimize_spec.rb +2 -0
  106. data/spec/unit/veritas/optimizer/algebra/extension/extensions_spec.rb +31 -0
  107. data/spec/unit/veritas/optimizer/algebra/extension/order_operand/optimizable_spec.rb +23 -0
  108. data/spec/unit/veritas/optimizer/algebra/extension/order_operand/optimize_spec.rb +22 -0
  109. data/spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimizable_spec.rb +18 -8
  110. data/spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimize_spec.rb +4 -2
  111. data/spec/unit/veritas/optimizer/algebra/intersection/empty_left/optimize_spec.rb +2 -0
  112. data/spec/unit/veritas/optimizer/algebra/intersection/empty_right/optimize_spec.rb +2 -0
  113. data/spec/unit/veritas/optimizer/algebra/intersection/equal_operands/optimize_spec.rb +2 -0
  114. data/spec/unit/veritas/optimizer/algebra/join/equal_headers/optimizable_spec.rb +2 -0
  115. data/spec/unit/veritas/optimizer/algebra/join/equal_headers/optimize_spec.rb +2 -0
  116. data/spec/unit/veritas/optimizer/algebra/product/table_dee_left/optimizable_spec.rb +2 -0
  117. data/spec/unit/veritas/optimizer/algebra/product/table_dee_left/optimize_spec.rb +2 -0
  118. data/spec/unit/veritas/optimizer/algebra/product/table_dee_right/optimizable_spec.rb +2 -0
  119. data/spec/unit/veritas/optimizer/algebra/product/table_dee_right/optimize_spec.rb +2 -0
  120. data/spec/unit/veritas/optimizer/algebra/projection/empty_operand/optimizable_spec.rb +2 -0
  121. data/spec/unit/veritas/optimizer/algebra/projection/empty_operand/optimize_spec.rb +2 -0
  122. data/spec/unit/veritas/optimizer/algebra/projection/projection_operand/optimizable_spec.rb +2 -0
  123. data/spec/unit/veritas/optimizer/algebra/projection/projection_operand/optimize_spec.rb +2 -0
  124. data/spec/unit/veritas/optimizer/algebra/projection/{set_operand → union_operand}/optimizable_spec.rb +3 -1
  125. data/spec/unit/veritas/optimizer/algebra/projection/{set_operand → union_operand}/optimize_spec.rb +4 -2
  126. data/spec/unit/veritas/optimizer/algebra/projection/unoptimized_operand/optimizable_spec.rb +3 -1
  127. data/spec/unit/veritas/optimizer/algebra/projection/unoptimized_operand/optimize_spec.rb +6 -4
  128. data/spec/unit/veritas/optimizer/algebra/rename/aliases_spec.rb +5 -13
  129. data/spec/unit/veritas/optimizer/algebra/rename/empty_operand/optimizable_spec.rb +2 -0
  130. data/spec/unit/veritas/optimizer/algebra/rename/empty_operand/optimize_spec.rb +2 -0
  131. data/spec/unit/veritas/optimizer/algebra/rename/limit_operand/optimizable_spec.rb +2 -0
  132. data/spec/unit/veritas/optimizer/algebra/rename/limit_operand/optimize_spec.rb +2 -0
  133. data/spec/unit/veritas/optimizer/algebra/rename/offset_operand/optimizable_spec.rb +2 -0
  134. data/spec/unit/veritas/optimizer/algebra/rename/offset_operand/optimize_spec.rb +2 -0
  135. data/spec/unit/veritas/optimizer/algebra/rename/order_operand/optimizable_spec.rb +2 -0
  136. data/spec/unit/veritas/optimizer/algebra/rename/order_operand/optimize_spec.rb +2 -0
  137. data/spec/unit/veritas/optimizer/algebra/rename/projection_operand/optimizable_spec.rb +17 -7
  138. data/spec/unit/veritas/optimizer/algebra/rename/projection_operand/optimize_spec.rb +2 -0
  139. data/spec/unit/veritas/optimizer/algebra/rename/rename_operand/optimizable_spec.rb +2 -0
  140. data/spec/unit/veritas/optimizer/algebra/rename/rename_operand/optimize_spec.rb +2 -0
  141. data/spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimizable_spec.rb +2 -0
  142. data/spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimize_spec.rb +2 -0
  143. data/spec/unit/veritas/optimizer/algebra/rename/restriction_operand/optimizable_spec.rb +3 -1
  144. data/spec/unit/veritas/optimizer/algebra/rename/restriction_operand/optimize_spec.rb +7 -5
  145. data/spec/unit/veritas/optimizer/algebra/rename/reverse_operand/optimizable_spec.rb +2 -0
  146. data/spec/unit/veritas/optimizer/algebra/rename/reverse_operand/optimize_spec.rb +2 -0
  147. data/spec/unit/veritas/optimizer/algebra/rename/set_operand/optimizable_spec.rb +2 -0
  148. data/spec/unit/veritas/optimizer/algebra/rename/set_operand/optimize_spec.rb +2 -0
  149. data/spec/unit/veritas/optimizer/algebra/rename/unoptimized_operand/optimizable_spec.rb +7 -20
  150. data/spec/unit/veritas/optimizer/algebra/rename/unoptimized_operand/optimize_spec.rb +2 -0
  151. data/spec/unit/veritas/optimizer/algebra/restriction/contradiction/optimizable_spec.rb +23 -3
  152. data/spec/unit/veritas/optimizer/algebra/restriction/contradiction/optimize_spec.rb +7 -5
  153. data/spec/unit/veritas/optimizer/algebra/restriction/order_operand/optimizable_spec.rb +3 -1
  154. data/spec/unit/veritas/optimizer/algebra/restriction/order_operand/optimize_spec.rb +7 -3
  155. data/spec/unit/veritas/optimizer/algebra/restriction/predicate_spec.rb +3 -1
  156. data/spec/unit/veritas/optimizer/algebra/restriction/restriction_operand/optimizable_spec.rb +5 -3
  157. data/spec/unit/veritas/optimizer/algebra/restriction/restriction_operand/optimize_spec.rb +8 -6
  158. data/spec/unit/veritas/optimizer/algebra/restriction/set_operand/optimizable_spec.rb +3 -1
  159. data/spec/unit/veritas/optimizer/algebra/restriction/set_operand/optimize_spec.rb +5 -3
  160. data/spec/unit/veritas/optimizer/algebra/restriction/tautology/optimizable_spec.rb +11 -3
  161. data/spec/unit/veritas/optimizer/algebra/restriction/tautology/optimize_spec.rb +4 -2
  162. data/spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimizable_spec.rb +7 -5
  163. data/spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimize_spec.rb +2 -0
  164. data/spec/unit/veritas/optimizer/algebra/summarization/empty_operand/class_methods/extension_default_spec.rb +22 -0
  165. data/spec/unit/veritas/optimizer/algebra/summarization/empty_operand/optimizable_spec.rb +29 -0
  166. data/spec/unit/veritas/optimizer/algebra/summarization/empty_operand/optimize_spec.rb +47 -0
  167. data/spec/unit/veritas/optimizer/algebra/summarization/empty_summarize_per/optimizable_spec.rb +29 -0
  168. data/spec/unit/veritas/optimizer/algebra/summarization/empty_summarize_per/optimize_spec.rb +23 -0
  169. data/spec/unit/veritas/optimizer/algebra/summarization/order_operand/optimizable_spec.rb +23 -0
  170. data/spec/unit/veritas/optimizer/algebra/summarization/order_operand/optimize_spec.rb +22 -0
  171. data/spec/unit/veritas/optimizer/algebra/summarization/summarize_per_spec.rb +29 -0
  172. data/spec/unit/veritas/optimizer/algebra/summarization/summarizers_spec.rb +31 -0
  173. data/spec/unit/veritas/optimizer/algebra/summarization/unoptimized_operand/optimizable_spec.rb +30 -8
  174. data/spec/unit/veritas/optimizer/algebra/summarization/unoptimized_operand/optimize_spec.rb +12 -9
  175. data/spec/unit/veritas/optimizer/algebra/union/empty_left/optimize_spec.rb +2 -0
  176. data/spec/unit/veritas/optimizer/algebra/union/empty_right/optimize_spec.rb +2 -0
  177. data/spec/unit/veritas/optimizer/algebra/union/equal_operands/optimize_spec.rb +2 -0
  178. data/spec/unit/veritas/optimizer/class_methods/chain_spec.rb +2 -0
  179. data/spec/unit/veritas/optimizer/function/binary/constant_operands/optimizable_spec.rb +36 -0
  180. data/spec/unit/veritas/optimizer/function/binary/constant_operands/optimize_spec.rb +18 -0
  181. data/spec/unit/veritas/optimizer/function/binary/left_spec.rb +28 -0
  182. data/spec/unit/veritas/optimizer/function/binary/right_spec.rb +28 -0
  183. data/spec/unit/veritas/optimizer/function/binary/unoptimized_operands/optimizable_spec.rb +37 -0
  184. data/spec/unit/veritas/optimizer/function/binary/unoptimized_operands/optimize_spec.rb +23 -0
  185. data/spec/unit/veritas/optimizer/function/class_methods/optimize_functions_spec.rb +26 -0
  186. data/spec/unit/veritas/optimizer/function/class_methods/optimize_operand_spec.rb +22 -0
  187. data/spec/unit/veritas/optimizer/function/connective/binary/constant_operands/optimize_spec.rb +16 -0
  188. data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/equal_operands/optimizable_spec.rb +4 -2
  189. data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/equal_operands/optimize_spec.rb +3 -1
  190. data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/left_spec.rb +3 -1
  191. data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_left_operand/optimizable_spec.rb +4 -2
  192. data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_left_operand/optimize_spec.rb +4 -2
  193. data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_right_operand/optimizable_spec.rb +4 -2
  194. data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_right_operand/optimize_spec.rb +4 -2
  195. data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/right_spec.rb +3 -1
  196. data/spec/unit/veritas/optimizer/function/connective/conjunction/contradiction/optimizable_spec.rb +64 -0
  197. data/spec/unit/veritas/optimizer/function/connective/conjunction/contradiction/optimize_spec.rb +19 -0
  198. data/spec/unit/veritas/optimizer/{logic/connective/disjunction/contradiction_left_operand → function/connective/conjunction/left_operand_tautology}/optimizable_spec.rb +9 -7
  199. data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/left_operand_tautology/optimize_spec.rb +8 -6
  200. data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/optimizable_to_exclusion/optimizable_spec.rb +4 -2
  201. data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/optimizable_to_exclusion/optimize_spec.rb +5 -3
  202. data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/right_operand_tautology/optimizable_spec.rb +6 -4
  203. data/spec/unit/veritas/optimizer/function/connective/conjunction/right_operand_tautology/optimize_spec.rb +19 -0
  204. data/spec/unit/veritas/optimizer/{logic/connective/conjunction/left_operand_tautology → function/connective/disjunction/contradiction_left_operand}/optimizable_spec.rb +9 -7
  205. data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/contradiction_left_operand/optimize_spec.rb +8 -6
  206. data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/contradiction_right_operand/optimizable_spec.rb +6 -4
  207. data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/contradiction_right_operand/optimize_spec.rb +8 -6
  208. data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/optimizable_to_inclusion/optimizable_spec.rb +4 -2
  209. data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/optimizable_to_inclusion/optimize_spec.rb +5 -3
  210. data/spec/unit/veritas/optimizer/function/connective/disjunction/tautology/optimizable_spec.rb +64 -0
  211. data/spec/unit/veritas/optimizer/function/connective/disjunction/tautology/optimize_spec.rb +19 -0
  212. data/spec/unit/veritas/optimizer/function/connective/negation/constant_operand/optimize_spec.rb +16 -0
  213. data/spec/unit/veritas/optimizer/function/connective/negation/invertible_operand/optimizable_spec.rb +28 -0
  214. data/spec/unit/veritas/optimizer/function/connective/negation/invertible_operand/optimize_spec.rb +22 -0
  215. data/spec/unit/veritas/optimizer/{logic → function}/connective/negation/operand_spec.rb +3 -1
  216. data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/never_comparable/optimizable_spec.rb +23 -7
  217. data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/never_equivalent/optimizable_spec.rb +23 -7
  218. data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/normalizable_operands/optimizable_spec.rb +7 -5
  219. data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/normalizable_operands/optimize_spec.rb +7 -5
  220. data/spec/unit/veritas/optimizer/function/predicate/constant_operands/optimize_spec.rb +16 -0
  221. data/spec/unit/veritas/optimizer/function/predicate/contradiction/optimize_spec.rb +18 -0
  222. data/spec/unit/veritas/optimizer/function/predicate/enumerable/class_methods/sort_by_value_spec.rb +27 -0
  223. data/spec/unit/veritas/optimizer/{logic → function}/predicate/enumerable/empty_right_operand/optimizable_spec.rb +6 -4
  224. data/spec/unit/veritas/optimizer/{logic → function}/predicate/enumerable/one_right_operand/optimizable_spec.rb +9 -7
  225. data/spec/unit/veritas/optimizer/{logic/predicate/enumerable/unoptimized_operand → function/predicate/enumerable/unoptimized_operands}/optimizable_spec.rb +4 -2
  226. data/spec/unit/veritas/optimizer/{logic/predicate/enumerable/unoptimized_operand → function/predicate/enumerable/unoptimized_operands}/optimize_spec.rb +18 -5
  227. data/spec/unit/veritas/optimizer/{logic → function}/predicate/equality/tautology/optimizable_spec.rb +4 -2
  228. data/spec/unit/veritas/optimizer/{logic → function}/predicate/exclusion/empty_right_operand/optimize_spec.rb +8 -6
  229. data/spec/unit/veritas/optimizer/{logic → function}/predicate/exclusion/one_right_operand/optimize_spec.rb +8 -6
  230. data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than/contradiction/optimizable_spec.rb +4 -2
  231. data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than/tautology/optimizable_spec.rb +4 -2
  232. data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than_or_equal_to/contradiction/optimizable_spec.rb +4 -2
  233. data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than_or_equal_to/tautology/optimizable_spec.rb +4 -2
  234. data/spec/unit/veritas/optimizer/{logic → function}/predicate/inclusion/empty_right_operand/optimize_spec.rb +8 -6
  235. data/spec/unit/veritas/optimizer/{logic → function}/predicate/inclusion/one_right_operand/optimize_spec.rb +8 -6
  236. data/spec/unit/veritas/optimizer/{logic → function}/predicate/inequality/contradiction/optimizable_spec.rb +4 -2
  237. data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than/contradiction/optimizable_spec.rb +4 -2
  238. data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than/tautology/optimizable_spec.rb +4 -2
  239. data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than_or_equal_to/contradiction/optimizable_spec.rb +4 -2
  240. data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than_or_equal_to/tautology/optimizable_spec.rb +4 -2
  241. data/spec/unit/veritas/optimizer/function/predicate/tautology/optimize_spec.rb +18 -0
  242. data/spec/unit/veritas/optimizer/function/unary/constant_operand/optimizable_spec.rb +27 -0
  243. data/spec/unit/veritas/optimizer/function/unary/constant_operand/optimize_spec.rb +18 -0
  244. data/spec/unit/veritas/optimizer/function/unary/operand_spec.rb +27 -0
  245. data/spec/unit/veritas/optimizer/function/unary/unoptimized_operand/optimizable_spec.rb +27 -0
  246. data/spec/unit/veritas/optimizer/function/unary/unoptimized_operand/optimize_spec.rb +18 -0
  247. data/spec/unit/veritas/optimizer/{logic/predicate → function}/util/class_methods/attribute_spec.rb +4 -2
  248. data/spec/unit/veritas/optimizer/{logic/predicate → function}/util/class_methods/constant_spec.rb +13 -5
  249. data/spec/unit/veritas/optimizer/function/util/class_methods/max_spec.rb +27 -0
  250. data/spec/unit/veritas/optimizer/function/util/class_methods/min_spec.rb +27 -0
  251. data/spec/unit/veritas/optimizer/operation_spec.rb +2 -0
  252. data/spec/unit/veritas/optimizer/optimizable/class_methods/optimizer_spec.rb +2 -0
  253. data/spec/unit/veritas/optimizer/optimizable/optimize_spec.rb +3 -1
  254. data/spec/unit/veritas/optimizer/optimizable_spec.rb +2 -0
  255. data/spec/unit/veritas/optimizer/optimize_spec.rb +2 -0
  256. data/spec/unit/veritas/optimizer/relation/materialized/empty_operand/optimizable_spec.rb +2 -0
  257. data/spec/unit/veritas/optimizer/relation/materialized/empty_operand/optimize_spec.rb +2 -0
  258. data/spec/unit/veritas/optimizer/relation/operation/binary/empty_left/optimizable_spec.rb +2 -4
  259. data/spec/unit/veritas/optimizer/relation/operation/binary/empty_right/optimizable_spec.rb +2 -4
  260. data/spec/unit/veritas/optimizer/relation/operation/binary/equal_operands/optimizable_spec.rb +2 -5
  261. data/spec/unit/veritas/optimizer/relation/operation/binary/left_order_operand/optimizable_spec.rb +23 -0
  262. data/spec/unit/veritas/optimizer/relation/operation/binary/left_order_operand/optimize_spec.rb +23 -0
  263. data/spec/unit/veritas/optimizer/relation/operation/binary/left_spec.rb +2 -4
  264. data/spec/unit/veritas/optimizer/relation/operation/binary/materialized_operand/optimizable_spec.rb +2 -0
  265. data/spec/unit/veritas/optimizer/relation/operation/binary/materialized_operand/optimize_spec.rb +2 -0
  266. data/spec/unit/veritas/optimizer/relation/operation/binary/right_order_operand/optimizable_spec.rb +23 -0
  267. data/spec/unit/veritas/optimizer/relation/operation/binary/right_order_operand/optimize_spec.rb +23 -0
  268. data/spec/unit/veritas/optimizer/relation/operation/binary/right_spec.rb +2 -4
  269. data/spec/unit/veritas/optimizer/relation/operation/binary/{unoptimized_operand → unoptimized_operands}/optimizable_spec.rb +3 -1
  270. data/spec/unit/veritas/optimizer/relation/operation/binary/{unoptimized_operand → unoptimized_operands}/optimize_spec.rb +3 -1
  271. data/spec/unit/veritas/optimizer/relation/operation/combination/optimize_spec.rb +2 -0
  272. data/spec/unit/veritas/optimizer/relation/operation/limit/equal_limit_operand/optimizable_spec.rb +2 -0
  273. data/spec/unit/veritas/optimizer/relation/operation/limit/equal_limit_operand/optimize_spec.rb +2 -0
  274. data/spec/unit/veritas/optimizer/relation/operation/limit/limit_operand/optimizable_spec.rb +2 -0
  275. data/spec/unit/veritas/optimizer/relation/operation/limit/limit_operand/optimize_spec.rb +2 -0
  276. data/spec/unit/veritas/optimizer/relation/operation/limit/unoptimized_operand/optimizable_spec.rb +2 -0
  277. data/spec/unit/veritas/optimizer/relation/operation/limit/unoptimized_operand/optimize_spec.rb +2 -0
  278. data/spec/unit/veritas/optimizer/relation/operation/limit/zero_limit/optimizable_spec.rb +2 -0
  279. data/spec/unit/veritas/optimizer/relation/operation/limit/zero_limit/optimize_spec.rb +2 -0
  280. data/spec/unit/veritas/optimizer/relation/operation/offset/offset_operand/optimizable_spec.rb +2 -0
  281. data/spec/unit/veritas/optimizer/relation/operation/offset/offset_operand/optimize_spec.rb +2 -0
  282. data/spec/unit/veritas/optimizer/relation/operation/offset/unoptimized_operand/optimizable_spec.rb +2 -0
  283. data/spec/unit/veritas/optimizer/relation/operation/offset/unoptimized_operand/optimize_spec.rb +2 -0
  284. data/spec/unit/veritas/optimizer/relation/operation/offset/zero_offset/optimizable_spec.rb +2 -0
  285. data/spec/unit/veritas/optimizer/relation/operation/offset/zero_offset/optimize_spec.rb +2 -0
  286. data/spec/unit/veritas/optimizer/relation/operation/order/one_limit_operand/optimizable_spec.rb +2 -0
  287. data/spec/unit/veritas/optimizer/relation/operation/order/one_limit_operand/optimize_spec.rb +2 -0
  288. data/spec/unit/veritas/optimizer/relation/operation/order/order_operand/optimizable_spec.rb +2 -0
  289. data/spec/unit/veritas/optimizer/relation/operation/order/order_operand/optimize_spec.rb +3 -1
  290. data/spec/unit/veritas/optimizer/relation/operation/order/unoptimized_operand/optimizable_spec.rb +2 -0
  291. data/spec/unit/veritas/optimizer/relation/operation/order/unoptimized_operand/optimize_spec.rb +2 -0
  292. data/spec/unit/veritas/optimizer/relation/operation/reverse/order_operand/optimizable_spec.rb +2 -0
  293. data/spec/unit/veritas/optimizer/relation/operation/reverse/order_operand/optimize_spec.rb +2 -0
  294. data/spec/unit/veritas/optimizer/relation/operation/reverse/reverse_operand/optimizable_spec.rb +2 -0
  295. data/spec/unit/veritas/optimizer/relation/operation/reverse/reverse_operand/optimize_spec.rb +2 -0
  296. data/spec/unit/veritas/optimizer/relation/operation/reverse/unoptimized_operand/optimizable_spec.rb +2 -0
  297. data/spec/unit/veritas/optimizer/relation/operation/reverse/unoptimized_operand/optimize_spec.rb +2 -0
  298. data/spec/unit/veritas/optimizer/relation/operation/unary/empty_operand/optimizable_spec.rb +5 -2
  299. data/spec/unit/veritas/optimizer/relation/operation/unary/empty_operand/optimize_spec.rb +2 -0
  300. data/spec/unit/veritas/optimizer/relation/operation/unary/header_spec.rb +15 -0
  301. data/spec/unit/veritas/optimizer/relation/operation/unary/materialized_operand/optimizable_spec.rb +5 -2
  302. data/spec/unit/veritas/optimizer/relation/operation/unary/materialized_operand/optimize_spec.rb +2 -0
  303. data/spec/unit/veritas/optimizer/relation/operation/unary/operand_spec.rb +8 -5
  304. data/spec/unit/veritas/optimizer/relation/operation/unary/order_operand/optimizable_spec.rb +28 -0
  305. data/spec/unit/veritas/optimizer/relation/operation/unary/order_operand/optimize_spec.rb +27 -0
  306. data/spec/unit/veritas/optimizer/relation/operation/unary/unchanged_header/optimizable_spec.rb +24 -0
  307. data/spec/unit/veritas/optimizer/relation/operation/unary/unchanged_header/optimize_spec.rb +14 -0
  308. data/tasks/metrics/ci.rake +7 -0
  309. data/tasks/{quality → metrics}/flay.rake +0 -0
  310. data/tasks/{quality → metrics}/flog.rake +0 -0
  311. data/tasks/{quality → metrics}/heckle.rake +1 -0
  312. data/tasks/{quality → metrics}/metric_fu.rake +3 -0
  313. data/tasks/{quality → metrics}/reek.rake +0 -0
  314. data/tasks/{quality → metrics}/roodi.rake +0 -0
  315. data/tasks/{quality → metrics}/yardstick.rake +0 -0
  316. data/tasks/spec.rake +1 -0
  317. data/veritas-optimizer.gemspec +183 -352
  318. metadata +232 -357
  319. data/lib/veritas/optimizer/logic/connective/negation.rb +0 -71
  320. data/lib/veritas/optimizer/logic/predicate.rb +0 -177
  321. data/spec/unit/veritas/optimizer/algebra/projection/header_spec.rb +0 -16
  322. data/spec/unit/veritas/optimizer/algebra/projection/unchanged_header/optimizable_spec.rb +0 -26
  323. data/spec/unit/veritas/optimizer/algebra/projection/unchanged_header/optimize_spec.rb +0 -16
  324. data/spec/unit/veritas/optimizer/algebra/rename/class_methods/union_aliases_spec.rb +0 -27
  325. data/spec/unit/veritas/optimizer/algebra/rename/header_spec.rb +0 -19
  326. data/spec/unit/veritas/optimizer/algebra/rename/unchanged_header/optimizable_spec.rb +0 -26
  327. data/spec/unit/veritas/optimizer/algebra/rename/unchanged_header/optimize_spec.rb +0 -16
  328. data/spec/unit/veritas/optimizer/algebra/restriction/class_methods/optimize_predicate_spec.rb +0 -31
  329. data/spec/unit/veritas/optimizer/algebra/restriction/reverse_operand/optimizable_spec.rb +0 -26
  330. data/spec/unit/veritas/optimizer/algebra/restriction/reverse_operand/optimize_spec.rb +0 -18
  331. data/spec/unit/veritas/optimizer/logic/connective/binary/unoptimized_operand/optimizable_spec.rb +0 -34
  332. data/spec/unit/veritas/optimizer/logic/connective/binary/unoptimized_operand/optimize_spec.rb +0 -21
  333. data/spec/unit/veritas/optimizer/logic/connective/conjunction/contradiction/optimizable_spec.rb +0 -41
  334. data/spec/unit/veritas/optimizer/logic/connective/conjunction/contradiction/optimize_spec.rb +0 -17
  335. data/spec/unit/veritas/optimizer/logic/connective/conjunction/right_operand_tautology/optimize_spec.rb +0 -17
  336. data/spec/unit/veritas/optimizer/logic/connective/disjunction/tautology/optimizable_spec.rb +0 -41
  337. data/spec/unit/veritas/optimizer/logic/connective/disjunction/tautology/optimize_spec.rb +0 -17
  338. data/spec/unit/veritas/optimizer/logic/connective/negation/invertible_operand/optimizable_spec.rb +0 -26
  339. data/spec/unit/veritas/optimizer/logic/connective/negation/invertible_operand/optimize_spec.rb +0 -20
  340. data/spec/unit/veritas/optimizer/logic/predicate/class_methods/optimize_operand_spec.rb +0 -20
  341. data/spec/unit/veritas/optimizer/logic/predicate/constant_operands/optimizable_spec.rb +0 -29
  342. data/spec/unit/veritas/optimizer/logic/predicate/constant_operands/optimize_spec.rb +0 -14
  343. data/spec/unit/veritas/optimizer/logic/predicate/contradiction/optimize_spec.rb +0 -16
  344. data/spec/unit/veritas/optimizer/logic/predicate/left_spec.rb +0 -25
  345. data/spec/unit/veritas/optimizer/logic/predicate/right_spec.rb +0 -25
  346. data/spec/unit/veritas/optimizer/logic/predicate/tautology/optimize_spec.rb +0 -16
  347. data/spec/unit/veritas/optimizer/logic/predicate/util/class_methods/max_spec.rb +0 -19
  348. data/spec/unit/veritas/optimizer/logic/predicate/util/class_methods/min_spec.rb +0 -19
  349. data/tasks/quality/ci.rake +0 -2
@@ -1,6 +1,8 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
- describe Logic::Predicate::Inequality, '#optimize' do
5
+ describe Function::Predicate::Inequality, '#optimize' do
4
6
  subject { object.optimize }
5
7
 
6
8
  let(:attribute) { Attribute::Integer.new(:id) }
@@ -10,7 +12,7 @@ describe Logic::Predicate::Inequality, '#optimize' do
10
12
 
11
13
  context 'left and right are attributes' do
12
14
  context 'and equivalent' do
13
- it { should equal(Logic::Proposition::Contradiction.instance) }
15
+ it { should equal(Function::Proposition::Contradiction.instance) }
14
16
 
15
17
  it_should_behave_like 'an optimize method'
16
18
  end
@@ -18,7 +20,7 @@ describe Logic::Predicate::Inequality, '#optimize' do
18
20
  context 'and are not joinable' do
19
21
  let(:right) { Attribute::String.new(:other) }
20
22
 
21
- it { should equal(Logic::Proposition::Tautology.instance) }
23
+ it { should equal(Function::Proposition::Tautology.instance) }
22
24
 
23
25
  it_should_behave_like 'an optimize method'
24
26
  end
@@ -44,7 +46,7 @@ describe Logic::Predicate::Inequality, '#optimize' do
44
46
  context 'right is an invalid value' do
45
47
  let(:right) { 'a' }
46
48
 
47
- it { should equal(Logic::Proposition::Tautology.instance) }
49
+ it { should equal(Function::Proposition::Tautology.instance) }
48
50
 
49
51
  it_should_behave_like 'an optimize method'
50
52
  end
@@ -62,7 +64,7 @@ describe Logic::Predicate::Inequality, '#optimize' do
62
64
  context 'left is an invalid value' do
63
65
  let(:left) { 'a' }
64
66
 
65
- it { should equal(Logic::Proposition::Tautology.instance) }
67
+ it { should equal(Function::Proposition::Tautology.instance) }
66
68
 
67
69
  it_should_behave_like 'an optimize method'
68
70
  end
@@ -73,7 +75,7 @@ describe Logic::Predicate::Inequality, '#optimize' do
73
75
  let(:left) { 1 }
74
76
  let(:right) { 2 }
75
77
 
76
- it { should equal(Logic::Proposition::Tautology.instance) }
78
+ it { should equal(Function::Proposition::Tautology.instance) }
77
79
 
78
80
  it_should_behave_like 'an optimize method'
79
81
  end
@@ -82,7 +84,7 @@ describe Logic::Predicate::Inequality, '#optimize' do
82
84
  let(:left) { 1 }
83
85
  let(:right) { 1 }
84
86
 
85
- it { should equal(Logic::Proposition::Contradiction.instance) }
87
+ it { should equal(Function::Proposition::Contradiction.instance) }
86
88
 
87
89
  it_should_behave_like 'an optimize method'
88
90
  end
@@ -1,16 +1,18 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
- describe Logic::Predicate::LessThan, '#optimize' do
5
+ describe Function::Predicate::LessThan, '#optimize' do
4
6
  subject { object.optimize }
5
7
 
6
- let(:attribute) { Attribute::Integer.new(:id, :required => false) }
7
- let(:left) { attribute }
8
- let(:right) { attribute }
9
- let(:object) { described_class.new(left, right) }
8
+ let(:attribute) { Attribute::Integer.new(:id, :required => false, :size => 1..2**31-1) }
9
+ let(:left) { attribute }
10
+ let(:right) { attribute }
11
+ let(:object) { described_class.new(left, right) }
10
12
 
11
13
  context 'left and right are attributes' do
12
14
  context 'and equivalent' do
13
- it { should equal(Logic::Proposition::Contradiction.instance) }
15
+ it { should equal(Function::Proposition::Contradiction.instance) }
14
16
 
15
17
  it_should_behave_like 'an optimize method'
16
18
  end
@@ -18,7 +20,7 @@ describe Logic::Predicate::LessThan, '#optimize' do
18
20
  context 'and are not comparable' do
19
21
  let(:right) { Attribute::Float.new(:float) }
20
22
 
21
- it { should equal(Logic::Proposition::Contradiction.instance) }
23
+ it { should equal(Function::Proposition::Contradiction.instance) }
22
24
 
23
25
  it_should_behave_like 'an optimize method'
24
26
  end
@@ -27,7 +29,7 @@ describe Logic::Predicate::LessThan, '#optimize' do
27
29
  let(:left) { attribute }
28
30
  let(:right) { Attribute::Integer.new(:right, :size => 2**31..2**31) }
29
31
 
30
- it { should equal(Logic::Proposition::Tautology.instance) }
32
+ it { should equal(Function::Proposition::Tautology.instance) }
31
33
 
32
34
  it_should_behave_like 'an optimize method'
33
35
  end
@@ -36,7 +38,7 @@ describe Logic::Predicate::LessThan, '#optimize' do
36
38
  let(:left) { attribute }
37
39
  let(:right) { Attribute::Integer.new(:right, :size => 0..0) }
38
40
 
39
- it { should equal(Logic::Proposition::Contradiction.instance) }
41
+ it { should equal(Function::Proposition::Contradiction.instance) }
40
42
 
41
43
  it_should_behave_like 'an optimize method'
42
44
  end
@@ -44,7 +46,7 @@ describe Logic::Predicate::LessThan, '#optimize' do
44
46
 
45
47
  context 'left is an attribute' do
46
48
  context 'right is a valid value' do
47
- let(:right) { 1 }
49
+ let(:right) { 2 }
48
50
 
49
51
  it { should equal(object) }
50
52
 
@@ -54,7 +56,7 @@ describe Logic::Predicate::LessThan, '#optimize' do
54
56
  context 'right is an invalid primitive' do
55
57
  let(:right) { nil }
56
58
 
57
- it { should equal(Logic::Proposition::Contradiction.instance) }
59
+ it { should equal(Function::Proposition::Contradiction.instance) }
58
60
 
59
61
  it_should_behave_like 'an optimize method'
60
62
  end
@@ -64,7 +66,7 @@ describe Logic::Predicate::LessThan, '#optimize' do
64
66
  context 'left is a valid value' do
65
67
  let(:left) { 1 }
66
68
 
67
- it { should eql(Logic::Predicate::GreaterThan.new(attribute, 1)) }
69
+ it { should eql(Function::Predicate::GreaterThan.new(attribute, 1)) }
68
70
 
69
71
  it_should_behave_like 'an optimize method'
70
72
  end
@@ -72,7 +74,7 @@ describe Logic::Predicate::LessThan, '#optimize' do
72
74
  context 'left is an invalid primitive' do
73
75
  let(:left) { nil }
74
76
 
75
- it { should equal(Logic::Proposition::Contradiction.instance) }
77
+ it { should equal(Function::Proposition::Contradiction.instance) }
76
78
 
77
79
  it_should_behave_like 'an optimize method'
78
80
  end
@@ -83,7 +85,7 @@ describe Logic::Predicate::LessThan, '#optimize' do
83
85
  let(:left) { 1 }
84
86
  let(:right) { 2 }
85
87
 
86
- it { should equal(Logic::Proposition::Tautology.instance) }
88
+ it { should equal(Function::Proposition::Tautology.instance) }
87
89
 
88
90
  it_should_behave_like 'an optimize method'
89
91
  end
@@ -92,7 +94,7 @@ describe Logic::Predicate::LessThan, '#optimize' do
92
94
  let(:left) { 1 }
93
95
  let(:right) { 1 }
94
96
 
95
- it { should equal(Logic::Proposition::Contradiction.instance) }
97
+ it { should equal(Function::Proposition::Contradiction.instance) }
96
98
 
97
99
  it_should_behave_like 'an optimize method'
98
100
  end
@@ -1,16 +1,18 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
- describe Logic::Predicate::LessThanOrEqualTo, '#optimize' do
5
+ describe Function::Predicate::LessThanOrEqualTo, '#optimize' do
4
6
  subject { object.optimize }
5
7
 
6
- let(:attribute) { Attribute::Integer.new(:id, :required => false) }
7
- let(:left) { attribute }
8
- let(:right) { attribute }
9
- let(:object) { described_class.new(left, right) }
8
+ let(:attribute) { Attribute::Integer.new(:id, :required => false, :size => 1..2**31-1) }
9
+ let(:left) { attribute }
10
+ let(:right) { attribute }
11
+ let(:object) { described_class.new(left, right) }
10
12
 
11
13
  context 'left and right are attributes' do
12
14
  context 'and equivalent' do
13
- it { should equal(Logic::Proposition::Tautology.instance) }
15
+ it { should equal(Function::Proposition::Tautology.instance) }
14
16
 
15
17
  it_should_behave_like 'an optimize method'
16
18
  end
@@ -18,7 +20,7 @@ describe Logic::Predicate::LessThanOrEqualTo, '#optimize' do
18
20
  context 'and are not comparable' do
19
21
  let(:right) { Attribute::Float.new(:float) }
20
22
 
21
- it { should equal(Logic::Proposition::Contradiction.instance) }
23
+ it { should equal(Function::Proposition::Contradiction.instance) }
22
24
 
23
25
  it_should_behave_like 'an optimize method'
24
26
  end
@@ -27,7 +29,7 @@ describe Logic::Predicate::LessThanOrEqualTo, '#optimize' do
27
29
  let(:left) { attribute }
28
30
  let(:right) { Attribute::Integer.new(:right, :size => 2**31..2**31) }
29
31
 
30
- it { should equal(Logic::Proposition::Tautology.instance) }
32
+ it { should equal(Function::Proposition::Tautology.instance) }
31
33
 
32
34
  it_should_behave_like 'an optimize method'
33
35
  end
@@ -36,7 +38,7 @@ describe Logic::Predicate::LessThanOrEqualTo, '#optimize' do
36
38
  let(:left) { attribute }
37
39
  let(:right) { Attribute::Integer.new(:right, :size => -1..-1) }
38
40
 
39
- it { should equal(Logic::Proposition::Contradiction.instance) }
41
+ it { should equal(Function::Proposition::Contradiction.instance) }
40
42
 
41
43
  it_should_behave_like 'an optimize method'
42
44
  end
@@ -54,7 +56,7 @@ describe Logic::Predicate::LessThanOrEqualTo, '#optimize' do
54
56
  context 'right is an invalid primitive' do
55
57
  let(:right) { nil }
56
58
 
57
- it { should equal(Logic::Proposition::Contradiction.instance) }
59
+ it { should equal(Function::Proposition::Contradiction.instance) }
58
60
 
59
61
  it_should_behave_like 'an optimize method'
60
62
  end
@@ -62,9 +64,9 @@ describe Logic::Predicate::LessThanOrEqualTo, '#optimize' do
62
64
 
63
65
  context 'right is an attribute' do
64
66
  context 'left is a valid value' do
65
- let(:left) { 1 }
67
+ let(:left) { 2 }
66
68
 
67
- it { should eql(Logic::Predicate::GreaterThanOrEqualTo.new(attribute, 1)) }
69
+ it { should eql(Function::Predicate::GreaterThanOrEqualTo.new(attribute, 2)) }
68
70
 
69
71
  it_should_behave_like 'an optimize method'
70
72
  end
@@ -72,7 +74,7 @@ describe Logic::Predicate::LessThanOrEqualTo, '#optimize' do
72
74
  context 'left is an invalid primitive' do
73
75
  let(:left) { nil }
74
76
 
75
- it { should equal(Logic::Proposition::Contradiction.instance) }
77
+ it { should equal(Function::Proposition::Contradiction.instance) }
76
78
 
77
79
  it_should_behave_like 'an optimize method'
78
80
  end
@@ -83,7 +85,7 @@ describe Logic::Predicate::LessThanOrEqualTo, '#optimize' do
83
85
  let(:left) { 1 }
84
86
  let(:right) { 1 }
85
87
 
86
- it { should equal(Logic::Proposition::Tautology.instance) }
88
+ it { should equal(Function::Proposition::Tautology.instance) }
87
89
 
88
90
  it_should_behave_like 'an optimize method'
89
91
  end
@@ -92,7 +94,7 @@ describe Logic::Predicate::LessThanOrEqualTo, '#optimize' do
92
94
  let(:left) { 2 }
93
95
  let(:right) { 1 }
94
96
 
95
- it { should equal(Logic::Proposition::Contradiction.instance) }
97
+ it { should equal(Function::Proposition::Contradiction.instance) }
96
98
 
97
99
  it_should_behave_like 'an optimize method'
98
100
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Relation::Empty, '#optimize' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Relation::Materialized, '#optimize' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Relation::Operation::Limit, '#optimize' do
@@ -6,7 +8,7 @@ describe Relation::Operation::Limit, '#optimize' do
6
8
  let(:body) { [ [ 1 ], [ 2 ], [ 3 ] ].each }
7
9
  let(:relation) { Relation.new([ [ :id, Integer ] ], body) }
8
10
  let(:directions) { [ relation[:id] ] }
9
- let(:order) { relation.order(directions) }
11
+ let(:order) { relation.order { directions } }
10
12
  let(:operand) { order }
11
13
  let(:limit) { 1 }
12
14
  let(:object) { described_class.new(operand, limit) }
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Relation::Operation::Offset, '#optimize' do
@@ -6,7 +8,7 @@ describe Relation::Operation::Offset, '#optimize' do
6
8
  let(:body) { [ [ 1 ], [ 2 ], [ 3 ] ].each }
7
9
  let(:relation) { Relation.new([ [ :id, Integer ] ], body) }
8
10
  let(:directions) { [ relation[:id] ] }
9
- let(:order) { relation.order(directions) }
11
+ let(:order) { relation.order { directions } }
10
12
  let(:operand) { order }
11
13
  let(:offset) { 1 }
12
14
  let(:object) { described_class.new(operand, offset) }
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Relation::Operation::Order, '#optimize' do
@@ -23,7 +25,7 @@ describe Relation::Operation::Order, '#optimize' do
23
25
  context 'containing an optimizable relation' do
24
26
  let(:operand) { relation.project(relation.header) }
25
27
 
26
- it { should eql(relation.order(directions)) }
28
+ it { should eql(relation.order { directions }) }
27
29
 
28
30
  it 'returns an equivalent relation to the unoptimized operation' do
29
31
  should == object
@@ -40,7 +42,7 @@ describe Relation::Operation::Order, '#optimize' do
40
42
  context 'containing an object operation' do
41
43
  let(:operand) { relation.order { |r| [ r[:id].desc ] } }
42
44
 
43
- it { should eql(relation.order(directions)) }
45
+ it { should eql(relation.order { directions }) }
44
46
 
45
47
  it 'returns an equivalent relation to the unoptimized operation' do
46
48
  should == object
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Relation::Operation::Reverse, '#optimize' do
@@ -50,7 +52,7 @@ describe Relation::Operation::Reverse, '#optimize' do
50
52
  end
51
53
 
52
54
  context 'with an order operation' do
53
- it { should eql(relation.order(object.directions)) }
55
+ it { should eql(relation.order { object.directions }) }
54
56
 
55
57
  it 'returns an equivalent relation to the unoptimized operation' do
56
58
  should == object
@@ -67,7 +69,7 @@ describe Relation::Operation::Reverse, '#optimize' do
67
69
  context 'with an order operation when optimized' do
68
70
  let(:operand) { order.rename({}) }
69
71
 
70
- it { should eql(relation.order(object.directions)) }
72
+ it { should eql(relation.order { object.directions }) }
71
73
 
72
74
  it 'returns an equivalent relation to the unoptimized operation' do
73
75
  should == object
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Relation, '#optimize' do
@@ -1,4 +1,6 @@
1
- shared_examples_for 'Logic::Connective::Binary#optimize' do
1
+ # encoding: utf-8
2
+
3
+ shared_examples_for 'Function::Connective::Binary#optimize' do
2
4
  context 'left and right are the same' do
3
5
  let(:left) { attribute.gt(1) }
4
6
  let(:right) { attribute.gt(1) }
@@ -9,9 +11,9 @@ shared_examples_for 'Logic::Connective::Binary#optimize' do
9
11
  end
10
12
 
11
13
  context 'left and right are the same, after optimizing the left' do
12
- let(:original_left) { attribute.gt(1) }
13
- let(:left) { original_left.and(Logic::Proposition::Tautology.instance) }
14
- let(:right) { attribute.gt(1) }
14
+ let(:original_left) { attribute.gt(1) }
15
+ let(:left) { original_left.and(Function::Proposition::Tautology.instance) }
16
+ let(:right) { attribute.gt(1) }
15
17
 
16
18
  it { should equal(original_left) }
17
19
 
@@ -19,8 +21,8 @@ shared_examples_for 'Logic::Connective::Binary#optimize' do
19
21
  end
20
22
 
21
23
  context 'left and right are the same, after optimizing the right' do
22
- let(:left) { attribute.gt(1) }
23
- let(:right) { attribute.gt(1).and(Logic::Proposition::Tautology.instance) }
24
+ let(:left) { attribute.gt(1) }
25
+ let(:right) { attribute.gt(1).and(Function::Proposition::Tautology.instance) }
24
26
 
25
27
  it { should equal(left) }
26
28
 
@@ -37,9 +39,9 @@ shared_examples_for 'Logic::Connective::Binary#optimize' do
37
39
  end
38
40
 
39
41
  context 'left and right are different, after optimizing the left' do
40
- let(:original_left) { attribute.gt(1) }
41
- let(:left) { original_left.and(Logic::Proposition::Tautology.instance) }
42
- let(:right) { attribute.lt(1) }
42
+ let(:original_left) { attribute.gt(1) }
43
+ let(:left) { original_left.and(Function::Proposition::Tautology.instance) }
44
+ let(:right) { attribute.lt(1) }
43
45
 
44
46
  add_method_missing
45
47
 
@@ -55,9 +57,9 @@ shared_examples_for 'Logic::Connective::Binary#optimize' do
55
57
  end
56
58
 
57
59
  context 'left and right are different, after optimizing the right' do
58
- let(:original_right) { attribute.lt(1) }
59
- let(:left) { attribute.gt(1) }
60
- let(:right) { original_right.and(Logic::Proposition::Tautology.instance) }
60
+ let(:original_right) { attribute.lt(1) }
61
+ let(:left) { attribute.gt(1) }
62
+ let(:right) { original_right.and(Function::Proposition::Tautology.instance) }
61
63
 
62
64
  add_method_missing
63
65
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  shared_examples_for 'an idempotent method' do
2
4
  it 'is idempotent' do
3
5
  should equal(instance_eval(&self.class.subject))
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  shared_examples_for 'an optimize method' do
2
4
  it_should_behave_like 'an idempotent method'
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module AddMethodMissing
2
4
  def add_method_missing(name = :described_class)
3
5
  before do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Optimizer::Algebra::Difference::EmptyLeft, '#optimize' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Optimizer::Algebra::Difference::EmptyRight, '#optimize' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Optimizer::Algebra::Difference::EqualOperands, '#optimize' do
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Optimizer::Algebra::Extension, '#extensions' do
6
+ subject { object.extensions }
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.extend { |r| r.add(attribute, function) } }
12
+ let(:object) { described_class.new(relation) }
13
+
14
+ before do
15
+ object.operation.should be_kind_of(Algebra::Extension)
16
+ end
17
+
18
+ context 'when extensions are optimized' do
19
+ let(:function) { 1 }
20
+
21
+ it { should eql(relation.extensions) }
22
+ end
23
+
24
+ context 'when extensions are not optimized' do
25
+ let(:function) { Function::Numeric::Absolute.new(1) }
26
+
27
+ it { should_not equal(relation.extensions) }
28
+
29
+ it { should eql(attribute => 1) }
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Optimizer::Algebra::Extension::OrderOperand, '#optimizable?' do
6
+ subject { object.optimizable? }
7
+
8
+ let(:base) { Relation.new([ [ :id, Integer ] ], [].each) }
9
+ let(:relation) { operand.extend {} }
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::Extension::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.extend {} }
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::Extension) }
18
+
19
+ its(:operand) { should equal(base) }
20
+
21
+ its(:extensions) { should eql(relation.extensions) }
22
+ end
@@ -1,26 +1,36 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Optimizer::Algebra::Extension::UnoptimizedOperand, '#optimizable?' do
4
6
  subject { object.optimizable? }
5
7
 
6
- let(:header) { Relation::Header.new([ [ :id, Integer ] ]) }
7
- let(:base) { Relation.new(header, [ [ 1 ] ].each) }
8
- let(:extensions) { [ :text, lambda { |tuple| 1 } ] }
9
- let(:relation) { operand.extend { |r| r.add(*extensions) } }
10
- let(:object) { described_class.new(relation) }
8
+ let(:header) { Relation::Header.new([ [ :id, Integer ] ]) }
9
+ let(:base) { Relation.new(header, [ [ 1 ] ].each) }
10
+ let(:relation) { operand.extend { |r| r.add(*extensions) } }
11
+ let(:object) { described_class.new(relation) }
11
12
 
12
13
  before do
13
14
  object.operation.should be_kind_of(Algebra::Extension)
14
15
  end
15
16
 
16
17
  context 'when the operand is optimizable' do
17
- let(:operand) { base.rename({}) }
18
+ let(:operand) { base.rename({}) }
19
+ let(:extensions) { [ :text, 1 ] }
20
+
21
+ it { should be(true) }
22
+ end
23
+
24
+ context 'when the extensions are optimizable' do
25
+ let(:operand) { base }
26
+ let(:extensions) { [ :text, Function::Numeric::Absolute.new(1) ] }
18
27
 
19
28
  it { should be(true) }
20
29
  end
21
30
 
22
- context 'when the operand is not optimizable' do
23
- let(:operand) { base }
31
+ context 'when the operand and extensions are not optimizable' do
32
+ let(:operand) { base }
33
+ let(:extensions) { [ :text, 1 ] }
24
34
 
25
35
  it { should be(false) }
26
36
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Optimizer::Algebra::Extension::UnoptimizedOperand, '#optimize' do
@@ -6,7 +8,7 @@ describe Optimizer::Algebra::Extension::UnoptimizedOperand, '#optimize' do
6
8
  let(:header) { Relation::Header.new([ [ :id, Integer ] ]) }
7
9
  let(:base) { Relation.new(header, [ [ 1 ] ].each) }
8
10
  let(:attribute) { Attribute::Object.new(:text) }
9
- let(:function) { lambda { |tuple| 1 } }
11
+ let(:function) { Function::Numeric::Absolute.new(1) }
10
12
  let(:operand) { base.rename({}) }
11
13
  let(:relation) { operand.extend { |r| r.add(attribute, function) } }
12
14
  let(:object) { described_class.new(relation) }
@@ -21,5 +23,5 @@ describe Optimizer::Algebra::Extension::UnoptimizedOperand, '#optimize' do
21
23
 
22
24
  its(:operand) { should equal(base) }
23
25
 
24
- its(:extensions) { should == { attribute => function } }
26
+ its(:extensions) { should == { attribute => 1 } }
25
27
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Optimizer::Algebra::Intersection::EmptyLeft, '#optimize' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Optimizer::Algebra::Intersection::EmptyRight, '#optimize' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Optimizer::Algebra::Intersection::EqualOperands, '#optimize' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Optimizer::Algebra::Join::EqualHeaders, '#optimizable?' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Optimizer::Algebra::Join::EqualHeaders, '#optimize' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Optimizer::Algebra::Product::TableDeeLeft, '#optimizable?' do