alf-core 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -8
- data/Gemfile.lock +9 -17
- data/examples/operators/frame.alf +2 -0
- data/lib/alf-core.rb +24 -22
- data/lib/{alf-adapter/alf → alf}/adapter.rb +0 -0
- data/lib/{alf-adapter/alf → alf}/adapter/connection.rb +4 -10
- data/lib/{alf-adapter/alf → alf}/adapter/connection/schema_cached.rb +0 -0
- data/lib/{alf-adapter-fs/alf → alf}/adapter/folder.rb +0 -0
- data/lib/{alf-adapter-fs/alf → alf}/adapter/folder/connection.rb +3 -2
- data/lib/{alf-adapter-fs/alf → alf}/adapter/fs.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator.rb +12 -9
- data/lib/{alf-aggregator/alf → alf}/aggregator/avg.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/collect.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/concat.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/count.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/max.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/min.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/stddev.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/sum.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/variance.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra.rb +1 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operand.rb +13 -6
- data/lib/{alf-algebra/alf → alf}/algebra/operand/fake.rb +18 -4
- data/lib/alf/algebra/operand/named.rb +65 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operand/proxy.rb +7 -3
- data/lib/{alf-algebra/alf → alf}/algebra/operator.rb +40 -12
- data/lib/{alf-algebra/alf → alf}/algebra/operator/autonum.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/clip.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/coerce.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/compact.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/defaults.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/extend.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/frame.rb +12 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/generator.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/group.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/hierarchize.rb +8 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operator/intersect.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/join.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/matching.rb +10 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/minus.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/not_matching.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/page.rb +11 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/project.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/quota.rb +12 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/rank.rb +11 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/rename.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/restrict.rb +12 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/sort.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/summarize.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/ungroup.rb +11 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/union.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/unwrap.rb +13 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/wrap.rb +10 -1
- data/lib/alf/algebra/shortcut.rb +40 -0
- data/lib/alf/algebra/shortcut/allbut.rb +25 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support.rb +2 -1
- data/lib/{alf-algebra/alf → alf}/algebra/support/binary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/classification.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/compiler.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/experimental.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/non_relational.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/nullary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/relational.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/rewriter.rb +4 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/signature.rb +7 -8
- data/lib/alf/algebra/support/type_check.rb +51 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/unary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/visitor.rb +2 -1
- data/lib/{alf-algebra/alf → alf}/algebra/support/with_ordering.rb +0 -0
- data/lib/alf/compiler.rb +57 -0
- data/lib/alf/compiler/cog.rb +39 -0
- data/lib/alf/compiler/default.rb +168 -0
- data/lib/alf/compiler/plan.rb +77 -0
- data/lib/{alf-core → alf/core}/loader.rb +0 -0
- data/lib/{alf-core → alf/core}/version.rb +1 -1
- data/lib/{alf-database/alf → alf}/database.rb +0 -0
- data/lib/{alf-database/alf → alf}/database/connection.rb +10 -52
- data/lib/{alf-database/alf → alf}/database/options.rb +2 -5
- data/lib/{alf-core → alf}/dsl.rb +4 -4
- data/lib/{alf-engine/alf → alf}/engine.rb +0 -2
- data/lib/{alf-engine/alf → alf}/engine/aggregate.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/autonum.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/clip.rb +10 -2
- data/lib/{alf-engine/alf → alf}/engine/coerce.rb +6 -2
- data/lib/alf/engine/cog.rb +58 -0
- data/lib/{alf-engine/alf → alf}/engine/compact.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/compact/set.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/compact/uniq.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/concat.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/defaults.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/filter.rb +8 -4
- data/lib/{alf-engine/alf → alf}/engine/generator.rb +6 -2
- data/lib/alf/engine/group.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/group/hash.rb +11 -2
- data/lib/{alf-engine/alf → alf}/engine/hierarchize.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/infer_heading.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/join.rb +0 -0
- data/lib/{alf-engine/alf → alf}/engine/join/hash.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/leaf.rb +7 -3
- data/lib/{alf-engine/alf → alf}/engine/materialize.rb +5 -1
- data/lib/{alf-engine/alf → alf}/engine/materialize/array.rb +3 -2
- data/lib/{alf-engine/alf → alf}/engine/materialize/hash.rb +3 -2
- data/lib/alf/engine/quota.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/quota/cesure.rb +8 -3
- data/lib/alf/engine/rank.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/rank/cesure.rb +8 -3
- data/lib/{alf-engine/alf → alf}/engine/rename.rb +6 -2
- data/lib/alf/engine/semi.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/semi/hash.rb +7 -2
- data/lib/{alf-engine/alf → alf}/engine/set_attr.rb +8 -4
- data/lib/alf/engine/sort.rb +13 -0
- data/lib/{alf-engine/alf → alf}/engine/sort/in_memory.rb +12 -2
- data/lib/alf/engine/summarize.rb +13 -0
- data/lib/{alf-engine/alf → alf}/engine/summarize/cesure.rb +5 -4
- data/lib/{alf-engine/alf → alf}/engine/summarize/hash.rb +3 -2
- data/lib/{alf-engine/alf → alf}/engine/support/cesure.rb +0 -0
- data/lib/{alf-engine/alf → alf}/engine/take.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/to_array.rb +13 -5
- data/lib/{alf-engine/alf → alf}/engine/type_safe.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/ungroup.rb +7 -2
- data/lib/{alf-engine/alf → alf}/engine/unwrap.rb +11 -5
- data/lib/{alf-engine/alf → alf}/engine/wrap.rb +6 -2
- data/lib/{alf-core → alf}/errors.rb +2 -3
- data/lib/{alf-core → alf}/ext.rb +0 -0
- data/lib/{alf-core → alf}/ext/domain/heading_based.rb +5 -0
- data/lib/alf/facade.rb +53 -0
- data/lib/{alf-lang/alf → alf}/lang.rb +1 -1
- data/lib/{alf-lang/alf → alf}/lang/functional.rb +0 -4
- data/lib/{alf-lang/alf → alf}/lang/object_oriented.rb +0 -0
- data/lib/{alf-lang/alf → alf}/lang/oo/aggregation_methods.rb +1 -1
- data/lib/{alf-lang/alf → alf}/lang/oo/algebra_methods.rb +0 -12
- data/lib/{alf-lang/alf → alf}/lang/oo/rendering_methods.rb +1 -1
- data/lib/alf/lang/parser.rb +9 -0
- data/lib/alf/lang/parser/lispy.rb +63 -0
- data/lib/alf/lang/parser/safer.rb +69 -0
- data/lib/{alf-lang/alf → alf}/lang/predicates.rb +1 -1
- data/lib/{alf-optimizer/alf → alf}/optimizer.rb +15 -7
- data/lib/alf/optimizer/project.rb +182 -0
- data/lib/{alf-optimizer/alf → alf}/optimizer/restrict.rb +48 -50
- data/lib/{alf-predicate/alf → alf}/predicate.rb +16 -12
- data/lib/{alf-predicate/alf → alf}/predicate/factory.rb +13 -8
- data/lib/{alf-predicate/alf → alf}/predicate/grammar.rb +2 -5
- data/lib/{alf-predicate/alf → alf}/predicate/grammar.sexp.yml +11 -7
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/and.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/contradiction.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/dyadic_comp.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/eq.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/expr.rb +10 -5
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/gt.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/gte.rb +0 -0
- data/lib/{alf-predicate/alf/predicate/nodes/var_ref.rb → alf/predicate/nodes/identifier.rb} +3 -3
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/in.rb +2 -2
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/literal.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/lt.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/lte.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/nadic_bool.rb +0 -0
- data/lib/alf/predicate/nodes/native.rb +32 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/neq.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/not.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/or.rb +0 -0
- data/lib/{alf-predicate/alf/predicate/nodes/native.rb → alf/predicate/nodes/qualified_identifier.rb} +8 -4
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/tautology.rb +0 -0
- data/lib/alf/predicate/processors.rb +3 -0
- data/lib/alf/predicate/processors/qualifier.rb +25 -0
- data/lib/alf/predicate/processors/renamer.rb +27 -0
- data/lib/{alf-predicate/alf → alf}/predicate/processors/to_ruby_code.rb +6 -11
- data/lib/{alf-io/alf → alf}/reader.rb +11 -2
- data/lib/{alf-io/alf → alf}/reader/csv.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/json.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/rash.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/ruby.rb +0 -0
- data/lib/alf/reader/yaml.rb +25 -0
- data/lib/{alf-relation/alf → alf}/relation.rb +12 -2
- data/lib/{alf-relvar/alf → alf}/relvar.rb +14 -21
- data/lib/alf/relvar/base.rb +35 -0
- data/lib/{alf-relvar/alf → alf}/relvar/fake.rb +3 -2
- data/lib/{alf-relvar/alf → alf}/relvar/read_only.rb +6 -30
- data/lib/{alf-relvar/alf → alf}/relvar/virtual.rb +0 -31
- data/lib/{alf-io/alf → alf}/renderer.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/csv.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/json.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/rash.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/text.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/yaml.rb +2 -2
- data/lib/{alf-support/alf → alf}/support.rb +2 -1
- data/lib/{alf-support/alf → alf}/support/coerce.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/config.rb +0 -0
- data/lib/{alf-io/alf → alf}/support/csv_utils.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/dot_utils.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/miscellaneous.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/ordered_set.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/registry.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/scope.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/to_lispy.rb +6 -1
- data/lib/{alf-support/alf → alf}/support/to_ruby_literal.rb +0 -0
- data/lib/alf/support/tree.rb +51 -0
- data/lib/{alf-support/alf → alf}/support/tuple_scope.rb +9 -1
- data/lib/{alf-relation/alf → alf}/tuple.rb +1 -1
- data/lib/{alf-types/alf → alf}/types.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/attr_list.rb +2 -2
- data/lib/{alf-types/alf → alf}/types/attr_name.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/boolean.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/heading.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/keys.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/ordering.rb +7 -1
- data/lib/{alf-types/alf → alf}/types/renaming.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/selection.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/selector.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/size.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/summarization.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/tuple_computation.rb +13 -4
- data/lib/{alf-types/alf → alf}/types/tuple_expression.rb +6 -19
- data/lib/{alf-types/alf → alf}/types/type_check.rb +1 -0
- data/lib/{alf-update/alf → alf}/update.rb +0 -0
- data/lib/{alf-update/alf → alf}/update/deleter.rb +0 -3
- data/lib/{alf-update/alf → alf}/update/inserter.rb +1 -7
- data/lib/{alf-update/alf → alf}/update/updater.rb +0 -2
- data/lib/{alf-viewpoint/alf → alf}/viewpoint.rb +9 -7
- data/lib/{alf-viewpoint/alf → alf}/viewpoint/metadata.rb +5 -2
- data/spec/compiler_helper.rb +20 -0
- data/spec/integration/relation/test_to_array.rb +6 -6
- data/spec/integration/test_examples.rb +14 -6
- data/spec/shared/a_cog.rb +8 -4
- data/spec/shared/a_valid_type_implementation.rb +4 -7
- data/spec/spec_helper.rb +9 -5
- data/spec/type_check_helper.rb +1 -0
- data/spec/unit/alf-adapter/shared_examples/an_adapter_with_readable_cogs.rb +1 -1
- data/spec/unit/alf-aggregator/test_concat.rb +8 -0
- data/spec/unit/alf-algebra/operand/named/test_hash_and_equal.rb +53 -0
- data/spec/unit/alf-algebra/operand/named/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operand/named/test_to_ascii_tree.rb +18 -0
- data/spec/unit/alf-algebra/operand/named/test_to_cog.rb +24 -0
- data/spec/unit/alf-algebra/operand/named/test_to_relvar.rb +1 -1
- data/spec/unit/alf-algebra/operand/named/test_type_check.rb +38 -0
- data/spec/unit/alf-algebra/operand/proxy/test_to_cog.rb +42 -0
- data/spec/unit/alf-algebra/operand/test_coerce.rb +0 -6
- data/spec/unit/alf-algebra/operand/test_proxy.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_key_preserving.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/autonum/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/clip/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/coerce/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/commons/test_resulting_type.rb +20 -0
- data/spec/unit/alf-algebra/operator/commons/test_to_ascii_tree.rb +40 -0
- data/spec/unit/alf-algebra/operator/extend/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/frame/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/group/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/operator/hierarchize/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/intersect/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/join/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/matching/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operator/matching/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/minus/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/not_matching/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/page/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/operator/project/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/quota/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/rank/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/rename/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/restrict/test_type_check.rb +46 -0
- data/spec/unit/alf-algebra/operator/shared/test_to_cog.rb +34 -0
- data/spec/unit/alf-algebra/operator/sort/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/summarize/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/test_hash_and_equal.rb +59 -0
- data/spec/unit/alf-algebra/operator/ungroup/test_type_check.rb +44 -0
- data/spec/unit/alf-algebra/operator/union/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/unwrap/test_type_check.rb +44 -0
- data/spec/unit/alf-algebra/operator/wrap/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/support/signature/test_to_lispy.rb +24 -9
- data/spec/unit/alf-algebra/support/test_non_relational.rb +1 -2
- data/spec/unit/alf-algebra/support/test_relational.rb +1 -1
- data/spec/unit/alf-compiler/default/test_allbut.rb +65 -0
- data/spec/unit/alf-compiler/default/test_autonum.rb +30 -0
- data/spec/unit/alf-compiler/default/test_clip.rb +30 -0
- data/spec/unit/alf-compiler/default/test_coerce.rb +30 -0
- data/spec/unit/alf-compiler/default/test_compact.rb +26 -0
- data/spec/unit/alf-compiler/default/test_completude.rb +16 -0
- data/spec/unit/alf-compiler/default/test_defaults.rb +50 -0
- data/spec/unit/alf-compiler/default/test_extend.rb +34 -0
- data/spec/unit/alf-compiler/default/test_frame.rb +77 -0
- data/spec/unit/alf-compiler/default/test_generator.rb +30 -0
- data/spec/unit/alf-compiler/default/test_group.rb +38 -0
- data/spec/unit/alf-compiler/default/test_hierarchize.rb +40 -0
- data/spec/unit/alf-compiler/default/test_intersect.rb +34 -0
- data/spec/unit/alf-compiler/default/test_join.rb +34 -0
- data/spec/unit/alf-compiler/default/test_matching.rb +38 -0
- data/spec/unit/alf-compiler/default/test_minus.rb +38 -0
- data/spec/unit/alf-compiler/default/test_not_matching.rb +38 -0
- data/spec/unit/alf-compiler/default/test_page.rb +91 -0
- data/spec/unit/alf-compiler/default/test_project.rb +76 -0
- data/spec/unit/alf-compiler/default/test_quota.rb +88 -0
- data/spec/unit/alf-compiler/default/test_rank.rb +71 -0
- data/spec/unit/alf-compiler/default/test_rename.rb +30 -0
- data/spec/unit/alf-compiler/default/test_restrict.rb +34 -0
- data/spec/unit/alf-compiler/default/test_sort.rb +81 -0
- data/spec/unit/alf-compiler/default/test_summarize.rb +85 -0
- data/spec/unit/alf-compiler/default/test_ungroup.rb +30 -0
- data/spec/unit/alf-compiler/default/test_union.rb +36 -0
- data/spec/unit/alf-compiler/default/test_unwrap.rb +30 -0
- data/spec/unit/alf-compiler/default/test_wrap.rb +38 -0
- data/spec/unit/alf-compiler/shared/compiled_examples.rb +111 -0
- data/spec/unit/alf-compiler/test_principle.rb +332 -0
- data/spec/unit/alf-core/test_aggregator.rb +0 -24
- data/spec/unit/alf-database/connection/test_parse.rb +0 -49
- data/spec/unit/alf-database/connection/test_relvar.rb +1 -9
- data/spec/unit/alf-database/options/test_parser.rb +23 -0
- data/spec/unit/alf-engine/cog/test_to_ascii_tree.rb +14 -0
- data/spec/unit/alf-engine/test_aggregate.rb +2 -2
- data/spec/unit/alf-engine/test_filter.rb +1 -1
- data/spec/unit/alf-engine/test_to_array.rb +16 -2
- data/spec/unit/alf-io/reader/test_yaml.rb +30 -0
- data/spec/unit/alf-io/renderer/test_yaml.rb +11 -0
- data/spec/unit/alf-lang/functional/test_aggregation.rb +18 -4
- data/spec/unit/alf-lang/parser/lispy/test_connection_bang.rb +28 -0
- data/spec/unit/alf-lang/parser/lispy/test_parse.rb +38 -0
- data/spec/unit/alf-lang/parser/lispy/test_to_s.rb +16 -0
- data/spec/unit/alf-lang/parser/safer/safe.txt +5 -0
- data/spec/unit/alf-lang/parser/safer/test_parse.rb +82 -0
- data/spec/unit/alf-lang/parser/safer/unsafe.txt +14 -0
- data/spec/unit/alf-optimizer/restrict/test_on_autonum.rb +1 -1
- data/spec/unit/alf-optimizer/test_quota.rb +1 -1
- data/spec/unit/alf-optimizer/test_rename.rb +7 -0
- data/spec/unit/alf-optimizer/test_summarize.rb +1 -1
- data/spec/unit/alf-predicate/expr/test_to_proc.rb +4 -6
- data/spec/unit/alf-predicate/expr/test_to_ruby_code.rb +23 -23
- data/spec/unit/alf-predicate/factory/shared/a_comparison_factory_method.rb +3 -3
- data/spec/unit/alf-predicate/factory/test_between.rb +1 -1
- data/spec/unit/alf-predicate/factory/test_comp.rb +3 -3
- data/spec/unit/alf-predicate/factory/test_factor_predicate.rb +3 -3
- data/spec/unit/alf-predicate/factory/{test_var_ref.rb → test_identifier.rb} +4 -4
- data/spec/unit/alf-predicate/factory/test_in.rb +1 -1
- data/spec/unit/alf-predicate/factory/test_native.rb +9 -4
- data/spec/unit/alf-predicate/factory/test_qualified_identifier.rb +17 -0
- data/spec/unit/alf-predicate/grammar/test_match.rb +9 -9
- data/spec/unit/alf-predicate/grammar/test_sexpr.rb +11 -11
- data/spec/unit/alf-predicate/nodes/{var_ref → identifier}/test_and_split.rb +2 -2
- data/spec/unit/alf-predicate/nodes/{var_ref → identifier}/test_free_variables.rb +2 -2
- data/spec/unit/alf-predicate/nodes/identifier/test_name.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_and_split.rb +25 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_free_variables.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_name.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_qualifier.rb +14 -0
- data/spec/unit/alf-predicate/predicate/test_and_split.rb +4 -4
- data/spec/unit/alf-predicate/predicate/test_bool_and.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_bool_not.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_bool_or.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_coerce.rb +9 -8
- data/spec/unit/alf-predicate/predicate/test_contradiction.rb +2 -2
- data/spec/unit/alf-predicate/predicate/test_factory_methods.rb +12 -12
- data/spec/unit/alf-predicate/predicate/test_qualify.rb +36 -0
- data/spec/unit/alf-predicate/predicate/test_rename.rb +58 -15
- data/spec/unit/alf-predicate/predicate/test_tautology.rb +2 -2
- data/spec/unit/alf-predicate/predicate/test_to_ruby_code.rb +8 -2
- data/spec/unit/alf-predicate/predicate/test_to_ruby_literal.rb +1 -1
- data/spec/unit/alf-predicate/test_predicate.rb +7 -8
- data/spec/unit/alf-relation/relation/class/test_dum.rb +19 -0
- data/spec/unit/alf-relation/relation/test_heading.rb +1 -1
- data/spec/unit/alf-relation/relation/test_keys.rb +17 -0
- data/spec/unit/alf-relation/relation/test_relation.rb +1 -1
- data/spec/unit/alf-relation/relation/test_to_a.rb +10 -10
- data/spec/unit/alf-relvar/base/test_oo_lang.rb +26 -10
- data/spec/unit/alf-relvar/base/test_to_cog.rb +2 -2
- data/spec/unit/alf-relvar/read_only/test_to_relation.rb +17 -0
- data/spec/unit/alf-relvar/read_only/test_type.rb +0 -4
- data/spec/unit/alf-relvar/virtual/test_oo_lang.rb +0 -4
- data/spec/unit/alf-relvar/virtual/test_to_cog.rb +4 -4
- data/spec/unit/alf-relvar/virtual/test_to_s.rb +1 -1
- data/spec/unit/alf-support/test_to_lispy.rb +13 -31
- data/spec/unit/alf-support/test_tuple_scope.rb +11 -0
- data/spec/unit/alf-types/ordering/test_coerce.rb +13 -0
- data/spec/unit/alf-types/ordering/test_lte.rb +43 -0
- data/spec/unit/alf-types/summarization/test_coerce.rb +2 -2
- data/spec/unit/alf-types/summarization/test_least.rb +1 -1
- data/spec/unit/alf-types/summarization/test_summarize.rb +1 -1
- data/spec/unit/alf-types/test_summarization.rb +2 -2
- data/spec/unit/alf-types/test_tuple_expression.rb +2 -2
- data/spec/unit/alf-types/tuple_computation/test_coerce.rb +4 -13
- data/spec/unit/alf-types/tuple_computation/test_empty.rb +24 -0
- data/spec/unit/alf-types/tuple_computation/test_project.rb +46 -0
- data/spec/unit/alf-types/tuple_expression/test_coerce.rb +1 -10
- data/spec/unit/alf-types/tuple_expression/test_evaluate.rb +0 -8
- data/spec/unit/alf-types/tuple_expression/test_to_ruby_literal.rb +0 -5
- data/spec/unit/alf-update/deleter/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-update/inserter/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-update/updater/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-viewpoint/test_native_const.rb +1 -1
- data/spec/update_helper.rb +18 -2
- metadata +417 -313
- data/lib/alf-algebra/alf/algebra/operand/named.rb +0 -36
- data/lib/alf-algebra/alf/algebra/operator/infer_heading.rb +0 -19
- data/lib/alf-algebra/alf/algebra/operator/type_safe.rb +0 -21
- data/lib/alf-algebra/alf/algebra/support/to_dot.rb +0 -196
- data/lib/alf-core/facade.rb +0 -39
- data/lib/alf-engine/alf/engine/cog.rb +0 -50
- data/lib/alf-engine/alf/engine/compiler.rb +0 -171
- data/lib/alf-engine/alf/engine/group.rb +0 -3
- data/lib/alf-engine/alf/engine/quota.rb +0 -3
- data/lib/alf-engine/alf/engine/rank.rb +0 -3
- data/lib/alf-engine/alf/engine/semi.rb +0 -3
- data/lib/alf-engine/alf/engine/sort.rb +0 -30
- data/lib/alf-engine/alf/engine/summarize.rb +0 -4
- data/lib/alf-engine/alf/engine/to_dot.rb +0 -60
- data/lib/alf-io/alf/io.rb +0 -6
- data/lib/alf-lang/alf/lang/lispy.rb +0 -65
- data/lib/alf-predicate/alf/predicate/parser.rb +0 -12
- data/lib/alf-predicate/alf/predicate/processors.rb +0 -3
- data/lib/alf-predicate/alf/predicate/processors/renamer.rb +0 -19
- data/lib/alf-predicate/alf/predicate/processors/to_proc.rb +0 -35
- data/lib/alf-relvar/alf/relvar/base.rb +0 -69
- data/lib/alf-support/alf/support/bindable.rb +0 -26
- data/spec/integration/algebra/test_to_dot.rb +0 -14
- data/spec/integration/relvar/test_type_safe.rb +0 -22
- data/spec/unit/alf-algebra/operator/infer_heading/test_keys.rb +0 -23
- data/spec/unit/alf-algebra/operator/test_infer_heading.rb +0 -16
- data/spec/unit/alf-algebra/operator/type_safe/test_heading.rb +0 -26
- data/spec/unit/alf-algebra/operator/type_safe/test_keys.rb +0 -26
- data/spec/unit/alf-engine/compiler/test_on_frame.rb +0 -70
- data/spec/unit/alf-engine/compiler/test_on_hierarchize.rb +0 -33
- data/spec/unit/alf-engine/compiler/test_on_page.rb +0 -128
- data/spec/unit/alf-engine/compiler/test_unsupported.rb +0 -48
- data/spec/unit/alf-lang/lispy/test_connection_bang.rb +0 -26
- data/spec/unit/alf-lang/lispy/test_parse.rb +0 -38
- data/spec/unit/alf-lang/lispy/test_to_s.rb +0 -14
- data/spec/unit/alf-optimizer/optimizer/test_optimizer.rb +0 -37
- data/spec/unit/alf-optimizer/test_infer_heading.rb +0 -9
- data/spec/unit/alf-predicate/grammar/test_parse.rb +0 -23
- data/spec/unit/alf-predicate/nodes/var_ref/test_var_name.rb +0 -14
- data/spec/unit/alf-relvar/base/test_name.rb +0 -15
- data/spec/unit/alf-relvar/virtual/test_connection.rb +0 -15
- data/spec/unit/alf-support/bindable/test_bind.rb +0 -60
- data/spec/unit/alf-support/bindable/test_bound.rb +0 -31
- data/spec/unit/alf-support/bindable/test_connection.rb +0 -31
- data/spec/unit/alf-support/bindable/test_connection_bang.rb +0 -35
- data/spec/unit/alf-update/inserter/test_type_safe.rb +0 -72
@@ -1,36 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Algebra
|
3
|
-
module Operand
|
4
|
-
class Named
|
5
|
-
include Operand
|
6
|
-
|
7
|
-
def initialize(name, connection = nil)
|
8
|
-
@name = name
|
9
|
-
@connection = connection
|
10
|
-
end
|
11
|
-
attr_reader :name
|
12
|
-
|
13
|
-
def keys
|
14
|
-
connection!.keys(name)
|
15
|
-
end
|
16
|
-
|
17
|
-
def heading
|
18
|
-
connection!.heading(name)
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_relvar
|
22
|
-
Relvar::Base.new(self)
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_s
|
26
|
-
"Operand::Named(#{name.inspect})"
|
27
|
-
end
|
28
|
-
|
29
|
-
def to_lispy
|
30
|
-
name.to_s
|
31
|
-
end
|
32
|
-
|
33
|
-
end # Named
|
34
|
-
end # module Operand
|
35
|
-
end # module Algebra
|
36
|
-
end # module Alf
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Algebra
|
3
|
-
class InferHeading
|
4
|
-
include Operator, Relational, Unary, Experimental
|
5
|
-
|
6
|
-
signature do |s|
|
7
|
-
end
|
8
|
-
|
9
|
-
def heading
|
10
|
-
raise NotSupportedError
|
11
|
-
end
|
12
|
-
|
13
|
-
def keys
|
14
|
-
@keys ||= Keys[ [] ]
|
15
|
-
end
|
16
|
-
|
17
|
-
end # class InferHeading
|
18
|
-
end # module Algebra
|
19
|
-
end # module Alf
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Algebra
|
3
|
-
class TypeSafe
|
4
|
-
include Operator, NonRelational, Unary
|
5
|
-
|
6
|
-
signature do |s|
|
7
|
-
s.argument :type_safe_heading, Heading, nil
|
8
|
-
s.option :strict, Boolean, false, 'Be strict, not allowing tuple projections?'
|
9
|
-
end
|
10
|
-
|
11
|
-
def heading
|
12
|
-
type_safe_heading
|
13
|
-
end
|
14
|
-
|
15
|
-
def keys
|
16
|
-
operand.keys
|
17
|
-
end
|
18
|
-
|
19
|
-
end # class TypeSafe
|
20
|
-
end # module Algebra
|
21
|
-
end # module Alf
|
@@ -1,196 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Algebra
|
3
|
-
class ToDot < Compiler
|
4
|
-
include Alf::Support::DotUtils
|
5
|
-
|
6
|
-
def call(expr, buf = "")
|
7
|
-
buf << "/* #{expr} */\n"
|
8
|
-
buf << "digraph \"Alf\" {\n"
|
9
|
-
buf << "node [width=0.375,height=0.25,shape=record];\n"
|
10
|
-
super
|
11
|
-
buf << "}\n"
|
12
|
-
buf
|
13
|
-
end
|
14
|
-
|
15
|
-
def on_unary_operator(expr, buf, label)
|
16
|
-
buf << "#{expr.object_id} [label=#{dot_label(label)}];\n"
|
17
|
-
apply(expr.operand, buf)
|
18
|
-
buf << "#{expr.object_id} -> #{expr.operand.object_id} [label=\"operand\"];\n"
|
19
|
-
end
|
20
|
-
|
21
|
-
def on_binary_operator(expr, buf, label)
|
22
|
-
buf << "#{expr.object_id} [label=#{dot_label(label)}];\n"
|
23
|
-
apply(expr.left, buf)
|
24
|
-
apply(expr.right, buf)
|
25
|
-
buf << "#{expr.object_id} -> #{expr.left.object_id} [label=\"left\"];\n"
|
26
|
-
buf << "#{expr.object_id} -> #{expr.right.object_id} [label=\"right\"];\n"
|
27
|
-
end
|
28
|
-
|
29
|
-
def on_leaf_operand(expr, buf = "")
|
30
|
-
case expr
|
31
|
-
when Operand::Named
|
32
|
-
buf << "#{expr.object_id} [label=#{dot_label(expr.name)}];\n"
|
33
|
-
when Operand::Proxy
|
34
|
-
buf << "#{expr.object_id} [label=#{dot_label(expr.subject)}];\n"
|
35
|
-
when Relvar::Virtual
|
36
|
-
buf << "#{expr.object_id} [label=\"Relvar::Virtual\"];\n"
|
37
|
-
apply(expr.expr, buf)
|
38
|
-
buf << "#{expr.object_id} -> #{expr.expr.object_id} [label=\"definition\"];\n"
|
39
|
-
when Relation
|
40
|
-
buf << "#{expr.object_id} [label=\"Relation\"];\n"
|
41
|
-
else
|
42
|
-
buf << "#{expr.object_id} [label=#{dot_label(expr)}];\n"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
###
|
47
|
-
|
48
|
-
def on_autonum(expr, buf = "")
|
49
|
-
on_unary_operator(expr, buf, "Autonum|#{as(expr)}")
|
50
|
-
end
|
51
|
-
|
52
|
-
def on_clip(expr, buf = "")
|
53
|
-
on_unary_operator(expr, buf, "Clip|#{allbut(expr)}#{attributes(expr)}")
|
54
|
-
end
|
55
|
-
|
56
|
-
def on_coerce(expr, buf = "")
|
57
|
-
on_unary_operator(expr, buf, "Coerce|#{expr.coercions}")
|
58
|
-
end
|
59
|
-
|
60
|
-
def on_compact(expr, buf = "")
|
61
|
-
on_unary_operator(expr, buf, "Compact")
|
62
|
-
end
|
63
|
-
|
64
|
-
def on_defaults(expr, buf = "")
|
65
|
-
on_unary_operator(expr, buf, "Defaults|#{strict}#{expr.defaults}")
|
66
|
-
end
|
67
|
-
|
68
|
-
def on_extend(expr, buf = "")
|
69
|
-
on_unary_operator(expr, buf, "Extend|#{expr.ext}")
|
70
|
-
end
|
71
|
-
|
72
|
-
def on_generator(expr, buf = "")
|
73
|
-
on_unary_operator(expr, buf, "Generator|#{expr.size}#{as(expr)}")
|
74
|
-
end
|
75
|
-
|
76
|
-
def on_group(expr, buf = "")
|
77
|
-
on_unary_operator(expr, buf, "Group|#{allbut(expr)}#{attributes(expr)}#{as(expr)}")
|
78
|
-
end
|
79
|
-
|
80
|
-
def on_infer_heading(expr, buf = "")
|
81
|
-
on_unary_operator(expr, buf, "InferHeading")
|
82
|
-
end
|
83
|
-
|
84
|
-
def on_intersect(expr, buf = "")
|
85
|
-
on_binary_operator(expr, buf, "Intersect")
|
86
|
-
end
|
87
|
-
|
88
|
-
def on_join(expr, buf = "")
|
89
|
-
on_binary_operator(expr, buf, "Join")
|
90
|
-
end
|
91
|
-
|
92
|
-
def on_matching(expr, buf = "")
|
93
|
-
on_binary_operator(expr, buf, "Matching")
|
94
|
-
end
|
95
|
-
|
96
|
-
def on_minus(expr, buf = "")
|
97
|
-
on_binary_operator(expr, buf, "Minus")
|
98
|
-
end
|
99
|
-
|
100
|
-
def on_not_matching(expr, buf = "")
|
101
|
-
on_binary_operator(expr, buf, "NotMatching")
|
102
|
-
end
|
103
|
-
|
104
|
-
def on_project(expr, buf = "")
|
105
|
-
on_unary_operator(expr, buf, "Project|#{allbut(expr)}#{attributes(expr)}")
|
106
|
-
end
|
107
|
-
|
108
|
-
def on_quota(expr, buf = "")
|
109
|
-
on_unary_operator(expr, buf, "Quota|#{by(expr)}")
|
110
|
-
end
|
111
|
-
|
112
|
-
def on_rank(expr, buf = "")
|
113
|
-
on_unary_operator(expr, buf, "Rank|#{order(expr)}#{as(expr)}")
|
114
|
-
end
|
115
|
-
|
116
|
-
def on_rename(expr, buf = "")
|
117
|
-
on_unary_operator(expr, buf, "Rename|#{renaming(expr)}")
|
118
|
-
end
|
119
|
-
|
120
|
-
def on_restrict(expr, buf = "")
|
121
|
-
on_unary_operator(expr, buf, "Restrict|#{predicate(expr)}")
|
122
|
-
end
|
123
|
-
|
124
|
-
def on_sort(expr, buf = "")
|
125
|
-
on_unary_operator(expr, buf, "Sort|#{ordering(expr)}")
|
126
|
-
end
|
127
|
-
|
128
|
-
def on_summarize(expr, buf = "")
|
129
|
-
on_unary_operator(expr, buf, "Sumarize|#{allbut(expr)}#{by(expr)}")
|
130
|
-
end
|
131
|
-
|
132
|
-
def on_type_safe(expr, buf = "")
|
133
|
-
on_unary_operator(expr, buf, "TypeSafe|#{strict(expr)}#{heading(expr)}")
|
134
|
-
end
|
135
|
-
|
136
|
-
def on_ungroup(expr, buf = "")
|
137
|
-
on_unary_operator(expr, buf, "Ungroup|#{expr.attribute}")
|
138
|
-
end
|
139
|
-
|
140
|
-
def on_union(expr, buf = "")
|
141
|
-
on_binary_operator(expr, buf, "Union")
|
142
|
-
end
|
143
|
-
|
144
|
-
def on_unwrap(expr, buf = "")
|
145
|
-
on_unary_operator(expr, buf, "Unwrap|#{expr.attribute}")
|
146
|
-
end
|
147
|
-
|
148
|
-
def on_wrap(expr, buf = "")
|
149
|
-
on_unary_operator(expr, buf, "Wrap|#{allbut(expr)}#{attributes(expr)}#{as(expr)}")
|
150
|
-
end
|
151
|
-
|
152
|
-
private
|
153
|
-
|
154
|
-
def allbut(expr)
|
155
|
-
expr.allbut ? 'allbut ' : ''
|
156
|
-
end
|
157
|
-
|
158
|
-
def as(expr)
|
159
|
-
"|#{expr.as}"
|
160
|
-
end
|
161
|
-
|
162
|
-
def attributes(expr)
|
163
|
-
"#{expr.attributes.to_a.join(',')}"
|
164
|
-
end
|
165
|
-
|
166
|
-
def by(expr)
|
167
|
-
"#{expr.by}"
|
168
|
-
end
|
169
|
-
|
170
|
-
def order(expr)
|
171
|
-
"#{expr.ordering}"
|
172
|
-
end
|
173
|
-
|
174
|
-
def renaming(expr)
|
175
|
-
"#{expr.renaming}"
|
176
|
-
end
|
177
|
-
|
178
|
-
def predicate(expr)
|
179
|
-
"#{expr.predicate}"
|
180
|
-
end
|
181
|
-
|
182
|
-
def heading(expr)
|
183
|
-
"#{expr.heading}"
|
184
|
-
end
|
185
|
-
|
186
|
-
def ordering(expr)
|
187
|
-
"#{expr.ordering}"
|
188
|
-
end
|
189
|
-
|
190
|
-
def strict(expr)
|
191
|
-
expr.strict ? "strict " : ''
|
192
|
-
end
|
193
|
-
|
194
|
-
end # class ToDot
|
195
|
-
end # module Algebra
|
196
|
-
end # module Alf
|
data/lib/alf-core/facade.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Facade
|
3
|
-
|
4
|
-
def database(*args, &bl)
|
5
|
-
Alf::Database.new(*args, &bl)
|
6
|
-
end
|
7
|
-
|
8
|
-
def connect(*args, &bl)
|
9
|
-
Alf::Database.connect(*args, &bl)
|
10
|
-
end
|
11
|
-
|
12
|
-
def examples_adapter
|
13
|
-
Path.backfind('examples/suppliers_and_parts')
|
14
|
-
end
|
15
|
-
|
16
|
-
def examples(&bl)
|
17
|
-
Alf::Database.connect examples_adapter, &bl
|
18
|
-
end
|
19
|
-
|
20
|
-
def reader(source, *args)
|
21
|
-
Alf::Reader.reader(source, *args)
|
22
|
-
end
|
23
|
-
|
24
|
-
def Relation(*args, &bl)
|
25
|
-
Alf::Relation.coerce(*args, &bl)
|
26
|
-
end
|
27
|
-
|
28
|
-
def Tuple(*args, &bl)
|
29
|
-
tuple = Alf::Tuple.coerce(*args)
|
30
|
-
tuple = tuple.remap(&bl) if bl
|
31
|
-
tuple
|
32
|
-
end
|
33
|
-
|
34
|
-
def Heading(*args, &bl)
|
35
|
-
Alf::Heading.coerce(*args, &bl)
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Engine
|
3
|
-
module Cog
|
4
|
-
include Enumerable
|
5
|
-
|
6
|
-
attr_reader :expr
|
7
|
-
|
8
|
-
def initialize(expr)
|
9
|
-
if expr && !expr.is_a?(Algebra::Operand)
|
10
|
-
raise "Operand expected as first cog argument"
|
11
|
-
end
|
12
|
-
@expr = expr
|
13
|
-
end
|
14
|
-
|
15
|
-
def heading
|
16
|
-
return expr.heading if expr
|
17
|
-
raise NotSupportedError, "Cog#heading without expr traceability"
|
18
|
-
end
|
19
|
-
|
20
|
-
def keys
|
21
|
-
return expr.keys if expr
|
22
|
-
raise NotSupportedError, "Cog#keys without expr traceability"
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_cog
|
26
|
-
self
|
27
|
-
end
|
28
|
-
|
29
|
-
def to_relation
|
30
|
-
Relation.coerce(to_a)
|
31
|
-
end
|
32
|
-
|
33
|
-
def each(&bl)
|
34
|
-
return to_enum unless block_given?
|
35
|
-
_each(&bl)
|
36
|
-
end
|
37
|
-
|
38
|
-
def to_dot(buffer = "")
|
39
|
-
Engine::ToDot.new.call(self, buffer)
|
40
|
-
end
|
41
|
-
|
42
|
-
protected
|
43
|
-
|
44
|
-
def tuple_scope(tuple = nil)
|
45
|
-
Support::TupleScope.new tuple, []
|
46
|
-
end
|
47
|
-
|
48
|
-
end # module Cog
|
49
|
-
end # module Engine
|
50
|
-
end # module Alf
|
@@ -1,171 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Engine
|
3
|
-
class Compiler < Algebra::Compiler
|
4
|
-
|
5
|
-
def not_supported(expr)
|
6
|
-
# sub-compilers (i.e. Alf::Sequel's one) cheat a bit by partly rewriting
|
7
|
-
# expressions so that their operands are actually Cogs...
|
8
|
-
expr.is_a?(Cog) ? expr : super
|
9
|
-
end
|
10
|
-
|
11
|
-
### leaf
|
12
|
-
|
13
|
-
def on_leaf_operand(expr)
|
14
|
-
expr.to_cog
|
15
|
-
end
|
16
|
-
|
17
|
-
### non relational
|
18
|
-
|
19
|
-
def on_autonum(expr)
|
20
|
-
Autonum.new(apply(expr.operand), expr.as, expr)
|
21
|
-
end
|
22
|
-
|
23
|
-
def on_clip(expr)
|
24
|
-
Clip.new(apply(expr.operand), expr.attributes, expr.allbut, expr)
|
25
|
-
end
|
26
|
-
|
27
|
-
def on_coerce(expr)
|
28
|
-
Coerce.new(apply(expr.operand), expr.coercions, expr)
|
29
|
-
end
|
30
|
-
|
31
|
-
def on_compact(expr)
|
32
|
-
Compact.new(apply(expr.operand), expr)
|
33
|
-
end
|
34
|
-
|
35
|
-
def on_defaults(expr)
|
36
|
-
op = Defaults.new(apply(expr.operand), expr.defaults, expr)
|
37
|
-
op = Clip.new(op, expr.defaults.to_attr_list, false, expr) if expr.strict
|
38
|
-
op
|
39
|
-
end
|
40
|
-
|
41
|
-
def on_generator(expr)
|
42
|
-
Generator.new(expr.as, 1, 1, expr.size, expr)
|
43
|
-
end
|
44
|
-
|
45
|
-
def on_sort(expr)
|
46
|
-
Sort.new(apply(expr.operand), expr.ordering, expr)
|
47
|
-
end
|
48
|
-
|
49
|
-
def on_type_safe(expr)
|
50
|
-
checker = TypeCheck.new(expr.heading, expr.strict)
|
51
|
-
TypeSafe.new(apply(expr.operand), checker, expr)
|
52
|
-
end
|
53
|
-
|
54
|
-
### relational
|
55
|
-
|
56
|
-
def on_extend(expr)
|
57
|
-
SetAttr.new(apply(expr.operand), expr.ext, expr)
|
58
|
-
end
|
59
|
-
|
60
|
-
def on_frame(expr)
|
61
|
-
offset, limit = expr.offset, expr.limit
|
62
|
-
ordering = unsupported(expr.ordering){ expr.total_ordering }
|
63
|
-
op = Sort.new(apply(expr.operand), ordering, expr)
|
64
|
-
op = Take.new(op, offset, limit, expr)
|
65
|
-
end
|
66
|
-
|
67
|
-
def on_page(expr)
|
68
|
-
index, size = expr.page_index, expr.page_size
|
69
|
-
ordering = unsupported(expr.ordering){ expr.total_ordering }
|
70
|
-
ordering = ordering.reverse if index < 0
|
71
|
-
op = Sort.new(apply(expr.operand), ordering, expr)
|
72
|
-
op = Take.new(op, (index.abs - 1) * size, size, expr)
|
73
|
-
end
|
74
|
-
|
75
|
-
def on_group(expr)
|
76
|
-
Group::Hash.new(apply(expr.operand), expr.attributes, expr.as, expr.allbut, expr)
|
77
|
-
end
|
78
|
-
|
79
|
-
def on_hierarchize(expr)
|
80
|
-
Hierarchize.new(apply(expr.operand), expr.id, expr.parent, expr.as)
|
81
|
-
end
|
82
|
-
|
83
|
-
def on_infer_heading(expr)
|
84
|
-
InferHeading.new(apply(expr.operand), expr)
|
85
|
-
end
|
86
|
-
|
87
|
-
def on_intersect(expr)
|
88
|
-
Join::Hash.new(apply(expr.left), apply(expr.right), expr)
|
89
|
-
end
|
90
|
-
|
91
|
-
def on_join(expr)
|
92
|
-
Join::Hash.new(apply(expr.left), apply(expr.right), expr)
|
93
|
-
end
|
94
|
-
|
95
|
-
def on_matching(expr)
|
96
|
-
Semi::Hash.new(apply(expr.left), apply(expr.right), true, expr)
|
97
|
-
end
|
98
|
-
|
99
|
-
def on_minus(expr)
|
100
|
-
Semi::Hash.new(apply(expr.left), apply(expr.right), false, expr)
|
101
|
-
end
|
102
|
-
|
103
|
-
def on_not_matching(expr)
|
104
|
-
Semi::Hash.new(apply(expr.left), apply(expr.right), false, expr)
|
105
|
-
end
|
106
|
-
|
107
|
-
def on_project(expr)
|
108
|
-
op = Clip.new(apply(expr.operand), expr.attributes, expr.allbut, expr)
|
109
|
-
op = Compact.new(op, expr)
|
110
|
-
op
|
111
|
-
end
|
112
|
-
|
113
|
-
def on_quota(expr)
|
114
|
-
op = Sort.new(apply(expr.operand), expr.by.to_ordering + expr.order, expr)
|
115
|
-
op = Quota::Cesure.new(op, expr.by, expr.summarization, expr)
|
116
|
-
op
|
117
|
-
end
|
118
|
-
|
119
|
-
def on_rank(expr)
|
120
|
-
op = Sort.new(apply(expr.operand), expr.order, expr)
|
121
|
-
op = Rank::Cesure.new(op, expr.order.to_attr_list, expr.as, expr)
|
122
|
-
op
|
123
|
-
end
|
124
|
-
|
125
|
-
def on_rename(expr)
|
126
|
-
Rename.new(apply(expr.operand), expr.renaming, expr)
|
127
|
-
end
|
128
|
-
|
129
|
-
def on_restrict(expr)
|
130
|
-
Filter.new(apply(expr.operand), expr.predicate, expr)
|
131
|
-
end
|
132
|
-
|
133
|
-
def on_summarize(expr)
|
134
|
-
if expr.allbut
|
135
|
-
Summarize::Hash.new(apply(expr.operand), expr.by, expr.summarization, expr.allbut, expr)
|
136
|
-
else
|
137
|
-
op = Sort.new(apply(expr.operand), expr.by.to_ordering, expr)
|
138
|
-
op = Summarize::Cesure.new(op, expr.by, expr.summarization, expr.allbut, expr)
|
139
|
-
op
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def on_ungroup(expr)
|
144
|
-
Ungroup.new(apply(expr.operand), expr.attribute, expr)
|
145
|
-
end
|
146
|
-
|
147
|
-
def on_union(expr)
|
148
|
-
op = Concat.new([apply(expr.left), apply(expr.right)], expr)
|
149
|
-
op = Compact.new(op, expr)
|
150
|
-
op
|
151
|
-
end
|
152
|
-
|
153
|
-
def on_unwrap(expr)
|
154
|
-
Unwrap.new(apply(expr.operand), expr.attribute, expr)
|
155
|
-
end
|
156
|
-
|
157
|
-
def on_wrap(expr)
|
158
|
-
Wrap.new(apply(expr.operand), expr.attributes, expr.as, expr.allbut, expr)
|
159
|
-
end
|
160
|
-
|
161
|
-
protected
|
162
|
-
|
163
|
-
def unsupported(fallback, &bl)
|
164
|
-
bl.call
|
165
|
-
rescue NotSupportedError
|
166
|
-
fallback
|
167
|
-
end
|
168
|
-
|
169
|
-
end # class Compiler
|
170
|
-
end # module Engine
|
171
|
-
end # module Alf
|