pacer 0.9.1.1-java → 1.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +4 -1
- data/.gitignore +4 -0
- data/.rspec +1 -1
- data/Gemfile-dev +33 -0
- data/Gemfile-release +4 -0
- data/README.md +27 -9
- data/Rakefile +26 -8
- data/bin/autotest +1 -1
- data/lib/pacer/blueprints/multi_graph.rb +7 -19
- data/lib/pacer/blueprints/ruby_graph.rb +77 -52
- data/lib/pacer/blueprints/tg.rb +6 -93
- data/lib/pacer/blueprints.rb +0 -1
- data/lib/pacer/core/graph/edges_route.rb +10 -12
- data/lib/pacer/core/graph/element_route.rb +14 -21
- data/lib/pacer/core/graph/graph_index_route.rb +12 -8
- data/lib/pacer/core/graph/graph_route.rb +2 -5
- data/lib/pacer/core/graph/mixed_route.rb +3 -5
- data/lib/pacer/core/graph/vertices_route.rb +26 -27
- data/lib/pacer/core/route.rb +35 -66
- data/lib/pacer/exceptions.rb +13 -6
- data/lib/pacer/extensions/block_filter_element.rb +0 -5
- data/lib/pacer/filter/collection_filter.rb +9 -2
- data/lib/pacer/filter/empty_filter.rb +12 -3
- data/lib/pacer/filter/future_filter.rb +5 -5
- data/lib/pacer/filter/loop_filter.rb +7 -13
- data/lib/pacer/filter/object_filter.rb +10 -16
- data/lib/pacer/filter/property_filter/filters.rb +134 -93
- data/lib/pacer/filter/property_filter.rb +22 -19
- data/lib/pacer/filter/where_filter/node_visitor.rb +47 -26
- data/lib/pacer/filter/where_filter.rb +24 -3
- data/lib/pacer/function_resolver.rb +7 -2
- data/lib/pacer/graph/graph_ml.rb +39 -0
- data/lib/pacer/graph/graph_transactions_mixin.rb +107 -175
- data/lib/pacer/graph/pacer_graph.rb +438 -0
- data/lib/pacer/graph/simple_encoder.rb +20 -0
- data/lib/pacer/graph/yaml_encoder.rb +81 -0
- data/lib/pacer/graph.rb +8 -10
- data/lib/pacer/pipe/blackbox_pipeline.rb +11 -4
- data/lib/pacer/pipe/block_filter_pipe.rb +5 -22
- data/lib/pacer/pipe/cross_product_transform_pipe.rb +5 -7
- data/lib/pacer/pipe/edges_pipe.rb +22 -0
- data/lib/pacer/pipe/enumerable_pipe.rb +3 -9
- data/lib/pacer/pipe/expandable_pipe.rb +2 -14
- data/lib/pacer/pipe/id_collection_filter_pipe.rb +2 -8
- data/lib/pacer/pipe/is_empty_pipe.rb +5 -12
- data/lib/pacer/pipe/is_unique_pipe.rb +3 -13
- data/lib/pacer/pipe/label_collection_filter_pipe.rb +1 -7
- data/lib/pacer/pipe/label_prefix_pipe.rb +0 -6
- data/lib/pacer/pipe/loop_pipe.rb +27 -25
- data/lib/pacer/pipe/never_pipe.rb +1 -1
- data/lib/pacer/pipe/path_wrapping_pipe.rb +40 -0
- data/lib/pacer/pipe/process_pipe.rb +2 -20
- data/lib/pacer/pipe/property_comparison_pipe.rb +0 -6
- data/lib/pacer/pipe/ruby_pipe.rb +10 -3
- data/lib/pacer/pipe/simple_visitor_pipe.rb +12 -11
- data/lib/pacer/pipe/stream_sort_pipe.rb +1 -7
- data/lib/pacer/pipe/stream_uniq_pipe.rb +0 -6
- data/lib/pacer/pipe/type_filter_pipe.rb +1 -7
- data/lib/pacer/pipe/unary_transform_pipe.rb +6 -8
- data/lib/pacer/pipe/unwrapping_pipe.rb +13 -0
- data/lib/pacer/pipe/vertices_pipe.rb +22 -0
- data/lib/pacer/pipe/visitor_pipe.rb +3 -7
- data/lib/pacer/pipe/wrapping_pipe.rb +37 -0
- data/lib/pacer/pipes.rb +17 -12
- data/lib/pacer/route/mixin/bulk_operations.rb +8 -9
- data/lib/pacer/route/mixin/route_operations.rb +17 -11
- data/lib/pacer/route/mixins.rb +0 -1
- data/lib/pacer/route.rb +198 -121
- data/lib/pacer/side_effect/aggregate.rb +22 -2
- data/lib/pacer/side_effect/as.rb +73 -0
- data/lib/pacer/side_effect/group_count.rb +0 -3
- data/lib/pacer/side_effect/is_unique.rb +7 -6
- data/lib/pacer/side_effect.rb +1 -1
- data/lib/pacer/support/enumerable.rb +14 -12
- data/lib/pacer/support/nil_class.rb +5 -0
- data/lib/pacer/support/proc.rb +2 -2
- data/lib/pacer/support.rb +1 -1
- data/lib/pacer/transform/cap.rb +1 -1
- data/lib/pacer/transform/has_count_cap.rb +1 -1
- data/lib/pacer/transform/join.rb +20 -16
- data/lib/pacer/transform/map.rb +6 -2
- data/lib/pacer/transform/path.rb +44 -20
- data/lib/pacer/transform/sort_section.rb +58 -51
- data/lib/pacer/utils/tsort.rb +7 -2
- data/lib/pacer/utils.rb +0 -1
- data/lib/pacer/version.rb +4 -3
- data/lib/pacer/visitors/section.rb +42 -0
- data/lib/pacer/visitors/visits_section.rb +32 -0
- data/lib/pacer/visitors.rb +7 -0
- data/lib/pacer/wrappers/edge_wrapper.rb +164 -11
- data/lib/pacer/wrappers/element_wrapper.rb +133 -8
- data/lib/pacer/wrappers/index_wrapper.rb +47 -0
- data/lib/pacer/wrappers/vertex_wrapper.rb +175 -12
- data/lib/pacer/wrappers/wrapper_selector.rb +40 -0
- data/lib/pacer/wrappers/wrapping_pipe_function.rb +90 -0
- data/lib/pacer/wrappers.rb +3 -1
- data/lib/pacer-1.0.0-standalone.jar +0 -0
- data/lib/pacer.rb +13 -47
- data/pacer.gemspec +0 -8
- data/pom.xml +10 -3
- data/spec/pacer/blueprints/dex_spec.rb +12 -26
- data/spec/pacer/blueprints/neo4j_spec.rb +14 -28
- data/spec/pacer/blueprints/tg_spec.rb +6 -54
- data/spec/pacer/core/graph/edges_route_spec.rb +1 -1
- data/spec/pacer/core/graph/element_route_spec.rb +2 -2
- data/spec/pacer/core/graph/graph_route_spec.rb +2 -2
- data/spec/pacer/core/graph/vertices_route_spec.rb +10 -3
- data/spec/pacer/core/route_spec.rb +35 -58
- data/spec/pacer/filter/empty_filter_spec.rb +5 -6
- data/spec/pacer/filter/future_filter_spec.rb +8 -8
- data/spec/pacer/filter/loop_filter_spec.rb +120 -6
- data/spec/pacer/filter/object_filter_spec.rb +15 -0
- data/spec/pacer/filter/property_filter/filters_spec.rb +169 -0
- data/spec/pacer/filter/property_filter_spec.rb +15 -12
- data/spec/pacer/filter/uniq_filter_spec.rb +1 -1
- data/spec/pacer/filter/where_filter_spec.rb +55 -7
- data/spec/pacer/graph/{graph_mixin_spec.rb → pacer_graph_spec.rb} +114 -185
- data/spec/pacer/route/mixin/base_spec.rb +36 -35
- data/spec/pacer/route/mixin/route_operations_spec.rb +4 -46
- data/spec/pacer/side_effect/as_spec.rb +34 -0
- data/spec/pacer/support/enumerable_spec.rb +6 -6
- data/spec/pacer/transform/join_spec.rb +7 -5
- data/spec/pacer/transform/map_spec.rb +55 -0
- data/spec/pacer/transform/path_spec.rb +30 -15
- data/spec/pacer/transform/process_spec.rb +42 -0
- data/spec/pacer/transform/sort_section_spec.rb +82 -0
- data/spec/pacer/wrapper/edge_wrapper_spec.rb +122 -2
- data/spec/pacer/wrapper/element_wrapper_spec.rb +289 -3
- data/spec/pacer/wrapper/vertex_wrapper_spec.rb +289 -2
- data/spec/spec_helper.rb +16 -7
- data/spec/support/graph_runner.rb +80 -29
- data/tags +1165 -0
- metadata +46 -107
- data/.rvmrc +0 -0
- data/lib/pacer/blueprints/extensions.rb +0 -77
- data/lib/pacer/graph/edge_mixin.rb +0 -127
- data/lib/pacer/graph/element_mixin.rb +0 -202
- data/lib/pacer/graph/graph_indices_mixin.rb +0 -93
- data/lib/pacer/graph/graph_mixin.rb +0 -361
- data/lib/pacer/graph/index_mixin.rb +0 -30
- data/lib/pacer/graph/vertex_mixin.rb +0 -119
- data/lib/pacer/pipe/map_pipe.rb +0 -36
- data/lib/pacer/pipe/variable_store_iterator_wrapper.rb +0 -26
- data/lib/pacer/route/mixin/variable_route_module.rb +0 -26
- data/lib/pacer/side_effect/section.rb +0 -25
- data/lib/pacer/support/iterator_mixins.rb +0 -110
- data/lib/pacer/wrappers/new_element.rb +0 -106
- data/lib/pacer-0.9.1.1-standalone.jar +0 -0
- data/spec/pacer/graph/edge_mixin_spec.rb +0 -116
- data/spec/pacer/graph/element_mixin_spec.rb +0 -297
- data/spec/pacer/graph/index_mixin_spec.rb +0 -0
- data/spec/pacer/graph/vertex_mixin_spec.rb +0 -192
@@ -1,119 +0,0 @@
|
|
1
|
-
module Pacer
|
2
|
-
# This module is mixed into the raw Blueprints Vertex class from any
|
3
|
-
# graph implementation.
|
4
|
-
#
|
5
|
-
# Adds more convenient/rubyish methods and adds support for extensions
|
6
|
-
# to some methods where needed.
|
7
|
-
module VertexMixin
|
8
|
-
# Add extensions to this vertex.
|
9
|
-
#
|
10
|
-
# If any extension has a Vertex module within it, this vertex will
|
11
|
-
# be extended with the extension's Vertex module.
|
12
|
-
#
|
13
|
-
# @see Core::Route#add_extension
|
14
|
-
#
|
15
|
-
# @param [[extensions]] exts the extensions to add
|
16
|
-
# @return [Pacer::EdgeWrapper] this vertex wrapped up and including
|
17
|
-
# the extensions
|
18
|
-
def add_extensions(exts)
|
19
|
-
if exts.any?
|
20
|
-
Wrappers::VertexWrapper.wrap(self, exts)
|
21
|
-
else
|
22
|
-
self
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Returns a human-readable representation of the vertex using the
|
27
|
-
# standard ruby console representation of an instantiated object.
|
28
|
-
# @return [String]
|
29
|
-
def inspect
|
30
|
-
"#<#{ ["V[#{element_id}]", display_name].compact.join(' ') }>"
|
31
|
-
end
|
32
|
-
|
33
|
-
# Returns the display name of the vertex.
|
34
|
-
# @return [String]
|
35
|
-
def display_name
|
36
|
-
graph.vertex_name.call self if graph and graph.vertex_name
|
37
|
-
end
|
38
|
-
|
39
|
-
# Deletes the vertex from its graph along with all related edges.
|
40
|
-
def delete!
|
41
|
-
graph.removeVertex element
|
42
|
-
end
|
43
|
-
|
44
|
-
# Copies including the vertex id unless a vertex with that id
|
45
|
-
# already exists.
|
46
|
-
# @param [Pacer::GraphMixin] target_graph
|
47
|
-
# @param opts for compatibility with {Pacer::EdgeMixin#clone_into}
|
48
|
-
# @yield [v] Optional block yields the vertex after it has been created.
|
49
|
-
# @return [Pacer::VertexMixin] the new vertex
|
50
|
-
def clone_into(target_graph, opts = nil)
|
51
|
-
v_idx = target_graph.index_name("tmp:v:#{graph.to_s}", :vertex, :create => true)
|
52
|
-
v = target_graph.vertex(element_id) || v_idx.get('id', element_id).first
|
53
|
-
unless v
|
54
|
-
v = target_graph.create_vertex element_id, properties
|
55
|
-
v_idx.put('id', element_id, v)
|
56
|
-
yield v if block_given?
|
57
|
-
end
|
58
|
-
v
|
59
|
-
end
|
60
|
-
|
61
|
-
# Make a new copy of the element with the next available vertex id.
|
62
|
-
#
|
63
|
-
# @param [Pacer::GraphMixin] target_graph
|
64
|
-
# @yield [v] Optional block yields the vertex after it has been created.
|
65
|
-
# @return [Pacer::VertexMixin] the new vertex
|
66
|
-
def copy_into(target_graph)
|
67
|
-
v = target_graph.create_vertex properties
|
68
|
-
yield v if block_given?
|
69
|
-
v
|
70
|
-
end
|
71
|
-
|
72
|
-
def raw_out_edges(*labels)
|
73
|
-
element.getOutEdges *labels
|
74
|
-
end
|
75
|
-
|
76
|
-
def raw_in_edges(*labels)
|
77
|
-
element.getInEdges *labels
|
78
|
-
end
|
79
|
-
|
80
|
-
def out_edges(*labels_and_extensions)
|
81
|
-
labels, exts = split_labels_and_extensions(labels_and_extensions)
|
82
|
-
edge_iterator(raw_out_edges(*labels).iterator, exts)
|
83
|
-
end
|
84
|
-
|
85
|
-
def in_edges(*labels_and_extensions)
|
86
|
-
labels, exts = split_labels_and_extensions(labels_and_extensions)
|
87
|
-
edge_iterator(raw_in_edges(*labels).iterator, exts)
|
88
|
-
end
|
89
|
-
|
90
|
-
def both_edges(*labels_and_extensions)
|
91
|
-
labels, exts = split_labels_and_extensions(labels_and_extensions)
|
92
|
-
ins = raw_in_edges(*labels).iterator
|
93
|
-
outs = raw_out_edges(*labels).iterator
|
94
|
-
edge_iterator(Pacer::Pipes::MultiIterator.new(ins, outs), exts)
|
95
|
-
end
|
96
|
-
|
97
|
-
protected
|
98
|
-
|
99
|
-
def split_labels_and_extensions(mixed)
|
100
|
-
labels = Set[]
|
101
|
-
exts = Set[]
|
102
|
-
mixed.each do |obj|
|
103
|
-
if obj.is_a? Symbol or obj.is_a? String
|
104
|
-
labels << obj
|
105
|
-
else
|
106
|
-
exts << obj
|
107
|
-
end
|
108
|
-
end
|
109
|
-
[labels, exts]
|
110
|
-
end
|
111
|
-
|
112
|
-
def edge_iterator(iter, exts)
|
113
|
-
iter.extend Pacer::Core::Route::IteratorExtensionsMixin
|
114
|
-
iter.graph = self.graph
|
115
|
-
iter.extensions = exts
|
116
|
-
iter
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
data/lib/pacer/pipe/map_pipe.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
module Pacer::Pipes
|
2
|
-
class MapPipe < AbstractPipe
|
3
|
-
field_reader :starts
|
4
|
-
|
5
|
-
def initialize(back, block)
|
6
|
-
super()
|
7
|
-
@block = block
|
8
|
-
@back = back
|
9
|
-
@graph = back.graph if back
|
10
|
-
@extensions = back.extensions + [Pacer::Extensions::BlockFilterElement]
|
11
|
-
@is_element = @graph.element_type?(back.element_type) if @graph
|
12
|
-
end
|
13
|
-
|
14
|
-
def processNextStart
|
15
|
-
while true
|
16
|
-
obj = starts.next
|
17
|
-
begin
|
18
|
-
if @is_element
|
19
|
-
obj = obj.add_extensions(@extensions)
|
20
|
-
obj.back = @back
|
21
|
-
obj.graph = @back.graph
|
22
|
-
end
|
23
|
-
rescue
|
24
|
-
end
|
25
|
-
result = @block.call(obj)
|
26
|
-
return result
|
27
|
-
end
|
28
|
-
rescue NativeException => e
|
29
|
-
if e.cause.getClass == Pacer::NoSuchElementException.getClass
|
30
|
-
raise e.cause
|
31
|
-
else
|
32
|
-
raise e
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Pacer::Pipes
|
2
|
-
class VariableStoreIteratorWrapper < AbstractPipe
|
3
|
-
|
4
|
-
field_reader :starts
|
5
|
-
attr_accessor :vars
|
6
|
-
|
7
|
-
def initialize(pipe, vars, variable_name)
|
8
|
-
super()
|
9
|
-
setStarts pipe if pipe
|
10
|
-
@vars = vars
|
11
|
-
@variable_name = variable_name
|
12
|
-
end
|
13
|
-
|
14
|
-
protected
|
15
|
-
|
16
|
-
def processNextStart
|
17
|
-
@vars[@variable_name] = starts.next
|
18
|
-
rescue NativeException => e
|
19
|
-
if e.cause.getClass == Pacer::NoSuchElementException.getClass
|
20
|
-
raise e.cause
|
21
|
-
else
|
22
|
-
raise e
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Pacer::Routes
|
2
|
-
|
3
|
-
# Adds support to a route to store a variable inline during processing. See
|
4
|
-
# Pacer::Routes::RouteOperations#as
|
5
|
-
module VariableRouteModule
|
6
|
-
attr_accessor :variable_name
|
7
|
-
|
8
|
-
def root?
|
9
|
-
false
|
10
|
-
end
|
11
|
-
|
12
|
-
protected
|
13
|
-
|
14
|
-
def attach_pipe(pipe)
|
15
|
-
Pacer::Pipes::VariableStoreIteratorWrapper.new(pipe, vars, @variable_name)
|
16
|
-
end
|
17
|
-
|
18
|
-
def has_routable_class?
|
19
|
-
false
|
20
|
-
end
|
21
|
-
|
22
|
-
def inspect_class_name
|
23
|
-
@variable_name.inspect
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Pacer
|
2
|
-
module Routes
|
3
|
-
module RouteOperations
|
4
|
-
def section(section_name = nil)
|
5
|
-
chain_route side_effect: :section, section_name: section_name
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
module SideEffect
|
11
|
-
module Section
|
12
|
-
attr_accessor :section_name
|
13
|
-
|
14
|
-
protected
|
15
|
-
|
16
|
-
attr_reader :section_visitor
|
17
|
-
|
18
|
-
def attach_pipe(end_pipe)
|
19
|
-
@section_visitor = pipe = Pacer::Pipes::SimpleVisitorPipe.new
|
20
|
-
pipe.setStarts end_pipe if end_pipe
|
21
|
-
pipe
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
module Pacer::Core::Route
|
2
|
-
# This mixin allows an iterator to be returned from methods that perform a
|
3
|
-
# transformation on the elements in their collection. Set the block property
|
4
|
-
# to the proc that does the transformation.
|
5
|
-
module IteratorBlockMixin
|
6
|
-
attr_accessor :graph
|
7
|
-
|
8
|
-
# Set the block that does the transformation.
|
9
|
-
def block=(block)
|
10
|
-
@block = block
|
11
|
-
end
|
12
|
-
|
13
|
-
def next
|
14
|
-
item = super
|
15
|
-
item.graph ||= @graph
|
16
|
-
@block.call(item)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
module IteratorPathMixin
|
21
|
-
attr_accessor :graph
|
22
|
-
|
23
|
-
def next
|
24
|
-
super.collect do |e|
|
25
|
-
e.graph ||= @graph if e.respond_to? :graph=
|
26
|
-
e
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
module IteratorExtensionsMixin
|
32
|
-
attr_accessor :graph, :extensions
|
33
|
-
|
34
|
-
def next
|
35
|
-
item = super
|
36
|
-
# TODO: optimize this (and other) check:
|
37
|
-
# - exception?
|
38
|
-
# - type check?
|
39
|
-
# - method check?
|
40
|
-
# - ...?
|
41
|
-
if item.respond_to? :graph=
|
42
|
-
item = item.add_extensions @extensions
|
43
|
-
item.graph ||= @graph
|
44
|
-
end
|
45
|
-
item
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
module IteratorWrapperMixin
|
50
|
-
attr_reader :graph, :extensions, :wrapper
|
51
|
-
|
52
|
-
def wrapper=(w)
|
53
|
-
@base_wrapper = w
|
54
|
-
@wrapper = build_wrapper?
|
55
|
-
@set_graph = set_graph?
|
56
|
-
end
|
57
|
-
|
58
|
-
def graph=(g)
|
59
|
-
@graph = g
|
60
|
-
@wrapper = build_wrapper?
|
61
|
-
@set_graph = set_graph?
|
62
|
-
end
|
63
|
-
|
64
|
-
def extensions=(exts)
|
65
|
-
@extensions = exts
|
66
|
-
@wrapper = build_wrapper?
|
67
|
-
@set_graph = set_graph?
|
68
|
-
end
|
69
|
-
|
70
|
-
def build_wrapper?
|
71
|
-
@base_wrapper = nil unless defined? @base_wrapper
|
72
|
-
@extensions = nil unless defined? @extensions
|
73
|
-
if @base_wrapper and @extensions
|
74
|
-
@wrapper = @base_wrapper.wrapper_for(@base_wrapper.extensions + @extensions.to_a)
|
75
|
-
elsif @base_wrapper
|
76
|
-
@wrapper = @base_wrapper
|
77
|
-
elsif @extensions
|
78
|
-
# We don't know what type of wrapper to create
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
if RUBY_VERSION =~ /^1\.8\./
|
83
|
-
def set_graph?
|
84
|
-
graph and wrapper and wrapper.instance_methods.include?('graph=')
|
85
|
-
end
|
86
|
-
else
|
87
|
-
def set_graph?
|
88
|
-
graph and wrapper and wrapper.instance_methods.include?(:graph=)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def next
|
93
|
-
item = wrapper.new(super)
|
94
|
-
item.graph ||= graph if @set_graph
|
95
|
-
item
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
module IteratorMixin
|
100
|
-
attr_accessor :graph
|
101
|
-
|
102
|
-
def next
|
103
|
-
item = super
|
104
|
-
if item.respond_to? :graph=
|
105
|
-
item.graph ||= @graph
|
106
|
-
end
|
107
|
-
item
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
module Pacer::Wrappers
|
2
|
-
class NewElement
|
3
|
-
include Pacer::Element
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@properties = {}
|
7
|
-
@out_edges = []
|
8
|
-
@in_edges = []
|
9
|
-
end
|
10
|
-
|
11
|
-
def getId
|
12
|
-
nil
|
13
|
-
end
|
14
|
-
alias get_id getId
|
15
|
-
|
16
|
-
def getPropertyKeys
|
17
|
-
@properties.keys
|
18
|
-
end
|
19
|
-
alias property_keys getPropertyKeys
|
20
|
-
|
21
|
-
def getProperty(prop)
|
22
|
-
@properties[prop]
|
23
|
-
end
|
24
|
-
alias get_property getProperty
|
25
|
-
|
26
|
-
def setProperty(prop, value)
|
27
|
-
@properties[prop] = value
|
28
|
-
end
|
29
|
-
alias set_property setProperty
|
30
|
-
|
31
|
-
def removeProperty(prop)
|
32
|
-
@properties.delete prop
|
33
|
-
end
|
34
|
-
alias remove_property removeProperty
|
35
|
-
|
36
|
-
def graph
|
37
|
-
@graph
|
38
|
-
end
|
39
|
-
|
40
|
-
def graph=(graph)
|
41
|
-
@graph = graph
|
42
|
-
end
|
43
|
-
|
44
|
-
def <=>(other)
|
45
|
-
object_id <=> other.object_id
|
46
|
-
end
|
47
|
-
|
48
|
-
def ==(other)
|
49
|
-
equal? other
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class NewVertex < NewElement
|
54
|
-
include Pacer::Vertex
|
55
|
-
|
56
|
-
def getOutEdges(*args)
|
57
|
-
@out_edges
|
58
|
-
end
|
59
|
-
alias out_edges getOutEdges
|
60
|
-
alias get_out_edges getOutEdges
|
61
|
-
|
62
|
-
def getInEdges(*args)
|
63
|
-
@in_edges
|
64
|
-
end
|
65
|
-
alias in_edges getInEdges
|
66
|
-
alias get_in_edges getInEdges
|
67
|
-
|
68
|
-
def getRawVertex
|
69
|
-
self
|
70
|
-
end
|
71
|
-
alias raw_vertex getRawVertex
|
72
|
-
end
|
73
|
-
|
74
|
-
class NewEdge < NewElement
|
75
|
-
include Pacer::Edge
|
76
|
-
|
77
|
-
def getInVertex
|
78
|
-
@in_vertex
|
79
|
-
end
|
80
|
-
alias in_vertex getInVertex
|
81
|
-
alias inVertex getInVertex
|
82
|
-
|
83
|
-
def getOutVertex
|
84
|
-
@out_vertex
|
85
|
-
end
|
86
|
-
alias out_vertex getOutVertex
|
87
|
-
alias outVertex getOutVertex
|
88
|
-
|
89
|
-
def getLabel
|
90
|
-
@label
|
91
|
-
end
|
92
|
-
alias get_label getLabel
|
93
|
-
alias label getLabel
|
94
|
-
|
95
|
-
def setLabel(label)
|
96
|
-
@label = label
|
97
|
-
end
|
98
|
-
alias set_label setLabel
|
99
|
-
alias label= setLabel
|
100
|
-
|
101
|
-
def getRawEdge
|
102
|
-
self
|
103
|
-
end
|
104
|
-
alias raw_edge getRawEdge
|
105
|
-
end
|
106
|
-
end
|
Binary file
|
@@ -1,116 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_examples_for Pacer::EdgeMixin do
|
4
|
-
use_simple_graph_data
|
5
|
-
|
6
|
-
describe '#e' do
|
7
|
-
subject { e0.e }
|
8
|
-
it { should be_an_edges_route }
|
9
|
-
it { should_not be_a(graph.element_type(:edge)) }
|
10
|
-
it { should_not be_an_instance_of(graph.element_type(:edge)) }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '#add_extensions' do
|
14
|
-
context 'no extensions' do
|
15
|
-
subject { e0.add_extensions([]) }
|
16
|
-
its('extensions.to_a') { should == [] }
|
17
|
-
it { should_not be_a(Pacer::Wrappers::ElementWrapper) }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'with extensions' do
|
21
|
-
subject { e0.add_extensions([Tackle::SimpleMixin]) }
|
22
|
-
its('extensions.to_a') { should == [Tackle::SimpleMixin] }
|
23
|
-
it { should be_a(Pacer::Wrappers::ElementWrapper) }
|
24
|
-
it { should be_a(Pacer::Wrappers::EdgeWrapper) }
|
25
|
-
it { should_not be_a(Pacer::Wrappers::VertexWrapper) }
|
26
|
-
|
27
|
-
describe '#e' do
|
28
|
-
subject { e0.add_extensions([Tackle::SimpleMixin]).e }
|
29
|
-
its('extensions.to_a') { should == [Tackle::SimpleMixin] }
|
30
|
-
it { should be_an_edges_route }
|
31
|
-
it { should be_a(Tackle::SimpleMixin::Route) }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#delete!' do
|
37
|
-
before do
|
38
|
-
@edge_id = e0.element_id
|
39
|
-
e0.delete!
|
40
|
-
graph.checkpoint # deleted edges in neo may be looked up during the transaction
|
41
|
-
end
|
42
|
-
it 'should be removed' do
|
43
|
-
graph.edge(@edge_id).should be_nil
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
contexts(
|
48
|
-
'into new tg' => proc {
|
49
|
-
let(:dest) { Pacer.tg }
|
50
|
-
},
|
51
|
-
'into graph2' => proc {
|
52
|
-
let(:dest) { graph2 }
|
53
|
-
}) do
|
54
|
-
describe '#clone_into', :transactions => false do
|
55
|
-
before { pending 'support temporary hash indices for clone/copy' unless graph.supports_manual_indices? }
|
56
|
-
context 'including vertices' do
|
57
|
-
subject { e0.clone_into(dest, :create_vertices => true) }
|
58
|
-
|
59
|
-
its('element_id.to_s') { should == e0.element_id.to_s if graph.supports_custom_element_ids? }
|
60
|
-
its(:label) { should == 'links' }
|
61
|
-
its(:graph) { should equal(dest) }
|
62
|
-
its('in_vertex.properties') { should == { 'name' => 'eliza' } }
|
63
|
-
its('out_vertex.properties') { should == { 'name' => 'darrick' } }
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'without vertices' do
|
67
|
-
subject { e0.clone_into(dest) rescue nil }
|
68
|
-
it { should be_nil }
|
69
|
-
|
70
|
-
context 'but already existing' do
|
71
|
-
before do
|
72
|
-
v0.clone_into(dest)
|
73
|
-
v1.clone_into(dest)
|
74
|
-
end
|
75
|
-
its('element_id.to_s') { should == e0.element_id.to_s if graph.supports_custom_element_ids? }
|
76
|
-
its(:label) { should == 'links' }
|
77
|
-
its(:graph) { should equal(dest) }
|
78
|
-
its('in_vertex.properties') { should == { 'name' => 'eliza' } }
|
79
|
-
its('out_vertex.properties') { should == { 'name' => 'darrick' } }
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe '#copy_into', :transactions => false do
|
85
|
-
before { pending unless graph.supports_manual_indices? }
|
86
|
-
subject { v0.clone_into(dest); v1.clone_into(dest); e0.copy_into(dest) }
|
87
|
-
its(:label) { should == 'links' }
|
88
|
-
its(:graph) { should equal(dest) }
|
89
|
-
its('in_vertex.properties') { should == { 'name' => 'eliza' } }
|
90
|
-
its('out_vertex.properties') { should == { 'name' => 'darrick' } }
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
subject { e0 }
|
96
|
-
its(:graph) { should equal(graph) }
|
97
|
-
its(:display_name) { should == "#{ v0.element_id }-links-#{ v1.element_id }" }
|
98
|
-
its(:inspect) { should == "#<E[#{ e0.element_id }]:#{ v0.element_id }-links-#{ v1.element_id }>" }
|
99
|
-
context 'with label proc' do
|
100
|
-
before do
|
101
|
-
graph.edge_name = proc { |e| "some name" }
|
102
|
-
end
|
103
|
-
its(:display_name) { should == "some name" }
|
104
|
-
its(:inspect) { should == "#<E[#{ e0.element_id }]:some name>" }
|
105
|
-
end
|
106
|
-
|
107
|
-
context '', :transactions => true do
|
108
|
-
it { should_not == e1 }
|
109
|
-
it { should == e0 }
|
110
|
-
it { should_not == v0 }
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
Run.all do
|
115
|
-
it_uses Pacer::EdgeMixin
|
116
|
-
end
|