alf-core 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/Gemfile +29 -0
- data/Gemfile.lock +41 -0
- data/LICENCE.md +22 -0
- data/Manifest.txt +14 -0
- data/README.md +11 -0
- data/Rakefile +11 -0
- data/TODO.md +23 -0
- data/examples/functions-as-values.rb +39 -0
- data/examples/memory_database.rb +44 -0
- data/examples/operators/autonum.alf +6 -0
- data/examples/operators/cities.rash +4 -0
- data/examples/operators/clip.alf +3 -0
- data/examples/operators/compact.alf +2 -0
- data/examples/operators/defaults.alf +3 -0
- data/examples/operators/extend.alf +3 -0
- data/examples/operators/group.alf +3 -0
- data/examples/operators/intersect.alf +4 -0
- data/examples/operators/join.alf +2 -0
- data/examples/operators/matching.alf +2 -0
- data/examples/operators/minus.alf +8 -0
- data/examples/operators/not_matching.alf +2 -0
- data/examples/operators/nulls.rash +3 -0
- data/examples/operators/parts.rash +6 -0
- data/examples/operators/project.alf +3 -0
- data/examples/operators/pseudo-with.alf +7 -0
- data/examples/operators/quota.alf +4 -0
- data/examples/operators/rank.alf +4 -0
- data/examples/operators/rename.alf +3 -0
- data/examples/operators/restrict.alf +2 -0
- data/examples/operators/schema.yaml +28 -0
- data/examples/operators/sort.alf +4 -0
- data/examples/operators/summarize.alf +16 -0
- data/examples/operators/suppliers.rash +5 -0
- data/examples/operators/supplies.rash +12 -0
- data/examples/operators/ungroup.alf +4 -0
- data/examples/operators/union.alf +3 -0
- data/examples/operators/unwrap.alf +4 -0
- data/examples/operators/wrap.alf +2 -0
- data/examples/readme.rb +23 -0
- data/examples/suppliers_and_parts/cities.rash +4 -0
- data/examples/suppliers_and_parts/parts.rash +6 -0
- data/examples/suppliers_and_parts/suppliers.rash +5 -0
- data/examples/suppliers_and_parts/supplies.rash +12 -0
- data/lib/alf-adapter-fs/alf/adapter/folder.rb +22 -0
- data/lib/alf-adapter-fs/alf/adapter/folder/connection.rb +39 -0
- data/lib/alf-adapter-fs/alf/adapter/fs.rb +1 -0
- data/lib/alf-adapter/alf/adapter.rb +95 -0
- data/lib/alf-adapter/alf/adapter/connection.rb +88 -0
- data/lib/alf-adapter/alf/adapter/connection/schema_cached.rb +34 -0
- data/lib/alf-aggregator/alf/aggregator.rb +223 -0
- data/lib/alf-aggregator/alf/aggregator/avg.rb +39 -0
- data/lib/alf-aggregator/alf/aggregator/collect.rb +32 -0
- data/lib/alf-aggregator/alf/aggregator/concat.rb +47 -0
- data/lib/alf-aggregator/alf/aggregator/count.rb +32 -0
- data/lib/alf-aggregator/alf/aggregator/max.rb +32 -0
- data/lib/alf-aggregator/alf/aggregator/min.rb +32 -0
- data/lib/alf-aggregator/alf/aggregator/stddev.rb +25 -0
- data/lib/alf-aggregator/alf/aggregator/sum.rb +32 -0
- data/lib/alf-aggregator/alf/aggregator/variance.rb +45 -0
- data/lib/alf-algebra/alf/algebra.rb +13 -0
- data/lib/alf-algebra/alf/algebra/operand.rb +54 -0
- data/lib/alf-algebra/alf/algebra/operand/fake.rb +61 -0
- data/lib/alf-algebra/alf/algebra/operand/named.rb +36 -0
- data/lib/alf-algebra/alf/algebra/operand/proxy.rb +25 -0
- data/lib/alf-algebra/alf/algebra/operator.rb +134 -0
- data/lib/alf-algebra/alf/algebra/operator/autonum.rb +20 -0
- data/lib/alf-algebra/alf/algebra/operator/clip.rb +28 -0
- data/lib/alf-algebra/alf/algebra/operator/coerce.rb +20 -0
- data/lib/alf-algebra/alf/algebra/operator/compact.rb +19 -0
- data/lib/alf-algebra/alf/algebra/operator/defaults.rb +24 -0
- data/lib/alf-algebra/alf/algebra/operator/extend.rb +23 -0
- data/lib/alf-algebra/alf/algebra/operator/generator.rb +21 -0
- data/lib/alf-algebra/alf/algebra/operator/group.rb +28 -0
- data/lib/alf-algebra/alf/algebra/operator/infer_heading.rb +19 -0
- data/lib/alf-algebra/alf/algebra/operator/intersect.rb +24 -0
- data/lib/alf-algebra/alf/algebra/operator/join.rb +27 -0
- data/lib/alf-algebra/alf/algebra/operator/matching.rb +19 -0
- data/lib/alf-algebra/alf/algebra/operator/minus.rb +19 -0
- data/lib/alf-algebra/alf/algebra/operator/not_matching.rb +19 -0
- data/lib/alf-algebra/alf/algebra/operator/project.rb +36 -0
- data/lib/alf-algebra/alf/algebra/operator/quota.rb +22 -0
- data/lib/alf-algebra/alf/algebra/operator/rank.rb +28 -0
- data/lib/alf-algebra/alf/algebra/operator/rename.rb +24 -0
- data/lib/alf-algebra/alf/algebra/operator/restrict.rb +26 -0
- data/lib/alf-algebra/alf/algebra/operator/sort.rb +20 -0
- data/lib/alf-algebra/alf/algebra/operator/summarize.rb +28 -0
- data/lib/alf-algebra/alf/algebra/operator/type_safe.rb +21 -0
- data/lib/alf-algebra/alf/algebra/operator/ungroup.rb +31 -0
- data/lib/alf-algebra/alf/algebra/operator/union.rb +19 -0
- data/lib/alf-algebra/alf/algebra/operator/unwrap.rb +23 -0
- data/lib/alf-algebra/alf/algebra/operator/wrap.rb +41 -0
- data/lib/alf-algebra/alf/algebra/support.rb +15 -0
- data/lib/alf-algebra/alf/algebra/support/binary.rb +51 -0
- data/lib/alf-algebra/alf/algebra/support/classification.rb +37 -0
- data/lib/alf-algebra/alf/algebra/support/compiler.rb +28 -0
- data/lib/alf-algebra/alf/algebra/support/experimental.rb +19 -0
- data/lib/alf-algebra/alf/algebra/support/non_relational.rb +16 -0
- data/lib/alf-algebra/alf/algebra/support/nullary.rb +25 -0
- data/lib/alf-algebra/alf/algebra/support/relational.rb +16 -0
- data/lib/alf-algebra/alf/algebra/support/rewriter.rb +32 -0
- data/lib/alf-algebra/alf/algebra/support/signature.rb +195 -0
- data/lib/alf-algebra/alf/algebra/support/to_dot.rb +196 -0
- data/lib/alf-algebra/alf/algebra/support/unary.rb +34 -0
- data/lib/alf-algebra/alf/algebra/support/visitor.rb +31 -0
- data/lib/alf-core.rb +37 -0
- data/lib/alf-core/dsl.rb +22 -0
- data/lib/alf-core/errors.rb +16 -0
- data/lib/alf-core/ext.rb +1 -0
- data/lib/alf-core/ext/domain/heading_based.rb +88 -0
- data/lib/alf-core/facade.rb +35 -0
- data/lib/alf-core/loader.rb +13 -0
- data/lib/alf-core/version.rb +16 -0
- data/lib/alf-database/alf/database.rb +46 -0
- data/lib/alf-database/alf/database/connection.rb +156 -0
- data/lib/alf-database/alf/database/options.rb +25 -0
- data/lib/alf-engine/alf/engine.rb +37 -0
- data/lib/alf-engine/alf/engine/aggregate.rb +46 -0
- data/lib/alf-engine/alf/engine/autonum.rb +46 -0
- data/lib/alf-engine/alf/engine/cesure.rb +47 -0
- data/lib/alf-engine/alf/engine/clip.rb +54 -0
- data/lib/alf-engine/alf/engine/coerce.rb +47 -0
- data/lib/alf-engine/alf/engine/cog.rb +27 -0
- data/lib/alf-engine/alf/engine/compact.rb +27 -0
- data/lib/alf-engine/alf/engine/compact/set.rb +24 -0
- data/lib/alf-engine/alf/engine/compact/uniq.rb +24 -0
- data/lib/alf-engine/alf/engine/compiler.rb +144 -0
- data/lib/alf-engine/alf/engine/concat.rb +26 -0
- data/lib/alf-engine/alf/engine/defaults.rb +44 -0
- data/lib/alf-engine/alf/engine/filter.rb +42 -0
- data/lib/alf-engine/alf/engine/generator.rb +51 -0
- data/lib/alf-engine/alf/engine/group.rb +3 -0
- data/lib/alf-engine/alf/engine/group/hash.rb +41 -0
- data/lib/alf-engine/alf/engine/infer_heading.rb +29 -0
- data/lib/alf-engine/alf/engine/join.rb +3 -0
- data/lib/alf-engine/alf/engine/join/hash.rb +36 -0
- data/lib/alf-engine/alf/engine/leaf.rb +24 -0
- data/lib/alf-engine/alf/engine/materialize.rb +4 -0
- data/lib/alf-engine/alf/engine/materialize/array.rb +79 -0
- data/lib/alf-engine/alf/engine/materialize/hash.rb +123 -0
- data/lib/alf-engine/alf/engine/quota.rb +3 -0
- data/lib/alf-engine/alf/engine/quota/cesure.rb +48 -0
- data/lib/alf-engine/alf/engine/rank.rb +3 -0
- data/lib/alf-engine/alf/engine/rank/cesure.rb +48 -0
- data/lib/alf-engine/alf/engine/rename.rb +40 -0
- data/lib/alf-engine/alf/engine/semi.rb +3 -0
- data/lib/alf-engine/alf/engine/semi/hash.rb +40 -0
- data/lib/alf-engine/alf/engine/set_attr.rb +47 -0
- data/lib/alf-engine/alf/engine/sort.rb +29 -0
- data/lib/alf-engine/alf/engine/sort/in_memory.rb +40 -0
- data/lib/alf-engine/alf/engine/summarize.rb +4 -0
- data/lib/alf-engine/alf/engine/summarize/cesure.rb +54 -0
- data/lib/alf-engine/alf/engine/summarize/hash.rb +36 -0
- data/lib/alf-engine/alf/engine/to_array.rb +62 -0
- data/lib/alf-engine/alf/engine/to_dot.rb +60 -0
- data/lib/alf-engine/alf/engine/type_safe.rb +28 -0
- data/lib/alf-engine/alf/engine/ungroup.rb +31 -0
- data/lib/alf-engine/alf/engine/unwrap.rb +33 -0
- data/lib/alf-engine/alf/engine/wrap.rb +40 -0
- data/lib/alf-io/alf/io.rb +6 -0
- data/lib/alf-io/alf/reader.rb +189 -0
- data/lib/alf-io/alf/reader/csv.rb +28 -0
- data/lib/alf-io/alf/reader/json.rb +25 -0
- data/lib/alf-io/alf/reader/rash.rb +32 -0
- data/lib/alf-io/alf/renderer.rb +119 -0
- data/lib/alf-io/alf/renderer/csv.rb +30 -0
- data/lib/alf-io/alf/renderer/json.rb +33 -0
- data/lib/alf-io/alf/renderer/rash.rb +38 -0
- data/lib/alf-io/alf/renderer/text.rb +166 -0
- data/lib/alf-io/alf/renderer/yaml.rb +25 -0
- data/lib/alf-io/alf/support/csv_utils.rb +40 -0
- data/lib/alf-lang/alf/lang.rb +4 -0
- data/lib/alf-lang/alf/lang/functional.rb +56 -0
- data/lib/alf-lang/alf/lang/lispy.rb +53 -0
- data/lib/alf-lang/alf/lang/object_oriented.rb +26 -0
- data/lib/alf-lang/alf/lang/oo/aggregation_methods.rb +19 -0
- data/lib/alf-lang/alf/lang/oo/algebra_methods.rb +72 -0
- data/lib/alf-lang/alf/lang/oo/rendering_methods.rb +54 -0
- data/lib/alf-lang/alf/lang/predicates.rb +17 -0
- data/lib/alf-optimizer/alf/optimizer.rb +38 -0
- data/lib/alf-optimizer/alf/optimizer/restrict.rb +169 -0
- data/lib/alf-predicate/alf/predicate.rb +110 -0
- data/lib/alf-predicate/alf/predicate/factory.rb +104 -0
- data/lib/alf-predicate/alf/predicate/grammar.rb +38 -0
- data/lib/alf-predicate/alf/predicate/grammar.sexp.yml +54 -0
- data/lib/alf-predicate/alf/predicate/nodes/and.rb +25 -0
- data/lib/alf-predicate/alf/predicate/nodes/contradiction.rb +36 -0
- data/lib/alf-predicate/alf/predicate/nodes/dyadic_comp.rb +28 -0
- data/lib/alf-predicate/alf/predicate/nodes/eq.rb +17 -0
- data/lib/alf-predicate/alf/predicate/nodes/expr.rb +65 -0
- data/lib/alf-predicate/alf/predicate/nodes/gt.rb +12 -0
- data/lib/alf-predicate/alf/predicate/nodes/gte.rb +12 -0
- data/lib/alf-predicate/alf/predicate/nodes/in.rb +28 -0
- data/lib/alf-predicate/alf/predicate/nodes/literal.rb +20 -0
- data/lib/alf-predicate/alf/predicate/nodes/lt.rb +12 -0
- data/lib/alf-predicate/alf/predicate/nodes/lte.rb +12 -0
- data/lib/alf-predicate/alf/predicate/nodes/nadic_bool.rb +18 -0
- data/lib/alf-predicate/alf/predicate/nodes/native.rb +20 -0
- data/lib/alf-predicate/alf/predicate/nodes/neq.rb +12 -0
- data/lib/alf-predicate/alf/predicate/nodes/not.rb +24 -0
- data/lib/alf-predicate/alf/predicate/nodes/or.rb +12 -0
- data/lib/alf-predicate/alf/predicate/nodes/tautology.rb +32 -0
- data/lib/alf-predicate/alf/predicate/nodes/var_ref.rb +20 -0
- data/lib/alf-predicate/alf/predicate/parser.rb +12 -0
- data/lib/alf-predicate/alf/predicate/processors.rb +3 -0
- data/lib/alf-predicate/alf/predicate/processors/renamer.rb +19 -0
- data/lib/alf-predicate/alf/predicate/processors/to_proc.rb +35 -0
- data/lib/alf-predicate/alf/predicate/processors/to_ruby_code.rb +74 -0
- data/lib/alf-relation/alf/relation.rb +123 -0
- data/lib/alf-relation/alf/tuple.rb +103 -0
- data/lib/alf-relvar/alf/relvar.rb +87 -0
- data/lib/alf-relvar/alf/relvar/base.rb +64 -0
- data/lib/alf-relvar/alf/relvar/fake.rb +34 -0
- data/lib/alf-relvar/alf/relvar/read_only.rb +67 -0
- data/lib/alf-relvar/alf/relvar/virtual.rb +62 -0
- data/lib/alf-support/alf/support.rb +21 -0
- data/lib/alf-support/alf/support/bindable.rb +26 -0
- data/lib/alf-support/alf/support/coerce.rb +28 -0
- data/lib/alf-support/alf/support/config.rb +62 -0
- data/lib/alf-support/alf/support/dot_utils.rb +15 -0
- data/lib/alf-support/alf/support/miscellaneous.rb +60 -0
- data/lib/alf-support/alf/support/ordered_set.rb +33 -0
- data/lib/alf-support/alf/support/registry.rb +52 -0
- data/lib/alf-support/alf/support/scope.rb +85 -0
- data/lib/alf-support/alf/support/to_lispy.rb +37 -0
- data/lib/alf-support/alf/support/to_ruby_literal.rb +33 -0
- data/lib/alf-support/alf/support/tuple_scope.rb +72 -0
- data/lib/alf-types/alf/types.rb +51 -0
- data/lib/alf-types/alf/types/attr_list.rb +154 -0
- data/lib/alf-types/alf/types/attr_name.rb +24 -0
- data/lib/alf-types/alf/types/boolean.rb +8 -0
- data/lib/alf-types/alf/types/heading.rb +189 -0
- data/lib/alf-types/alf/types/keys.rb +39 -0
- data/lib/alf-types/alf/types/ordering.rb +95 -0
- data/lib/alf-types/alf/types/renaming.rb +74 -0
- data/lib/alf-types/alf/types/size.rb +15 -0
- data/lib/alf-types/alf/types/summarization.rb +101 -0
- data/lib/alf-types/alf/types/tuple_computation.rb +104 -0
- data/lib/alf-types/alf/types/tuple_expression.rb +132 -0
- data/lib/alf-types/alf/types/type_check.rb +58 -0
- data/lib/alf-update/alf/update.rb +3 -0
- data/lib/alf-update/alf/update/deleter.rb +101 -0
- data/lib/alf-update/alf/update/inserter.rb +126 -0
- data/lib/alf-update/alf/update/updater.rb +55 -0
- data/lib/alf-viewpoint/alf/viewpoint.rb +41 -0
- data/spec/integration/__database__/group.alf +3 -0
- data/spec/integration/__database__/parts.rash +6 -0
- data/spec/integration/__database__/suppliers.rash +5 -0
- data/spec/integration/__database__/suppliers_csv.csv +6 -0
- data/spec/integration/__database__/supplies.rash +12 -0
- data/spec/integration/algebra/test_to_dot.rb +14 -0
- data/spec/integration/ext/test_relation.rb +16 -0
- data/spec/integration/relation/test_to_array.rb +28 -0
- data/spec/integration/relvar/test_type_safe.rb +22 -0
- data/spec/integration/test_alf.rb +8 -0
- data/spec/integration/test_examples.rb +14 -0
- data/spec/optimizer_helper.rb +19 -0
- data/spec/regression/heading/test_heading_with_date.rb +12 -0
- data/spec/regression/relation/test_coerce.rb +24 -0
- data/spec/regression/relation/test_relation_allbut_all.rb +14 -0
- data/spec/regression/relation/test_relation_with_date.rb +12 -0
- data/spec/regression/relation/test_restrict.rb +21 -0
- data/spec/regression/restrict/test_restrict_with_keywords.rb +17 -0
- data/spec/shared/a_scope.rb +21 -0
- data/spec/shared/a_valid_type_implementation.rb +47 -0
- data/spec/shared/a_value.rb +12 -0
- data/spec/shared/an_operator_class.rb +49 -0
- data/spec/spec_helper.rb +68 -0
- data/spec/unit/alf-adapter-fs/folder/fixtures/suppliers.rash +5 -0
- data/spec/unit/alf-adapter-fs/folder/test_adapter_class.rb +23 -0
- data/spec/unit/alf-adapter-fs/folder/test_adapter_instance.rb +17 -0
- data/spec/unit/alf-adapter/adapter/test_factor.rb +20 -0
- data/spec/unit/alf-adapter/connection/schema_cached/test_delegate.rb +14 -0
- data/spec/unit/alf-adapter/connection/schema_cached/test_heading.rb +12 -0
- data/spec/unit/alf-adapter/connection/schema_cached/test_keys.rb +12 -0
- data/spec/unit/alf-adapter/connection/schema_cached/test_knows.rb +12 -0
- data/spec/unit/alf-adapter/connection/test_lock.rb +16 -0
- data/spec/unit/alf-adapter/connection/test_migrate.rb +17 -0
- data/spec/unit/alf-adapter/shared_examples/a_cached_connection_method.rb +30 -0
- data/spec/unit/alf-adapter/shared_examples/an_adapter.rb +34 -0
- data/spec/unit/alf-adapter/shared_examples/an_adapter_class.rb +21 -0
- data/spec/unit/alf-adapter/shared_examples/an_adapter_with_readable_cogs.rb +31 -0
- data/spec/unit/alf-adapter/shared_examples/an_uncached_connection_method.rb +21 -0
- data/spec/unit/alf-aggregator/test_avg.rb +22 -0
- data/spec/unit/alf-aggregator/test_collect.rb +25 -0
- data/spec/unit/alf-aggregator/test_concat.rb +31 -0
- data/spec/unit/alf-aggregator/test_count.rb +17 -0
- data/spec/unit/alf-aggregator/test_max.rb +23 -0
- data/spec/unit/alf-aggregator/test_min.rb +23 -0
- data/spec/unit/alf-aggregator/test_stddev.rb +27 -0
- data/spec/unit/alf-aggregator/test_sum.rb +23 -0
- data/spec/unit/alf-aggregator/test_variance.rb +29 -0
- data/spec/unit/alf-algebra/operand/named/test_keys.rb +22 -0
- data/spec/unit/alf-algebra/operand/named/test_to_relvar.rb +18 -0
- data/spec/unit/alf-algebra/operand/test_coerce.rb +43 -0
- data/spec/unit/alf-algebra/operator/allbut/test_key_preserving.rb +55 -0
- data/spec/unit/alf-algebra/operator/allbut/test_keys.rb +52 -0
- data/spec/unit/alf-algebra/operator/autonum/test_heading.rb +22 -0
- data/spec/unit/alf-algebra/operator/autonum/test_keys.rb +22 -0
- data/spec/unit/alf-algebra/operator/clip/test_heading.rb +36 -0
- data/spec/unit/alf-algebra/operator/clip/test_keys.rb +48 -0
- data/spec/unit/alf-algebra/operator/coerce/test_heading.rb +23 -0
- data/spec/unit/alf-algebra/operator/coerce/test_keys.rb +23 -0
- data/spec/unit/alf-algebra/operator/commons/test_with_operands.rb +42 -0
- data/spec/unit/alf-algebra/operator/compact/test_heading.rb +23 -0
- data/spec/unit/alf-algebra/operator/compact/test_keys.rb +38 -0
- data/spec/unit/alf-algebra/operator/defaults/test_heading.rb +48 -0
- data/spec/unit/alf-algebra/operator/defaults/test_keys.rb +22 -0
- data/spec/unit/alf-algebra/operator/extend/test_heading.rb +37 -0
- data/spec/unit/alf-algebra/operator/extend/test_keys.rb +30 -0
- data/spec/unit/alf-algebra/operator/generator/test_heading.rb +19 -0
- data/spec/unit/alf-algebra/operator/generator/test_keys.rb +19 -0
- data/spec/unit/alf-algebra/operator/group/test_heading.rb +33 -0
- data/spec/unit/alf-algebra/operator/group/test_keys.rb +65 -0
- data/spec/unit/alf-algebra/operator/infer_heading/test_keys.rb +23 -0
- data/spec/unit/alf-algebra/operator/intersect/test_heading.rb +39 -0
- data/spec/unit/alf-algebra/operator/intersect/test_keys.rb +67 -0
- data/spec/unit/alf-algebra/operator/join/test_heading.rb +39 -0
- data/spec/unit/alf-algebra/operator/join/test_keys.rb +59 -0
- data/spec/unit/alf-algebra/operator/matching/test_heading.rb +26 -0
- data/spec/unit/alf-algebra/operator/matching/test_keys.rb +43 -0
- data/spec/unit/alf-algebra/operator/minus/test_heading.rb +26 -0
- data/spec/unit/alf-algebra/operator/minus/test_keys.rb +26 -0
- data/spec/unit/alf-algebra/operator/not_matching/test_heading.rb +26 -0
- data/spec/unit/alf-algebra/operator/not_matching/test_keys.rb +26 -0
- data/spec/unit/alf-algebra/operator/project/test_heading.rb +36 -0
- data/spec/unit/alf-algebra/operator/project/test_key_preserving.rb +55 -0
- data/spec/unit/alf-algebra/operator/project/test_keys.rb +52 -0
- data/spec/unit/alf-algebra/operator/quota/test_heading.rb +23 -0
- data/spec/unit/alf-algebra/operator/quota/test_keys.rb +23 -0
- data/spec/unit/alf-algebra/operator/rank/test_heading.rb +23 -0
- data/spec/unit/alf-algebra/operator/rank/test_keys.rb +36 -0
- data/spec/unit/alf-algebra/operator/rename/test_complete_renaming.rb +23 -0
- data/spec/unit/alf-algebra/operator/rename/test_heading.rb +23 -0
- data/spec/unit/alf-algebra/operator/rename/test_keys.rb +23 -0
- data/spec/unit/alf-algebra/operator/restrict/test_heading.rb +23 -0
- data/spec/unit/alf-algebra/operator/restrict/test_keys.rb +52 -0
- data/spec/unit/alf-algebra/operator/sort/test_heading.rb +23 -0
- data/spec/unit/alf-algebra/operator/sort/test_keys.rb +24 -0
- data/spec/unit/alf-algebra/operator/summarize/test_heading.rb +36 -0
- data/spec/unit/alf-algebra/operator/summarize/test_keys.rb +47 -0
- data/spec/unit/alf-algebra/operator/test_autonum.rb +32 -0
- data/spec/unit/alf-algebra/operator/test_clip.rb +32 -0
- data/spec/unit/alf-algebra/operator/test_coerce.rb +20 -0
- data/spec/unit/alf-algebra/operator/test_compact.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_defaults.rb +32 -0
- data/spec/unit/alf-algebra/operator/test_extend.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_generator.rb +23 -0
- data/spec/unit/alf-algebra/operator/test_group.rb +31 -0
- data/spec/unit/alf-algebra/operator/test_infer_heading.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_intersect.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_join.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_minus.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_project.rb +32 -0
- data/spec/unit/alf-algebra/operator/test_quota.rb +19 -0
- data/spec/unit/alf-algebra/operator/test_rank.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_rename.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_restrict.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_sort.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_summarize.rb +36 -0
- data/spec/unit/alf-algebra/operator/test_ungroup.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_union.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_unwrap.rb +16 -0
- data/spec/unit/alf-algebra/operator/test_wrap.rb +32 -0
- data/spec/unit/alf-algebra/operator/type_safe/test_heading.rb +26 -0
- data/spec/unit/alf-algebra/operator/type_safe/test_keys.rb +26 -0
- data/spec/unit/alf-algebra/operator/ungroup/test_heading.rb +20 -0
- data/spec/unit/alf-algebra/operator/ungroup/test_keys.rb +23 -0
- data/spec/unit/alf-algebra/operator/union/test_heading.rb +36 -0
- data/spec/unit/alf-algebra/operator/union/test_keys.rb +26 -0
- data/spec/unit/alf-algebra/operator/unwrap/test_heading.rb +20 -0
- data/spec/unit/alf-algebra/operator/unwrap/test_keys.rb +20 -0
- data/spec/unit/alf-algebra/operator/wrap/test_heading.rb +33 -0
- data/spec/unit/alf-algebra/operator/wrap/test_keys.rb +49 -0
- data/spec/unit/alf-algebra/support/binary/test_with_left.rb +27 -0
- data/spec/unit/alf-algebra/support/binary/test_with_right.rb +27 -0
- data/spec/unit/alf-algebra/support/signature/test_collect_on.rb +41 -0
- data/spec/unit/alf-algebra/support/signature/test_initialize.rb +20 -0
- data/spec/unit/alf-algebra/support/signature/test_install.rb +56 -0
- data/spec/unit/alf-algebra/support/signature/test_option_parser.rb +36 -0
- data/spec/unit/alf-algebra/support/signature/test_parse_args.rb +92 -0
- data/spec/unit/alf-algebra/support/signature/test_to_lispy.rb +102 -0
- data/spec/unit/alf-algebra/support/test_non_relational.rb +23 -0
- data/spec/unit/alf-algebra/support/test_relational.rb +33 -0
- data/spec/unit/alf-algebra/support/unary/test_with_operand.rb +28 -0
- data/spec/unit/alf-algebra/test_operator.rb +18 -0
- data/spec/unit/alf-algebra/test_rewriter.rb +29 -0
- data/spec/unit/alf-core/alf/example.rash +1 -0
- data/spec/unit/alf-core/alf/test_Relation.rb +28 -0
- data/spec/unit/alf-core/alf/test_connect.rb +25 -0
- data/spec/unit/alf-core/alf/test_database.rb +21 -0
- data/spec/unit/alf-core/alf/test_reader.rb +22 -0
- data/spec/unit/alf-core/assumptions/test_file.rb +16 -0
- data/spec/unit/alf-core/assumptions/test_instance_eval.rb +15 -0
- data/spec/unit/alf-core/assumptions/test_scoping.rb +29 -0
- data/spec/unit/alf-core/assumptions/test_set.rb +64 -0
- data/spec/unit/alf-core/test_aggregator.rb +59 -0
- data/spec/unit/alf-database/connection/test_assert.rb +36 -0
- data/spec/unit/alf-database/connection/test_close.rb +28 -0
- data/spec/unit/alf-database/connection/test_deny.rb +36 -0
- data/spec/unit/alf-database/connection/test_fact.rb +48 -0
- data/spec/unit/alf-database/connection/test_lock.rb +19 -0
- data/spec/unit/alf-database/connection/test_migrate.rb +27 -0
- data/spec/unit/alf-database/connection/test_new.rb +17 -0
- data/spec/unit/alf-database/connection/test_options.rb +16 -0
- data/spec/unit/alf-database/connection/test_parse.rb +109 -0
- data/spec/unit/alf-database/connection/test_query.rb +22 -0
- data/spec/unit/alf-database/connection/test_reconnect.rb +41 -0
- data/spec/unit/alf-database/connection/test_relvar.rb +42 -0
- data/spec/unit/alf-database/connection/test_tuple_extract.rb +38 -0
- data/spec/unit/alf-database/database/test_connect.rb +44 -0
- data/spec/unit/alf-database/database/test_connection.rb +21 -0
- data/spec/unit/alf-database/database/test_default_options.rb +14 -0
- data/spec/unit/alf-database/database/test_new.rb +53 -0
- data/spec/unit/alf-database/options/test_default_viewpoint.rb +25 -0
- data/spec/unit/alf-database/options/test_freeze.rb +20 -0
- data/spec/unit/alf-database/options/test_merge.rb +26 -0
- data/spec/unit/alf-database/options/test_new.rb +64 -0
- data/spec/unit/alf-database/options/test_schema_cache.rb +29 -0
- data/spec/unit/alf-database/options/test_viewpoint.rb +25 -0
- data/spec/unit/alf-database/shared_examples/a_facade_on_database_options.rb +6 -0
- data/spec/unit/alf-engine/compact/test_set.rb +33 -0
- data/spec/unit/alf-engine/compact/test_uniq.rb +33 -0
- data/spec/unit/alf-engine/group/test_hash.rb +29 -0
- data/spec/unit/alf-engine/infer_heading/test_heading.rb +30 -0
- data/spec/unit/alf-engine/join/test_hash.rb +55 -0
- data/spec/unit/alf-engine/materialize/test_array.rb +28 -0
- data/spec/unit/alf-engine/materialize/test_hash.rb +76 -0
- data/spec/unit/alf-engine/quota/test_cesure.rb +34 -0
- data/spec/unit/alf-engine/rank/test_cesure.rb +47 -0
- data/spec/unit/alf-engine/semi/test_hash.rb +58 -0
- data/spec/unit/alf-engine/sort/test_in_memory.rb +32 -0
- data/spec/unit/alf-engine/summarize/test_cesure.rb +36 -0
- data/spec/unit/alf-engine/summarize/test_hash.rb +36 -0
- data/spec/unit/alf-engine/test_aggregate.rb +26 -0
- data/spec/unit/alf-engine/test_autonum.rb +24 -0
- data/spec/unit/alf-engine/test_clip.rb +34 -0
- data/spec/unit/alf-engine/test_coerce.rb +35 -0
- data/spec/unit/alf-engine/test_compact.rb +33 -0
- data/spec/unit/alf-engine/test_concat.rb +38 -0
- data/spec/unit/alf-engine/test_defaults.rb +37 -0
- data/spec/unit/alf-engine/test_filter.rb +23 -0
- data/spec/unit/alf-engine/test_generator.rb +25 -0
- data/spec/unit/alf-engine/test_infer_heading.rb +58 -0
- data/spec/unit/alf-engine/test_rename.rb +24 -0
- data/spec/unit/alf-engine/test_set_attr.rb +38 -0
- data/spec/unit/alf-engine/test_sort.rb +32 -0
- data/spec/unit/alf-engine/test_to_array.rb +44 -0
- data/spec/unit/alf-engine/test_type_safe.rb +33 -0
- data/spec/unit/alf-engine/test_ungroup.rb +28 -0
- data/spec/unit/alf-engine/test_unwrap.rb +20 -0
- data/spec/unit/alf-engine/test_wrap.rb +26 -0
- data/spec/unit/alf-io/reader/class/test_by_mime_type.rb +32 -0
- data/spec/unit/alf-io/reader/input.csv +3 -0
- data/spec/unit/alf-io/reader/input.rb +2 -0
- data/spec/unit/alf-io/reader/test_csv.rb +67 -0
- data/spec/unit/alf-io/reader/test_initialize.rb +74 -0
- data/spec/unit/alf-io/reader/test_json.rb +30 -0
- data/spec/unit/alf-io/reader/test_rash.rb +32 -0
- data/spec/unit/alf-io/renderer/class/test_by_mime_type.rb +30 -0
- data/spec/unit/alf-io/renderer/test_csv.rb +68 -0
- data/spec/unit/alf-io/renderer/test_initialize.rb +40 -0
- data/spec/unit/alf-io/renderer/test_json.rb +42 -0
- data/spec/unit/alf-io/renderer/test_rash.rb +36 -0
- data/spec/unit/alf-io/renderer/test_text.rb +47 -0
- data/spec/unit/alf-io/renderer/test_yaml.rb +22 -0
- data/spec/unit/alf-io/renderer/text/test_cell.rb +35 -0
- data/spec/unit/alf-io/renderer/text/test_row.rb +30 -0
- data/spec/unit/alf-io/renderer/text/test_table.rb +39 -0
- data/spec/unit/alf-io/shared_examples/a_reader_class.rb +19 -0
- data/spec/unit/alf-io/shared_examples/a_renderer_class.rb +24 -0
- data/spec/unit/alf-io/support/test_proc_io.rb +18 -0
- data/spec/unit/alf-io/test_reader.rb +36 -0
- data/spec/unit/alf-io/test_renderer.rb +43 -0
- data/spec/unit/alf-lang/functional/test_aggregation.rb +26 -0
- data/spec/unit/alf-lang/functional/test_relation.rb +21 -0
- data/spec/unit/alf-lang/functional/test_tuple.rb +21 -0
- data/spec/unit/alf-lang/lispy/test_connection_bang.rb +26 -0
- data/spec/unit/alf-lang/lispy/test_parse.rb +38 -0
- data/spec/unit/alf-lang/lispy/test_to_s.rb +14 -0
- data/spec/unit/alf-lang/object_oriented/test_rendering_methods.rb +38 -0
- data/spec/unit/alf-lang/object_oriented/test_to_array.rb +45 -0
- data/spec/unit/alf-lang/object_oriented/test_to_rash.rb +34 -0
- data/spec/unit/alf-lang/object_oriented/test_tuple_extract.rb +51 -0
- data/spec/unit/alf-lang/test_predicates.rb +17 -0
- data/spec/unit/alf-optimizer/optimizer/test_optimizer.rb +37 -0
- data/spec/unit/alf-optimizer/optimizer/test_search.rb +48 -0
- data/spec/unit/alf-optimizer/restrict/test_on_autonum.rb +41 -0
- data/spec/unit/alf-optimizer/restrict/test_on_coerce.rb +42 -0
- data/spec/unit/alf-optimizer/restrict/test_on_join.rb +107 -0
- data/spec/unit/alf-optimizer/restrict/test_on_matching.rb +41 -0
- data/spec/unit/alf-optimizer/shared/a_pass_through_expression_for_restrict.rb +36 -0
- data/spec/unit/alf-optimizer/shared/a_split_able_expression_for_restrict.rb +46 -0
- data/spec/unit/alf-optimizer/shared/an_optimizable_expression_for_restrict.rb +39 -0
- data/spec/unit/alf-optimizer/shared/an_unoptimizable_expression_for_restrict.rb +24 -0
- data/spec/unit/alf-optimizer/test_autonum.rb +12 -0
- data/spec/unit/alf-optimizer/test_clip.rb +10 -0
- data/spec/unit/alf-optimizer/test_coerce.rb +12 -0
- data/spec/unit/alf-optimizer/test_compact.rb +10 -0
- data/spec/unit/alf-optimizer/test_defaults.rb +12 -0
- data/spec/unit/alf-optimizer/test_extend.rb +12 -0
- data/spec/unit/alf-optimizer/test_generator.rb +9 -0
- data/spec/unit/alf-optimizer/test_group.rb +12 -0
- data/spec/unit/alf-optimizer/test_infer_heading.rb +9 -0
- data/spec/unit/alf-optimizer/test_intersect.rb +10 -0
- data/spec/unit/alf-optimizer/test_minus.rb +10 -0
- data/spec/unit/alf-optimizer/test_project.rb +10 -0
- data/spec/unit/alf-optimizer/test_quota.rb +16 -0
- data/spec/unit/alf-optimizer/test_rank.rb +12 -0
- data/spec/unit/alf-optimizer/test_rename.rb +19 -0
- data/spec/unit/alf-optimizer/test_sort.rb +10 -0
- data/spec/unit/alf-optimizer/test_summarize.rb +15 -0
- data/spec/unit/alf-optimizer/test_union.rb +10 -0
- data/spec/unit/alf-optimizer/test_wrap.rb +12 -0
- data/spec/unit/alf-predicate/expr/test_to_proc.rb +20 -0
- data/spec/unit/alf-predicate/expr/test_to_ruby_code.rb +154 -0
- data/spec/unit/alf-predicate/factory/shared/a_comparison_factory_method.rb +35 -0
- data/spec/unit/alf-predicate/factory/shared/a_predicate_ast_node.rb +20 -0
- data/spec/unit/alf-predicate/factory/test_and.rb +15 -0
- data/spec/unit/alf-predicate/factory/test_between.rb +14 -0
- data/spec/unit/alf-predicate/factory/test_comp.rb +37 -0
- data/spec/unit/alf-predicate/factory/test_contradiction.rb +13 -0
- data/spec/unit/alf-predicate/factory/test_eq.rb +11 -0
- data/spec/unit/alf-predicate/factory/test_factor_predicate.rb +52 -0
- data/spec/unit/alf-predicate/factory/test_gt.rb +11 -0
- data/spec/unit/alf-predicate/factory/test_gte.rb +11 -0
- data/spec/unit/alf-predicate/factory/test_in.rb +14 -0
- data/spec/unit/alf-predicate/factory/test_literal.rb +15 -0
- data/spec/unit/alf-predicate/factory/test_lt.rb +11 -0
- data/spec/unit/alf-predicate/factory/test_lte.rb +11 -0
- data/spec/unit/alf-predicate/factory/test_native.rb +16 -0
- data/spec/unit/alf-predicate/factory/test_neq.rb +11 -0
- data/spec/unit/alf-predicate/factory/test_not.rb +15 -0
- data/spec/unit/alf-predicate/factory/test_or.rb +15 -0
- data/spec/unit/alf-predicate/factory/test_tautology.rb +14 -0
- data/spec/unit/alf-predicate/factory/test_var_ref.rb +15 -0
- data/spec/unit/alf-predicate/grammar/test_match.rb +95 -0
- data/spec/unit/alf-predicate/grammar/test_parse.rb +23 -0
- data/spec/unit/alf-predicate/grammar/test_sexpr.rb +105 -0
- data/spec/unit/alf-predicate/nodes/and/test_and_split.rb +68 -0
- data/spec/unit/alf-predicate/nodes/dyadic_comp/test_and_split.rb +47 -0
- data/spec/unit/alf-predicate/nodes/nadic_bool/test_free_variables.rb +16 -0
- data/spec/unit/alf-predicate/nodes/var_ref/test_and_split.rb +25 -0
- data/spec/unit/alf-predicate/nodes/var_ref/test_free_variables.rb +14 -0
- data/spec/unit/alf-predicate/nodes/var_ref/test_var_name.rb +14 -0
- data/spec/unit/alf-predicate/predicate/test_and_split.rb +59 -0
- data/spec/unit/alf-predicate/predicate/test_bool_and.rb +36 -0
- data/spec/unit/alf-predicate/predicate/test_bool_not.rb +70 -0
- data/spec/unit/alf-predicate/predicate/test_bool_or.rb +36 -0
- data/spec/unit/alf-predicate/predicate/test_coerce.rb +131 -0
- data/spec/unit/alf-predicate/predicate/test_constant_variables.rb +54 -0
- data/spec/unit/alf-predicate/predicate/test_contradiction.rb +28 -0
- data/spec/unit/alf-predicate/predicate/test_evaluate.rb +32 -0
- data/spec/unit/alf-predicate/predicate/test_factory_methods.rb +79 -0
- data/spec/unit/alf-predicate/predicate/test_free_variables.rb +16 -0
- data/spec/unit/alf-predicate/predicate/test_hash_and_equal.rb +28 -0
- data/spec/unit/alf-predicate/predicate/test_rename.rb +35 -0
- data/spec/unit/alf-predicate/predicate/test_tautology.rb +28 -0
- data/spec/unit/alf-predicate/predicate/test_to_proc.rb +16 -0
- data/spec/unit/alf-predicate/predicate/test_to_ruby_code.rb +16 -0
- data/spec/unit/alf-predicate/predicate/test_to_ruby_literal.rb +16 -0
- data/spec/unit/alf-predicate/test_predicate.rb +132 -0
- data/spec/unit/alf-relation/relation/class/test_coerce.rb +62 -0
- data/spec/unit/alf-relation/relation/class/test_type.rb +31 -0
- data/spec/unit/alf-relation/relation/factored-types/test_allbut.rb +34 -0
- data/spec/unit/alf-relation/relation/factored-types/test_coerce.rb +45 -0
- data/spec/unit/alf-relation/relation/factored-types/test_comparisons.rb +69 -0
- data/spec/unit/alf-relation/relation/factored-types/test_equality.rb +28 -0
- data/spec/unit/alf-relation/relation/factored-types/test_project.rb +34 -0
- data/spec/unit/alf-relation/relation/factored-types/test_rename.rb +12 -0
- data/spec/unit/alf-relation/relation/factored-types/test_split.rb +30 -0
- data/spec/unit/alf-relation/relation/factored-types/test_to_ruby_literal.rb +18 -0
- data/spec/unit/alf-relation/relation/factored-types/test_triple_equal.rb +42 -0
- data/spec/unit/alf-relation/relation/test_aggregation.rb +36 -0
- data/spec/unit/alf-relation/relation/test_equality.rb +34 -0
- data/spec/unit/alf-relation/relation/test_hash.rb +28 -0
- data/spec/unit/alf-relation/relation/test_heading.rb +17 -0
- data/spec/unit/alf-relation/relation/test_inspect.rb +20 -0
- data/spec/unit/alf-relation/relation/test_relation.rb +77 -0
- data/spec/unit/alf-relation/relation/test_relops.rb +62 -0
- data/spec/unit/alf-relation/relation/test_sugar.rb +40 -0
- data/spec/unit/alf-relation/relation/test_to_a.rb +37 -0
- data/spec/unit/alf-relation/relation/test_to_relation.rb +14 -0
- data/spec/unit/alf-relation/tuple/class/test_coerce.rb +29 -0
- data/spec/unit/alf-relation/tuple/class/test_type.rb +27 -0
- data/spec/unit/alf-relation/tuple/factored-types/test_allbut.rb +34 -0
- data/spec/unit/alf-relation/tuple/factored-types/test_coerce.rb +91 -0
- data/spec/unit/alf-relation/tuple/factored-types/test_comparisons.rb +69 -0
- data/spec/unit/alf-relation/tuple/factored-types/test_equality.rb +28 -0
- data/spec/unit/alf-relation/tuple/factored-types/test_project.rb +34 -0
- data/spec/unit/alf-relation/tuple/factored-types/test_rename.rb +12 -0
- data/spec/unit/alf-relation/tuple/factored-types/test_split.rb +30 -0
- data/spec/unit/alf-relation/tuple/factored-types/test_to_ruby_literal.rb +18 -0
- data/spec/unit/alf-relation/tuple/factored-types/test_triple_equal.rb +56 -0
- data/spec/unit/alf-relation/tuple/test_allbut.rb +14 -0
- data/spec/unit/alf-relation/tuple/test_attribute_accessors.rb +36 -0
- data/spec/unit/alf-relation/tuple/test_equality.rb +28 -0
- data/spec/unit/alf-relation/tuple/test_extend.rb +30 -0
- data/spec/unit/alf-relation/tuple/test_hash.rb +28 -0
- data/spec/unit/alf-relation/tuple/test_heading.rb +20 -0
- data/spec/unit/alf-relation/tuple/test_merge.rb +24 -0
- data/spec/unit/alf-relation/tuple/test_project.rb +18 -0
- data/spec/unit/alf-relation/tuple/test_remap.rb +14 -0
- data/spec/unit/alf-relation/tuple/test_rename.rb +14 -0
- data/spec/unit/alf-relation/tuple/test_split.rb +28 -0
- data/spec/unit/alf-relation/tuple/test_to_attr_list.rb +12 -0
- data/spec/unit/alf-relation/tuple/test_triple_equal.rb +17 -0
- data/spec/unit/alf-relvar/base/test_connection.rb +14 -0
- data/spec/unit/alf-relvar/base/test_delete.rb +35 -0
- data/spec/unit/alf-relvar/base/test_heading.rb +22 -0
- data/spec/unit/alf-relvar/base/test_insert.rb +23 -0
- data/spec/unit/alf-relvar/base/test_keys.rb +22 -0
- data/spec/unit/alf-relvar/base/test_lock.rb +22 -0
- data/spec/unit/alf-relvar/base/test_name.rb +14 -0
- data/spec/unit/alf-relvar/base/test_oo_lang.rb +28 -0
- data/spec/unit/alf-relvar/base/test_to_cog.rb +22 -0
- data/spec/unit/alf-relvar/base/test_to_lispy.rb +14 -0
- data/spec/unit/alf-relvar/base/test_to_relvar.rb +14 -0
- data/spec/unit/alf-relvar/base/test_to_s.rb +14 -0
- data/spec/unit/alf-relvar/base/test_update.rb +24 -0
- data/spec/unit/alf-relvar/read_only/test_type.rb +21 -0
- data/spec/unit/alf-relvar/shared/test_empty.rb +21 -0
- data/spec/unit/alf-relvar/shared/test_empty_bang.rb +31 -0
- data/spec/unit/alf-relvar/shared/test_not_empty_bang.rb +31 -0
- data/spec/unit/alf-relvar/shared/test_to_relation.rb +45 -0
- data/spec/unit/alf-relvar/shared/test_type.rb +21 -0
- data/spec/unit/alf-relvar/shared/test_upsert.rb +41 -0
- data/spec/unit/alf-relvar/virtual/test_connection.rb +14 -0
- data/spec/unit/alf-relvar/virtual/test_delete.rb +41 -0
- data/spec/unit/alf-relvar/virtual/test_expr.rb +14 -0
- data/spec/unit/alf-relvar/virtual/test_heading.rb +20 -0
- data/spec/unit/alf-relvar/virtual/test_insert.rb +28 -0
- data/spec/unit/alf-relvar/virtual/test_keys.rb +20 -0
- data/spec/unit/alf-relvar/virtual/test_oo_lang.rb +29 -0
- data/spec/unit/alf-relvar/virtual/test_to_cog.rb +18 -0
- data/spec/unit/alf-relvar/virtual/test_to_lispy.rb +20 -0
- data/spec/unit/alf-relvar/virtual/test_to_relvar.rb +14 -0
- data/spec/unit/alf-relvar/virtual/test_to_s.rb +15 -0
- data/spec/unit/alf-relvar/virtual/test_update.rb +29 -0
- data/spec/unit/alf-support/bindable/test_bind.rb +60 -0
- data/spec/unit/alf-support/bindable/test_bound.rb +31 -0
- data/spec/unit/alf-support/bindable/test_connection.rb +31 -0
- data/spec/unit/alf-support/bindable/test_connection_bang.rb +35 -0
- data/spec/unit/alf-support/config/test_helpers.rb +33 -0
- data/spec/unit/alf-support/config/test_merge.rb +34 -0
- data/spec/unit/alf-support/config/test_new.rb +52 -0
- data/spec/unit/alf-support/config/test_option.rb +27 -0
- data/spec/unit/alf-support/scope/test_branch.rb +28 -0
- data/spec/unit/alf-support/scope/test_evaluate.rb +42 -0
- data/spec/unit/alf-support/scope/test_initialize.rb +20 -0
- data/spec/unit/alf-support/scope/test_respond_to.rb +33 -0
- data/spec/unit/alf-support/test_class_name.rb +16 -0
- data/spec/unit/alf-support/test_coerce.rb +24 -0
- data/spec/unit/alf-support/test_registry.rb +63 -0
- data/spec/unit/alf-support/test_ruby_case.rb +16 -0
- data/spec/unit/alf-support/test_rubycase_name.rb +24 -0
- data/spec/unit/alf-support/test_symbolize_keys.rb +24 -0
- data/spec/unit/alf-support/test_to_lispy.rb +142 -0
- data/spec/unit/alf-support/test_to_ruby_literal.rb +26 -0
- data/spec/unit/alf-support/test_to_tuple.rb +29 -0
- data/spec/unit/alf-support/test_tuple_scope.rb +35 -0
- data/spec/unit/alf-support/test_unsymbolize_keys.rb +24 -0
- data/spec/unit/alf-support/tuple_scope/test_evaluate.rb +37 -0
- data/spec/unit/alf-support/tuple_scope/test_respond_to.rb +34 -0
- data/spec/unit/alf-types/attr_list/test_allbut.rb +28 -0
- data/spec/unit/alf-types/attr_list/test_ampersand.rb +20 -0
- data/spec/unit/alf-types/attr_list/test_coerce.rb +68 -0
- data/spec/unit/alf-types/attr_list/test_difference.rb +20 -0
- data/spec/unit/alf-types/attr_list/test_hash_and_eql.rb +47 -0
- data/spec/unit/alf-types/attr_list/test_include.rb +22 -0
- data/spec/unit/alf-types/attr_list/test_intersect.rb +36 -0
- data/spec/unit/alf-types/attr_list/test_or.rb +20 -0
- data/spec/unit/alf-types/attr_list/test_project.rb +52 -0
- data/spec/unit/alf-types/attr_list/test_project_tuple.rb +31 -0
- data/spec/unit/alf-types/attr_list/test_sameset.rb +36 -0
- data/spec/unit/alf-types/attr_list/test_set_compare.rb +59 -0
- data/spec/unit/alf-types/attr_list/test_split_tuple.rb +31 -0
- data/spec/unit/alf-types/attr_list/test_subset.rb +50 -0
- data/spec/unit/alf-types/attr_list/test_superset.rb +50 -0
- data/spec/unit/alf-types/attr_list/test_to_a.rb +14 -0
- data/spec/unit/alf-types/attr_list/test_to_ordering.rb +19 -0
- data/spec/unit/alf-types/attr_name/test_coerce.rb +16 -0
- data/spec/unit/alf-types/attr_name/test_triple_equal.rb +27 -0
- data/spec/unit/alf-types/heading/class/test_coerce.rb +40 -0
- data/spec/unit/alf-types/heading/class/test_infer.rb +26 -0
- data/spec/unit/alf-types/heading/test_allbut.rb +12 -0
- data/spec/unit/alf-types/heading/test_cardinality.rb +25 -0
- data/spec/unit/alf-types/heading/test_coerce.rb +57 -0
- data/spec/unit/alf-types/heading/test_comparison.rb +96 -0
- data/spec/unit/alf-types/heading/test_intersection.rb +29 -0
- data/spec/unit/alf-types/heading/test_merge.rb +25 -0
- data/spec/unit/alf-types/heading/test_project.rb +20 -0
- data/spec/unit/alf-types/heading/test_split.rb +20 -0
- data/spec/unit/alf-types/heading/test_to_h.rb +24 -0
- data/spec/unit/alf-types/heading/test_triple_equal.rb +40 -0
- data/spec/unit/alf-types/heading/test_union.rb +33 -0
- data/spec/unit/alf-types/keys/test_all.rb +17 -0
- data/spec/unit/alf-types/keys/test_ampersand.rb +26 -0
- data/spec/unit/alf-types/keys/test_any.rb +17 -0
- data/spec/unit/alf-types/keys/test_coerce.rb +64 -0
- data/spec/unit/alf-types/keys/test_compact.rb +21 -0
- data/spec/unit/alf-types/keys/test_empty.rb +20 -0
- data/spec/unit/alf-types/keys/test_first.rb +17 -0
- data/spec/unit/alf-types/keys/test_hash_and_equal.rb +33 -0
- data/spec/unit/alf-types/keys/test_if_empty.rb +40 -0
- data/spec/unit/alf-types/keys/test_map.rb +17 -0
- data/spec/unit/alf-types/keys/test_plus.rb +26 -0
- data/spec/unit/alf-types/keys/test_project.rb +29 -0
- data/spec/unit/alf-types/keys/test_reject.rb +17 -0
- data/spec/unit/alf-types/keys/test_rename.rb +21 -0
- data/spec/unit/alf-types/keys/test_select.rb +17 -0
- data/spec/unit/alf-types/ordering/test_coerce.rb +53 -0
- data/spec/unit/alf-types/ordering/test_compare.rb +29 -0
- data/spec/unit/alf-types/ordering/test_plus.rb +27 -0
- data/spec/unit/alf-types/ordering/test_sorter.rb +16 -0
- data/spec/unit/alf-types/ordering/test_to_attr_list.rb +14 -0
- data/spec/unit/alf-types/renaming/test_coerce.rb +24 -0
- data/spec/unit/alf-types/renaming/test_complete.rb +14 -0
- data/spec/unit/alf-types/renaming/test_invert.rb +14 -0
- data/spec/unit/alf-types/renaming/test_rename_attr_list.rb +24 -0
- data/spec/unit/alf-types/renaming/test_rename_tuple.rb +14 -0
- data/spec/unit/alf-types/renaming/test_to_attr_list.rb +14 -0
- data/spec/unit/alf-types/size/test_coerce.rb +23 -0
- data/spec/unit/alf-types/size/test_triple_equal.rb +25 -0
- data/spec/unit/alf-types/summarization/test_coerce.rb +31 -0
- data/spec/unit/alf-types/summarization/test_least.rb +11 -0
- data/spec/unit/alf-types/summarization/test_summarize.rb +15 -0
- data/spec/unit/alf-types/test_attr_list.rb +18 -0
- data/spec/unit/alf-types/test_class_methods.rb +59 -0
- data/spec/unit/alf-types/test_heading.rb +59 -0
- data/spec/unit/alf-types/test_ordering.rb +18 -0
- data/spec/unit/alf-types/test_renaming.rb +18 -0
- data/spec/unit/alf-types/test_summarization.rb +25 -0
- data/spec/unit/alf-types/test_tuple_computation.rb +28 -0
- data/spec/unit/alf-types/test_tuple_expression.rb +17 -0
- data/spec/unit/alf-types/tuple_computation/test_coerce.rb +54 -0
- data/spec/unit/alf-types/tuple_computation/test_to_attr_list.rb +15 -0
- data/spec/unit/alf-types/tuple_computation/test_to_heading.rb +29 -0
- data/spec/unit/alf-types/tuple_expression/test_coerce.rb +44 -0
- data/spec/unit/alf-types/tuple_expression/test_to_ruby_literal.rb +16 -0
- data/spec/unit/alf-types/type_check/test_triple_equal.rb +58 -0
- data/spec/unit/alf-update/deleter/test_autonum.rb +31 -0
- data/spec/unit/alf-update/deleter/test_clip.rb +18 -0
- data/spec/unit/alf-update/deleter/test_defaults.rb +31 -0
- data/spec/unit/alf-update/deleter/test_extend.rb +31 -0
- data/spec/unit/alf-update/deleter/test_group.rb +31 -0
- data/spec/unit/alf-update/deleter/test_intersect.rb +21 -0
- data/spec/unit/alf-update/deleter/test_project.rb +18 -0
- data/spec/unit/alf-update/deleter/test_rank.rb +31 -0
- data/spec/unit/alf-update/deleter/test_rename.rb +31 -0
- data/spec/unit/alf-update/deleter/test_restrict.rb +20 -0
- data/spec/unit/alf-update/deleter/test_sort.rb +18 -0
- data/spec/unit/alf-update/deleter/test_var_ref.rb +19 -0
- data/spec/unit/alf-update/deleter/test_wrap.rb +31 -0
- data/spec/unit/alf-update/inserter/test_autonum.rb +19 -0
- data/spec/unit/alf-update/inserter/test_clip.rb +21 -0
- data/spec/unit/alf-update/inserter/test_compact.rb +19 -0
- data/spec/unit/alf-update/inserter/test_defaults.rb +19 -0
- data/spec/unit/alf-update/inserter/test_extend.rb +19 -0
- data/spec/unit/alf-update/inserter/test_group.rb +26 -0
- data/spec/unit/alf-update/inserter/test_intersect.rb +22 -0
- data/spec/unit/alf-update/inserter/test_join.rb +21 -0
- data/spec/unit/alf-update/inserter/test_matching.rb +19 -0
- data/spec/unit/alf-update/inserter/test_minus.rb +19 -0
- data/spec/unit/alf-update/inserter/test_not_matching.rb +19 -0
- data/spec/unit/alf-update/inserter/test_project.rb +21 -0
- data/spec/unit/alf-update/inserter/test_rank.rb +19 -0
- data/spec/unit/alf-update/inserter/test_rename.rb +19 -0
- data/spec/unit/alf-update/inserter/test_restrict.rb +19 -0
- data/spec/unit/alf-update/inserter/test_sort.rb +19 -0
- data/spec/unit/alf-update/inserter/test_type_safe.rb +72 -0
- data/spec/unit/alf-update/inserter/test_union.rb +22 -0
- data/spec/unit/alf-update/inserter/test_var_ref.rb +18 -0
- data/spec/unit/alf-update/inserter/test_wrap.rb +25 -0
- data/spec/unit/alf-update/updater/test_var_ref.rb +19 -0
- data/spec/unit/alf-viewpoint/test_namespace.rb +23 -0
- data/spec/unit/alf-viewpoint/test_native.rb +26 -0
- data/spec/unit/alf-viewpoint/test_native_const.rb +16 -0
- data/spec/unit/alf-viewpoint/test_parse.rb +36 -0
- data/spec/unit/alf-viewpoint/test_parser.rb +22 -0
- data/spec/update_helper.rb +69 -0
- data/tasks/clean.rake +3 -0
- data/tasks/gem.rake +73 -0
- data/tasks/gh-pages.rake +69 -0
- data/tasks/integration_test.rake +43 -0
- data/tasks/regression_test.rake +44 -0
- data/tasks/unit_test.rake +44 -0
- data/tasks/yard.rake +51 -0
- metadata +1544 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Alf
|
3
|
+
module Lang
|
4
|
+
describe ObjectOriented, 'to_rash' do
|
5
|
+
|
6
|
+
include ObjectOriented.new(supplier_names_relation)
|
7
|
+
|
8
|
+
subject{
|
9
|
+
to_rash(options).each_line.map do |line|
|
10
|
+
::Kernel.eval(line)
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
before do
|
15
|
+
subject.should be_a(Array)
|
16
|
+
subject.each{|t| t.should be_a(Hash)}
|
17
|
+
end
|
18
|
+
|
19
|
+
after do
|
20
|
+
Relation(subject).should eq(_self_operand)
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when an ordering is specified' do
|
24
|
+
let(:ordering){ [[:name, :desc]] }
|
25
|
+
let(:options){ {:sort => ordering} }
|
26
|
+
it 'respects it' do
|
27
|
+
expected = supplier_names.sort.reverse
|
28
|
+
subject.map{|t| t[:name]}.should eq(expected)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Alf
|
3
|
+
module Lang
|
4
|
+
describe ObjectOriented, 'tuple_extract' do
|
5
|
+
|
6
|
+
def subject(&bl)
|
7
|
+
rel.extend(ObjectOriented.new(rel))
|
8
|
+
rel.tuple_extract(&bl)
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'on a singleton' do
|
12
|
+
let(:rel) { [{name: "Jones"}] }
|
13
|
+
let(:expected){ Tuple(name: "Jones") }
|
14
|
+
|
15
|
+
it 'returns the tuple' do
|
16
|
+
subject.should eq(expected)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'is aliased as tuple!' do
|
20
|
+
rel.extend(ObjectOriented.new(rel))
|
21
|
+
rel.tuple!.should eq(expected)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'on an empty relation' do
|
26
|
+
let(:rel){ [] }
|
27
|
+
|
28
|
+
it 'raises a NoSuchTupleError without block' do
|
29
|
+
lambda{
|
30
|
+
subject
|
31
|
+
}.should raise_error(NoSuchTupleError)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'yields if a block' do
|
35
|
+
subject{ {id: 12} }.should eq(Tuple(id: 12))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'on a relation with more than one tuple' do
|
40
|
+
let(:rel){ [{name: "Jones"}, {name: "Smith"}] }
|
41
|
+
|
42
|
+
it 'raises a NoSuchTupleError' do
|
43
|
+
lambda{
|
44
|
+
subject
|
45
|
+
}.should raise_error(NoSuchTupleError)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Alf
|
3
|
+
module Lang
|
4
|
+
describe Predicates do
|
5
|
+
include Predicates
|
6
|
+
|
7
|
+
it "eq should factor a predicate" do
|
8
|
+
eq(:x, 12).should be_a(Alf::Predicate)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "between should factor a predicate" do
|
12
|
+
between(:x, 2, 3).should be_a(Alf::Predicate)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'optimizer_helper'
|
2
|
+
module Alf
|
3
|
+
class Optimizer
|
4
|
+
describe Search do
|
5
|
+
|
6
|
+
let(:operand_1){ an_operand.with_heading(:id => String) }
|
7
|
+
|
8
|
+
# replaces project by clip
|
9
|
+
let(:processor_1){
|
10
|
+
lambda{|expr, search|
|
11
|
+
clip(search.apply(expr.operand), expr.attributes, :allbut => expr.allbut)
|
12
|
+
}
|
13
|
+
}
|
14
|
+
# adds an autonum before rename
|
15
|
+
let(:processor_2){
|
16
|
+
lambda{|expr, search| autonum(search.copy_and_apply(expr), :auto) }
|
17
|
+
}
|
18
|
+
let(:optimizer){
|
19
|
+
Optimizer.new.register(processor_1, Algebra::Project).
|
20
|
+
register(processor_2, Algebra::Rename)
|
21
|
+
}
|
22
|
+
|
23
|
+
subject{ optimizer.call(expr) }
|
24
|
+
|
25
|
+
let(:expr){
|
26
|
+
(project (rename (project operand_1, [:bar]), :foo => :bar), [:foo])
|
27
|
+
}
|
28
|
+
|
29
|
+
let(:expected){
|
30
|
+
(clip (autonum (rename (clip operand_1, [:bar]), :foo => :bar), :auto), [:foo])
|
31
|
+
}
|
32
|
+
|
33
|
+
it{ should eq(expected) }
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'optimizer_helper'
|
2
|
+
module Alf
|
3
|
+
class Optimizer
|
4
|
+
describe Search do
|
5
|
+
|
6
|
+
let(:search){
|
7
|
+
Search.new(processor, Algebra::Project)
|
8
|
+
}
|
9
|
+
|
10
|
+
let(:new_operand){ an_operand }
|
11
|
+
|
12
|
+
let(:processor){
|
13
|
+
lambda{|expr, s|
|
14
|
+
raise unless expr.is_a?(Algebra::Project)
|
15
|
+
raise unless s == search
|
16
|
+
new_operand
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
subject{ search.call(expr) }
|
21
|
+
|
22
|
+
context "when the expression is a Project" do
|
23
|
+
let(:expr){ project(an_operand, [:foo]) }
|
24
|
+
|
25
|
+
it{ should be(new_operand) }
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when the expression has no Project at all" do
|
29
|
+
let(:expr){ clip(an_operand, [:foo]) }
|
30
|
+
|
31
|
+
it{ should eq(expr) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when the expression has a Project somewhere" do
|
35
|
+
let(:expr){ clip(project(an_operand, [:foo]), [:foo]) }
|
36
|
+
|
37
|
+
specify "the top one should be a Clip" do
|
38
|
+
subject.should be_a(Algebra::Clip)
|
39
|
+
end
|
40
|
+
|
41
|
+
specify "the internal one has been seen by processor" do
|
42
|
+
subject.operand.should be(new_operand)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'optimizer_helper'
|
2
|
+
module Alf
|
3
|
+
class Optimizer
|
4
|
+
describe Restrict, "on_autonum" do
|
5
|
+
|
6
|
+
let(:inside){ an_operand }
|
7
|
+
let(:expr) { restrict(autonum(inside, :auto), predicate) }
|
8
|
+
|
9
|
+
subject{ Restrict.new.call(expr) }
|
10
|
+
|
11
|
+
context 'when the restriction does not apply to auto at all' do
|
12
|
+
let(:predicate){ comp(:x => 12) }
|
13
|
+
let(:expected) { autonum(restrict(inside, predicate)) }
|
14
|
+
|
15
|
+
it{ should eq(expected) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when the restriction applies to auto only' do
|
19
|
+
let(:predicate){ comp(:auto => 12) }
|
20
|
+
|
21
|
+
it{ should eq(expr) }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when the restriction applies to auto and other fields in a AND' do
|
25
|
+
let(:predicate){ comp(:auto => 12, :x => 13) }
|
26
|
+
let(:expected){
|
27
|
+
restrict(autonum(restrict(inside, comp(:x => 13)), :auto), comp(:auto => 12))
|
28
|
+
}
|
29
|
+
|
30
|
+
it{ should eq(expected) }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when the restriction applies to auto and other fields in a OR' do
|
34
|
+
let(:predicate){ comp(:auto => 12) | comp(:x => 13) }
|
35
|
+
|
36
|
+
it{ should eq(expr) }
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'optimizer_helper'
|
2
|
+
module Alf
|
3
|
+
class Optimizer
|
4
|
+
describe Restrict, "on_coerce" do
|
5
|
+
|
6
|
+
let(:inside) { an_operand }
|
7
|
+
let(:coercion){ Heading.coerce(:x => Integer) }
|
8
|
+
let(:expr) { restrict(coerce(inside, coercion), predicate) }
|
9
|
+
|
10
|
+
subject{ Restrict.new.call(expr) }
|
11
|
+
|
12
|
+
context 'when the restriction does not apply to x' do
|
13
|
+
let(:predicate){ comp(:y => 12) }
|
14
|
+
let(:expected) { coerce(restrict(inside, predicate), coercion) }
|
15
|
+
|
16
|
+
it{ should eq(expected) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when the restriction applies to x' do
|
20
|
+
let(:predicate){ comp(:x => 12) }
|
21
|
+
|
22
|
+
it{ should eq(expr) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when the restriction applies to x and other fields in a COMP' do
|
26
|
+
let(:predicate){ comp(:y => 12, :x => 13) }
|
27
|
+
let(:expected){
|
28
|
+
restrict(coerce(restrict(inside, comp(:y => 12)), coercion), comp(:x => 13))
|
29
|
+
}
|
30
|
+
|
31
|
+
it{ should eq(expected) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when the restriction applies to x and other fields in a OR' do
|
35
|
+
let(:predicate){ comp(:y => 12) | comp(:x => 13) }
|
36
|
+
|
37
|
+
it{ should eq(expr) }
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'optimizer_helper'
|
2
|
+
module Alf
|
3
|
+
class Optimizer
|
4
|
+
describe Restrict, "on_join" do
|
5
|
+
|
6
|
+
let(:left) { an_operand.with_heading(id: Integer, name: String) }
|
7
|
+
let(:right){ an_operand.with_heading(id: Integer, city: String) }
|
8
|
+
|
9
|
+
let(:id_pred) { comp(id: 1) }
|
10
|
+
let(:name_pred){ comp(name: 'foo') }
|
11
|
+
let(:city_pred){ comp(city: 'bar') }
|
12
|
+
|
13
|
+
let(:expr) { restrict(join(left, right), predicate) }
|
14
|
+
let(:optimized){ Restrict.new.call(expr) }
|
15
|
+
let(:expected) { Support.to_lispy(expected_rewrite) }
|
16
|
+
|
17
|
+
subject{ Support.to_lispy(optimized) }
|
18
|
+
|
19
|
+
# not analyzable
|
20
|
+
context 'when the restriction is a native one' do
|
21
|
+
let(:predicate){ Predicate.native(->{ id > 12 }) }
|
22
|
+
let(:expected_rewrite){ restrict(join(left, right), predicate) }
|
23
|
+
|
24
|
+
it 'should be as expected' do
|
25
|
+
optimized.should be_a(Algebra::Restrict)
|
26
|
+
optimized.operand.should be(expr.operand)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# covered by one restriction pushed
|
31
|
+
|
32
|
+
context 'when the restriction applies to left only' do
|
33
|
+
let(:predicate){ name_pred }
|
34
|
+
let(:expected_rewrite){ join(restrict(left, predicate), right) }
|
35
|
+
|
36
|
+
it{ should eq(expected) }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when the restriction applies to right only' do
|
40
|
+
let(:predicate){ city_pred }
|
41
|
+
let(:expected_rewrite){ join(left, restrict(right, predicate)) }
|
42
|
+
|
43
|
+
it{ should eq(expected) }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when the restriction is a OR on left' do
|
47
|
+
let(:predicate){ id_pred | name_pred }
|
48
|
+
let(:expected_rewrite){ join(restrict(left, predicate), right) }
|
49
|
+
|
50
|
+
it{ should eq(expected) }
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when the restriction is a OR on right' do
|
54
|
+
let(:predicate){ id_pred | city_pred }
|
55
|
+
let(:expected_rewrite){ join(left, restrict(right, predicate)) }
|
56
|
+
|
57
|
+
it{ should eq(expected) }
|
58
|
+
end
|
59
|
+
|
60
|
+
# covered by the conjunction of pushed restrictions
|
61
|
+
|
62
|
+
context 'when the restriction applies to both operands' do
|
63
|
+
let(:predicate){ id_pred }
|
64
|
+
let(:expected_rewrite){ join(restrict(left, predicate), restrict(right, predicate)) }
|
65
|
+
|
66
|
+
it{ should eq(expected) }
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when the restriction is a AND on left' do
|
70
|
+
let(:predicate){ id_pred & name_pred }
|
71
|
+
let(:expected_rewrite){ join(restrict(left, predicate), restrict(right, id_pred)) }
|
72
|
+
|
73
|
+
it{ should eq(expected) }
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when the restriction is a AND to be splitted' do
|
77
|
+
let(:predicate){ city_pred & name_pred }
|
78
|
+
let(:expected_rewrite){ join(restrict(left, name_pred), restrict(right, city_pred)) }
|
79
|
+
|
80
|
+
it{ should eq(expected) }
|
81
|
+
end
|
82
|
+
|
83
|
+
# not fully covered by a conjunction
|
84
|
+
context 'when the restriction is an un-splittable OR' do
|
85
|
+
let(:predicate){ city_pred | name_pred }
|
86
|
+
let(:expected_rewrite){ restrict(join(left, right), predicate) }
|
87
|
+
|
88
|
+
it{ should eq(expected) }
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'when the restriction is an un-splittable AND/OR' do
|
92
|
+
let(:predicate){ (city_pred & name_pred) | id_pred }
|
93
|
+
let(:expected_rewrite){ restrict(join(left, right), predicate) }
|
94
|
+
|
95
|
+
it{ should eq(expected) }
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when the restriction is a partly un-splittable OR' do
|
99
|
+
let(:predicate){ id_pred & (city_pred | name_pred) }
|
100
|
+
let(:expected_rewrite){ restrict(join(restrict(left, id_pred), restrict(right, id_pred)), city_pred | name_pred) }
|
101
|
+
|
102
|
+
it{ should eq(expected) }
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'optimizer_helper'
|
2
|
+
module Alf
|
3
|
+
class Optimizer
|
4
|
+
describe Restrict, "on_matching" do
|
5
|
+
|
6
|
+
let(:left) { an_operand.with_heading(id: Integer, name: String) }
|
7
|
+
let(:right){ an_operand.with_heading(id: Integer, city: String) }
|
8
|
+
|
9
|
+
let(:id_pred) { comp(id: 1) }
|
10
|
+
let(:name_pred){ comp(name: 'foo') }
|
11
|
+
|
12
|
+
let(:expr) { restrict(matching(left, right), predicate) }
|
13
|
+
let(:optimized){ Restrict.new.call(expr) }
|
14
|
+
let(:expected) { Support.to_lispy(expected_rewrite) }
|
15
|
+
|
16
|
+
subject{ Support.to_lispy(optimized) }
|
17
|
+
|
18
|
+
context 'when the restriction does not touch right attributes' do
|
19
|
+
let(:predicate){ name_pred }
|
20
|
+
let(:expected_rewrite){ matching(restrict(left, predicate), right) }
|
21
|
+
|
22
|
+
it{ should eq(expected) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when the restriction does touch right attributes' do
|
26
|
+
let(:predicate){ id_pred }
|
27
|
+
let(:expected_rewrite){ matching(restrict(left, predicate), restrict(right, predicate)) }
|
28
|
+
|
29
|
+
it{ should eq(expected) }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when the restriction partly touches right attributes' do
|
33
|
+
let(:predicate){ id_pred & name_pred }
|
34
|
+
let(:expected_rewrite){ matching(restrict(left, predicate), restrict(right, id_pred)) }
|
35
|
+
|
36
|
+
it{ should eq(expected) }
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
shared_examples_for "a pass-through expression for restrict" do
|
2
|
+
|
3
|
+
let(:the_predicate){
|
4
|
+
defined?(predicate) ? predicate : Alf::Predicate.native(lambda{})
|
5
|
+
}
|
6
|
+
|
7
|
+
let(:restriction){
|
8
|
+
restrict(subject, the_predicate)
|
9
|
+
}
|
10
|
+
|
11
|
+
let(:optimized){
|
12
|
+
Alf::Optimizer::Restrict.new.call(restriction)
|
13
|
+
}
|
14
|
+
|
15
|
+
# before(:all) do
|
16
|
+
# puts Support.to_lispy(restriction)
|
17
|
+
# puts Support.to_lispy(optimized)
|
18
|
+
# end
|
19
|
+
|
20
|
+
specify "optimized leads to the initial operator" do
|
21
|
+
optimized.should be_a(subject.class)
|
22
|
+
end
|
23
|
+
|
24
|
+
specify "optimized signature is unchanged" do
|
25
|
+
optimized.signature.collect_on(subject).should eq(subject.signature.collect_on(subject))
|
26
|
+
end
|
27
|
+
|
28
|
+
specify "the restriction has been pushed with same predicate" do
|
29
|
+
optimized.operands.each do |operand|
|
30
|
+
operand.should be_a(Alf::Algebra::Restrict)
|
31
|
+
repl = defined?(replaced_predicate) ? replaced_predicate : restriction.predicate
|
32
|
+
operand.predicate.should eq(repl)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|