axiom-arango-adapter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rspec +5 -0
- data/.travis.yml +25 -0
- data/Gemfile +9 -0
- data/Gemfile.devtools +57 -0
- data/Guardfile +18 -0
- data/LICENSE +20 -0
- data/README.md +92 -0
- data/Rakefile +2 -0
- data/TODO +1 -0
- data/axiom-arango-adapter.gemspec +26 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/mutant.yml +3 -0
- data/config/roodi.yml +18 -0
- data/config/site.reek +102 -0
- data/config/yardstick.yml +2 -0
- data/lib/axiom-arango-adapter.rb +2 -0
- data/lib/axiom/adapter/arango.rb +40 -0
- data/lib/axiom/adapter/arango/adapter.rb +68 -0
- data/lib/axiom/adapter/arango/gateway.rb +356 -0
- data/lib/axiom/adapter/arango/reader.rb +98 -0
- data/lib/axiom/adapter/arango/visitor.rb +100 -0
- data/lib/axiom/adapter/arango/visitor/aggregate.rb +132 -0
- data/lib/axiom/adapter/arango/visitor/attribute.rb +26 -0
- data/lib/axiom/adapter/arango/visitor/binary.rb +77 -0
- data/lib/axiom/adapter/arango/visitor/for.rb +75 -0
- data/lib/axiom/adapter/arango/visitor/for/base.rb +40 -0
- data/lib/axiom/adapter/arango/visitor/for/binary.rb +108 -0
- data/lib/axiom/adapter/arango/visitor/for/binary/join.rb +131 -0
- data/lib/axiom/adapter/arango/visitor/for/binary/product.rb +48 -0
- data/lib/axiom/adapter/arango/visitor/for/summarization.rb +113 -0
- data/lib/axiom/adapter/arango/visitor/for/unary.rb +29 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/extension.rb +72 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/limit.rb +31 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/offset.rb +34 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/order.rb +63 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/projection.rb +32 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/rename.rb +88 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/restriction.rb +42 -0
- data/lib/axiom/adapter/arango/visitor/function.rb +33 -0
- data/lib/axiom/adapter/arango/visitor/header.rb +55 -0
- data/lib/axiom/adapter/arango/visitor/literal.rb +26 -0
- data/lib/axiom/adapter/arango/visitor/reverse.rb +27 -0
- data/spec/fuzzer.rb +53 -0
- data/spec/integration/arango/read_spec.rb +166 -0
- data/spec/setup/arangodb.sh +61 -0
- data/spec/setup/run.sh +23 -0
- data/spec/shared/aql_behavior.rb +7 -0
- data/spec/shared/binary_relation_method_behaviour.rb +53 -0
- data/spec/shared/unary_relation_method_behaviour.rb +21 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/support/ice_nine_config.rb +6 -0
- data/spec/unit/axiom/adapter/arango/adapter/class_methods/new_spec.rb +24 -0
- data/spec/unit/axiom/adapter/arango/adapter/gateway_spec.rb +11 -0
- data/spec/unit/axiom/adapter/arango/adapter/reader_spec.rb +12 -0
- data/spec/unit/axiom/adapter/arango/gateway/class_methods/new_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/gateway/difference_spec.rb +16 -0
- data/spec/unit/axiom/adapter/arango/gateway/drop_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/each_spec.rb +78 -0
- data/spec/unit/axiom/adapter/arango/gateway/extend_spec.rb +26 -0
- data/spec/unit/axiom/adapter/arango/gateway/intersect_spec.rb +16 -0
- data/spec/unit/axiom/adapter/arango/gateway/join_spec.rb +43 -0
- data/spec/unit/axiom/adapter/arango/gateway/materialize_spec.rb +26 -0
- data/spec/unit/axiom/adapter/arango/gateway/optimize_spec.rb +22 -0
- data/spec/unit/axiom/adapter/arango/gateway/product_spec.rb +16 -0
- data/spec/unit/axiom/adapter/arango/gateway/project_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/remove_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/rename_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/respond_to_predicate_spec.rb +28 -0
- data/spec/unit/axiom/adapter/arango/gateway/restrict_spec.rb +26 -0
- data/spec/unit/axiom/adapter/arango/gateway/reverse_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/sort_by_spec.rb +26 -0
- data/spec/unit/axiom/adapter/arango/gateway/summarize_spec.rb +150 -0
- data/spec/unit/axiom/adapter/arango/gateway/take_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/unhandled_message_spec.rb +17 -0
- data/spec/unit/axiom/adapter/arango/gateway/union_spec.rb +16 -0
- data/spec/unit/axiom/adapter/arango/reader/each_spec.rb +43 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/count/root_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/count_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/maximum/root_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/maximum_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/minimum/root_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/minimum_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/sum/root_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/sum_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/attribute/root_spec.rb +12 -0
- data/spec/unit/axiom/adapter/arango/visitor/binary/root_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/class_methods/build_spec.rb +37 -0
- data/spec/unit/axiom/adapter/arango/visitor/class_methods/run_spec.rb +26 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/base/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/join/local_name_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/join/right/root_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/join/root_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/join_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/local_name_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/product/right/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/product/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/product_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/right/join_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/right/local_name_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/right/product_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/local_name_spec.rb +21 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/root_spec.rb +29 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/summarization/root_spec.rb +53 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/extension/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/extension_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/limit/root_spec.rb +17 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/limit_spec.rb +17 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/offset/root_spec.rb +17 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/offset_spec.rb +17 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/order/root_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/order_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/projection/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/projection_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/rename/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/rename_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/restriction/root_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/restriction_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/header/root_spec.rb +12 -0
- data/spec/unit/axiom/adapter/arango/visitor/literal/root_spec.rb +10 -0
- data/spec/unit/axiom/adapter/arango/visitor/static/root_spec.rb +19 -0
- data/spec/unit/axiom/adapter/arango/visitor/visit_spec.rb +52 -0
- data/spec/unit/axiom/adapter/arango/visitor/visitor_spec.rb +39 -0
- metadata +379 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
module Axiom
|
2
|
+
module Adapter
|
3
|
+
module Arango
|
4
|
+
class Visitor
|
5
|
+
class For
|
6
|
+
class Unary
|
7
|
+
# Visitor for emitting AQL LIMIT statements from axiom limit operations
|
8
|
+
class Limit < self
|
9
|
+
|
10
|
+
handle(Axiom::Relation::Operation::Limit)
|
11
|
+
LOCAL_NAME = AQL.name_node('limit')
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# Return limit operation
|
16
|
+
#
|
17
|
+
# @return [AQL::Node]
|
18
|
+
#
|
19
|
+
# @api private
|
20
|
+
#
|
21
|
+
def operation
|
22
|
+
Node::Operation::Nary::Limit.new(Node::Literal::Primitive::Number.new(input.limit), Node::Literal::Primitive::Number.new(0))
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Axiom
|
2
|
+
module Adapter
|
3
|
+
module Arango
|
4
|
+
class Visitor
|
5
|
+
class For
|
6
|
+
class Unary
|
7
|
+
# Visitor for emitting currently defunct LIMIT statements from axiom offset operations
|
8
|
+
class Offset < self
|
9
|
+
|
10
|
+
handle(Axiom::Relation::Operation::Offset)
|
11
|
+
|
12
|
+
SIGNED_INT_32_MAX = 2 ** 31 - 1
|
13
|
+
LOCAL_NAME = AQL.name_node('offset')
|
14
|
+
MAXIMUM = Node::Literal::Primitive::Number.new(SIGNED_INT_32_MAX)
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# Return offset operation
|
19
|
+
#
|
20
|
+
# @return [AQL::Node]
|
21
|
+
#
|
22
|
+
# @api private
|
23
|
+
#
|
24
|
+
def operation
|
25
|
+
Node::Operation::Nary::Limit.new(MAXIMUM, Node::Literal::Primitive::Number.new(input.offset))
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Axiom
|
2
|
+
module Adapter
|
3
|
+
module Arango
|
4
|
+
class Visitor
|
5
|
+
class For
|
6
|
+
class Unary
|
7
|
+
# Visitor for emitting AQL SORT statements from axiom order operations
|
8
|
+
class Order < self
|
9
|
+
|
10
|
+
handle(Axiom::Relation::Operation::Order)
|
11
|
+
|
12
|
+
LOCAL_NAME = AQL.name_node('order')
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# Return operation
|
17
|
+
#
|
18
|
+
# @return [AQL::Node]
|
19
|
+
#
|
20
|
+
# @api private
|
21
|
+
#
|
22
|
+
def operation
|
23
|
+
Node::Operation::Nary::Sort.new(directions)
|
24
|
+
end
|
25
|
+
memoize :operation
|
26
|
+
|
27
|
+
# Return restriction expression
|
28
|
+
#
|
29
|
+
# @return [Enumerable<AQL::Node>]
|
30
|
+
#
|
31
|
+
# @api private
|
32
|
+
#
|
33
|
+
def directions
|
34
|
+
input.directions.map do |direction|
|
35
|
+
direction(direction)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
TABLE = {
|
40
|
+
Axiom::Relation::Operation::Order::Ascending => Node::Operation::Unary::Direction::Ascending,
|
41
|
+
Axiom::Relation::Operation::Order::Descending => Node::Operation::Unary::Direction::Descending
|
42
|
+
}.freeze
|
43
|
+
|
44
|
+
# Return direction AQL for axiom direction
|
45
|
+
#
|
46
|
+
# @param [Relation::Operation::Order::Direction] direction
|
47
|
+
#
|
48
|
+
# @return [AQL::Node]
|
49
|
+
#
|
50
|
+
# @api private
|
51
|
+
#
|
52
|
+
def direction(direction)
|
53
|
+
klass = TABLE.fetch(direction.class)
|
54
|
+
klass.new(visit(direction.attribute))
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Axiom
|
2
|
+
module Adapter
|
3
|
+
module Arango
|
4
|
+
class Visitor
|
5
|
+
class For
|
6
|
+
class Unary
|
7
|
+
# Visitor for emitting projections
|
8
|
+
class Projection < self
|
9
|
+
|
10
|
+
handle(Algebra::Projection)
|
11
|
+
|
12
|
+
LOCAL_NAME = AQL.name_node('projection')
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# Return for body
|
17
|
+
#
|
18
|
+
# @return [AQL::Node]
|
19
|
+
#
|
20
|
+
# @api private
|
21
|
+
#
|
22
|
+
def body
|
23
|
+
return_operation
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Axiom
|
2
|
+
module Adapter
|
3
|
+
module Arango
|
4
|
+
class Visitor
|
5
|
+
class For
|
6
|
+
class Unary
|
7
|
+
# Visitor for emitting renames
|
8
|
+
class Rename < self
|
9
|
+
|
10
|
+
handle(Algebra::Rename)
|
11
|
+
|
12
|
+
LOCAL_NAME = AQL.name_node('rename')
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# Return return value
|
17
|
+
#
|
18
|
+
# @return [AQL::Node::Literal::Composed::Document]
|
19
|
+
#
|
20
|
+
# @api private
|
21
|
+
#
|
22
|
+
def return_value
|
23
|
+
Node::Literal::Composed::Document.new(renamed_attributes)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Return for body
|
27
|
+
#
|
28
|
+
# @return [AQL::Node]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
#
|
32
|
+
def body
|
33
|
+
return_operation
|
34
|
+
end
|
35
|
+
|
36
|
+
# Return renamed attributes
|
37
|
+
#
|
38
|
+
# @return [Enumerable<AQL::Node::Literal::Composed::Document::Attribute>]
|
39
|
+
#
|
40
|
+
# @api private
|
41
|
+
#
|
42
|
+
def renamed_attributes
|
43
|
+
input.header.map do |attribute|
|
44
|
+
document_attribute(attribute)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Return document attribute
|
49
|
+
#
|
50
|
+
# @param [Attribute] attribute
|
51
|
+
#
|
52
|
+
# @return [Node::Literal::Composed::Document::Attribute]
|
53
|
+
#
|
54
|
+
# @api private
|
55
|
+
#
|
56
|
+
def document_attribute(attribute)
|
57
|
+
key = Node::Literal::Primitive::String.new(attribute.name.to_s)
|
58
|
+
Node::Literal::Composed::Document::Attribute.new(key, document_attribute_value(attribute))
|
59
|
+
end
|
60
|
+
|
61
|
+
# Return inverse of aliases
|
62
|
+
#
|
63
|
+
# @return [Algebra::Rename::Aliases]
|
64
|
+
#
|
65
|
+
# @api private
|
66
|
+
#
|
67
|
+
def inverse
|
68
|
+
input.aliases.inverse
|
69
|
+
end
|
70
|
+
memoize :inverse
|
71
|
+
|
72
|
+
# Return document attribute value
|
73
|
+
#
|
74
|
+
# @return [AQL::Node]
|
75
|
+
#
|
76
|
+
# @api private
|
77
|
+
#
|
78
|
+
def document_attribute_value(attribute)
|
79
|
+
visit(inverse[attribute])
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Axiom
|
2
|
+
module Adapter
|
3
|
+
module Arango
|
4
|
+
class Visitor
|
5
|
+
class For
|
6
|
+
class Unary
|
7
|
+
# Visitor for emitting AQL FILTER statements from axiom restrictions
|
8
|
+
class Restriction < self
|
9
|
+
|
10
|
+
handle(Axiom::Algebra::Restriction)
|
11
|
+
|
12
|
+
LOCAL_NAME = AQL.name_node('restriction')
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# Return filter operation
|
17
|
+
#
|
18
|
+
# @return [AQL::Node]
|
19
|
+
#
|
20
|
+
# @api private
|
21
|
+
#
|
22
|
+
def operation
|
23
|
+
Node::Operation::Unary::Filter.new(expression)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Return restriction expression
|
27
|
+
#
|
28
|
+
# @return [AQL::Node]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
#
|
32
|
+
def expression
|
33
|
+
visit(input.predicate)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Axiom
|
2
|
+
module Adapter
|
3
|
+
module Arango
|
4
|
+
class Visitor
|
5
|
+
# Base class for visitors with static root
|
6
|
+
class Static < self
|
7
|
+
|
8
|
+
# Return root node
|
9
|
+
#
|
10
|
+
# @return [AQL::Node]
|
11
|
+
#
|
12
|
+
# @api private
|
13
|
+
#
|
14
|
+
def root
|
15
|
+
self.class::ROOT
|
16
|
+
end
|
17
|
+
|
18
|
+
# Visitor for Axiom::Function::Proposition::Tautology
|
19
|
+
class Tautology < self
|
20
|
+
ROOT = AQL::Node::Literal::Singleton::TRUE
|
21
|
+
handle(Axiom::Function::Proposition::Tautology)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Visitor for Axiom::Function::Proposition::Contradiction
|
25
|
+
class Contradiction < self
|
26
|
+
ROOT = AQL::Node::Literal::Singleton::FALSE
|
27
|
+
handle(Axiom::Function::Proposition::Contradiction)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Axiom
|
2
|
+
module Adapter
|
3
|
+
module Arango
|
4
|
+
class Visitor
|
5
|
+
# Visitor for creating projected documents from axiom header
|
6
|
+
class Header < self
|
7
|
+
|
8
|
+
handle(Relation::Header)
|
9
|
+
|
10
|
+
# Return document node
|
11
|
+
#
|
12
|
+
# @return [AQL::Node]
|
13
|
+
#
|
14
|
+
# @api private
|
15
|
+
#
|
16
|
+
def root
|
17
|
+
Node::Literal::Composed::Document.new(document_attributes)
|
18
|
+
end
|
19
|
+
memoize :root
|
20
|
+
|
21
|
+
# Return document attributes
|
22
|
+
#
|
23
|
+
# @return [Enumerable<AQL::Node>]
|
24
|
+
#
|
25
|
+
# @api private
|
26
|
+
#
|
27
|
+
def document_attributes
|
28
|
+
input.map do |attribute|
|
29
|
+
document_attribute(attribute)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
memoize :document_attributes
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Return document attribute node
|
37
|
+
#
|
38
|
+
# @return [Axiom::Attribute] attribute
|
39
|
+
#
|
40
|
+
# @return [AQL::Node]
|
41
|
+
#
|
42
|
+
# @api private
|
43
|
+
#
|
44
|
+
def document_attribute(attribute)
|
45
|
+
Node::Literal::Composed::Document::Attribute.new(
|
46
|
+
Node::Literal::Primitive::String.new(attribute.name.to_s),
|
47
|
+
visit(attribute, context)
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Axiom
|
2
|
+
module Adapter
|
3
|
+
module Arango
|
4
|
+
class Visitor
|
5
|
+
# Visitor for literal nodes
|
6
|
+
class Literal < self
|
7
|
+
|
8
|
+
handle(::String)
|
9
|
+
handle(::Fixnum)
|
10
|
+
|
11
|
+
# Return root AQL node
|
12
|
+
#
|
13
|
+
# @return [AQL::Node]
|
14
|
+
#
|
15
|
+
# @api private
|
16
|
+
#
|
17
|
+
def root
|
18
|
+
Node::Literal.build(input)
|
19
|
+
end
|
20
|
+
memoize :root
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Axiom
|
2
|
+
module Adapter
|
3
|
+
module Arango
|
4
|
+
class Visitor
|
5
|
+
# Visitor for reverse operation
|
6
|
+
class Reverse < self
|
7
|
+
|
8
|
+
handle(Axiom::Relation::Operation::Reverse)
|
9
|
+
|
10
|
+
FUNCTION_NAME = 'REVERSE'.freeze
|
11
|
+
|
12
|
+
# Return root AQL AST
|
13
|
+
#
|
14
|
+
# @return [AQL::Node]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
#
|
18
|
+
def root
|
19
|
+
Node::Call::new(FUNCTION_NAME, [visit(input.operand)])
|
20
|
+
end
|
21
|
+
memoize :root
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/fuzzer.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'axiom-arango-adapter'
|
4
|
+
require 'axiom-fuzzer'
|
5
|
+
require 'logger'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
# This will go away with the shared gateway
|
9
|
+
Axiom::Sexp::Generator::REGISTRY[Veritas::Adapter::Arango::Gateway] = [ :unary, :gateway, :relation ]
|
10
|
+
|
11
|
+
database = Ashikawa::Core::Database.new do |config|
|
12
|
+
config.url = 'http://localhost:8529'
|
13
|
+
end
|
14
|
+
|
15
|
+
collection = database['people']
|
16
|
+
collection.delete
|
17
|
+
collection = database['people']
|
18
|
+
|
19
|
+
YAML.load(DATA).each do |document|
|
20
|
+
collection.create_document(document)
|
21
|
+
end
|
22
|
+
|
23
|
+
header = [ [ :id, Integer ], [ :name, String, { :length => 1..50 } ] ]
|
24
|
+
|
25
|
+
base = Axiom::Relation::Base.new('people', header)
|
26
|
+
adapter = Axiom::Adapter::Arango::Adapter.new(database, Logger.new($stderr, :debug))
|
27
|
+
gateway = adapter.gateway(base)
|
28
|
+
relation = gateway.materialize
|
29
|
+
|
30
|
+
Axiom::Fuzzer.run(gateway, relation)
|
31
|
+
|
32
|
+
__END__
|
33
|
+
---
|
34
|
+
- id: 1
|
35
|
+
name: Macie Deckow
|
36
|
+
- id: 2
|
37
|
+
name: Desmond Gleichner
|
38
|
+
- id: 3
|
39
|
+
name: Phil Krajcik
|
40
|
+
- id: 4
|
41
|
+
name: Adolph McClure
|
42
|
+
- id: 5
|
43
|
+
name: Trudy Torphy
|
44
|
+
- id: 6
|
45
|
+
name: Vance Hegmann
|
46
|
+
- id: 7
|
47
|
+
name: Lincoln Morissette
|
48
|
+
- id: 8
|
49
|
+
name: Dexter Doyle
|
50
|
+
- id: 9
|
51
|
+
name: Edgar Sanford
|
52
|
+
- id: 10
|
53
|
+
name: Jasper Batz
|