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
data/.autotest
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
require 'autotest/
|
1
|
+
require 'autotest/growl'
|
2
|
+
|
3
|
+
Autotest::Growl::clear_terminal = false
|
4
|
+
|
2
5
|
Autotest.add_hook(:initialize) {|at|
|
3
6
|
at.add_exception %r{\.git} # ignore Version Control System
|
4
7
|
at.add_exception %r{/\.} # ignore any file that starts with a . (dot)
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
--format d
|
data/Gemfile-dev
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# A sample Gemfile
|
2
|
+
source "http://rubygems.org"
|
3
|
+
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'rspec', '~> 2.10.0'
|
8
|
+
gem 'rr', '~> 1.0'
|
9
|
+
gem 'simplecov'
|
10
|
+
gem 'yard'
|
11
|
+
gem 'rake'
|
12
|
+
|
13
|
+
# pacer-* gems are required for testing pacer.
|
14
|
+
# If you have the gem repos cloned locally, we'll use them.
|
15
|
+
#
|
16
|
+
libs = [
|
17
|
+
['pacer-neo4j', '2.0.0.pre'],
|
18
|
+
['pacer-orient', '2.0.0.pre'],
|
19
|
+
['pacer-dex', '2.0.0.pre']
|
20
|
+
]
|
21
|
+
libs.each do |lib, version|
|
22
|
+
if File.directory? "../#{lib}"
|
23
|
+
gem lib, :path => "../#{lib}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
gem 'autotest-standalone'
|
29
|
+
gem 'autotest-growl'
|
30
|
+
gem 'pry'
|
31
|
+
gem 'awesome_print', '0.4.0'
|
32
|
+
end
|
33
|
+
|
data/Gemfile-release
ADDED
data/README.md
CHANGED
@@ -2,9 +2,18 @@
|
|
2
2
|
|
3
3
|
Pacer is a JRuby library that enables very expressive graph traversals.
|
4
4
|
|
5
|
-
It currently supports 2 major graph database: [Neo4j](http://neo4j.org)
|
6
|
-
|
7
|
-
|
5
|
+
It currently supports 2 major graph database: [Neo4j](http://neo4j.org)
|
6
|
+
and [Dex](http://www.sparsity-technologies.com/dex) using the
|
7
|
+
[Tinkerpop](http://tinkerpop.com) graphdb stack. Plus there's a very
|
8
|
+
convenient in-memory graph called TinkerGraph which is part of
|
9
|
+
[Blueprints](http://blueprints.tinkerpop.com).
|
10
|
+
|
11
|
+
Pacer allows you to create, modify and traverse graphs using very fast
|
12
|
+
and memory efficient stream processing thanks to the very cool
|
13
|
+
[Pipes](http://pipes.tinkerpop.com) library. That also means that almost
|
14
|
+
all processing is done in pure Java, so when it comes the usual Ruby
|
15
|
+
expressiveness vs. speed problem, you can have your cake and eat it too,
|
16
|
+
it's very fast!
|
8
17
|
|
9
18
|
## Mailing List
|
10
19
|
|
@@ -22,6 +31,14 @@ If you like, you can also use the documentation locally via
|
|
22
31
|
gem install yard
|
23
32
|
yard server
|
24
33
|
|
34
|
+
## JRuby 1.7 Required
|
35
|
+
|
36
|
+
As of Pacer 1.0.0, [JRuby](http://jruby.org/) 1.7 is required because it is both faster and
|
37
|
+
fixes some problems that I previously had to work around in Pacer.
|
38
|
+
|
39
|
+
The easiest way (ie. the way I do it) to get the most recent version of
|
40
|
+
JRuby is to use [RVM](https://rvm.io/)
|
41
|
+
|
25
42
|
## Installation
|
26
43
|
|
27
44
|
The easiest way to get Pacer is `gem install pacer`.
|
@@ -29,12 +46,9 @@ The easiest way to get Pacer is `gem install pacer`.
|
|
29
46
|
If you want to hack on Pacer, you'll need to have
|
30
47
|
[maven](http://maven.apache.org/) installed (I recommend `brew install
|
31
48
|
maven`), then use `rake jar` to set up maven's pom.xml file and run the
|
32
|
-
maven build script.
|
33
|
-
|
34
|
-
|
35
|
-
main Pipes repo. You will need to build the `develop` branch of [my pipes
|
36
|
-
repo](https://github.com/pangloss/pipes) by cloning it and running `mvn
|
37
|
-
clean install`.
|
49
|
+
maven build script. Then `rake gemfile_devel` to set up a default
|
50
|
+
Gemfile that you can customize as needed to include dependencies
|
51
|
+
to the various pacer-... graphs you want the test suite to run against.
|
38
52
|
|
39
53
|
## Graph Database Support
|
40
54
|
|
@@ -185,3 +199,7 @@ A great introduction to the underlying concept of pipes can be found in Marko Ro
|
|
185
199
|
## Test Coverage
|
186
200
|
|
187
201
|
I'm aiming for 100% test coverage in Pacer and am currently nearly there in the core classes, but there is a way to go with the filter, transform and side effect route modules. Open coverage/index.html to see the current state of test coverage. And of course contributions would be much apreciated.
|
202
|
+
|
203
|
+
## Style Guide
|
204
|
+
|
205
|
+
Please follow Github's [Ruby style guide](https://github.com/styleguide/ruby) when contributing to make your patches more likely to be accepted!
|
data/Rakefile
CHANGED
@@ -6,16 +6,10 @@ require 'rspec/core/rake_task'
|
|
6
6
|
require 'yard'
|
7
7
|
|
8
8
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
9
|
+
spec.rspec_path = 'bin/rspec'
|
9
10
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
10
11
|
end
|
11
12
|
|
12
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
13
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
14
|
-
spec.ruby_opts = '--debug'
|
15
|
-
spec.rcov = true
|
16
|
-
spec.rcov_opts = %w{--exclude generator_internal,jsignal_internal,gems\/,spec\/}
|
17
|
-
end
|
18
|
-
|
19
13
|
task :default => :spec
|
20
14
|
|
21
15
|
desc 'Generate documentation'
|
@@ -24,6 +18,7 @@ YARD::Rake::YardocTask.new do |t|
|
|
24
18
|
t.options = ['--no-private']
|
25
19
|
end
|
26
20
|
|
21
|
+
desc 'update pom.xml with current versions from lib/pacer/version.rb'
|
27
22
|
file 'pom.xml' => 'lib/pacer/version.rb' do
|
28
23
|
pom = File.read 'pom.xml'
|
29
24
|
when_writing('Update pom.xml version number') do
|
@@ -32,6 +27,7 @@ file 'pom.xml' => 'lib/pacer/version.rb' do
|
|
32
27
|
line.sub!(%r{<gem.version>.*</gem.version>}, "<gem.version>#{ Pacer::VERSION }</gem.version>")
|
33
28
|
line.sub!(%r{<blueprints.version>.*</blueprints.version>}, "<blueprints.version>#{ Pacer::BLUEPRINTS_VERSION }</blueprints.version>")
|
34
29
|
line.sub!(%r{<pipes.version>.*</pipes.version>}, "<pipes.version>#{ Pacer::PIPES_VERSION }</pipes.version>")
|
30
|
+
line.sub!(%r{<gremlin.version>.*</gremlin.version>}, "<gremlin.version>#{ Pacer::GREMLIN_VERSION }</gremlin.version>")
|
35
31
|
f << line
|
36
32
|
end
|
37
33
|
end
|
@@ -40,10 +36,32 @@ end
|
|
40
36
|
|
41
37
|
file Pacer::JAR_PATH => 'pom.xml' do
|
42
38
|
when_writing("Execute 'mvn package' task") do
|
43
|
-
system
|
39
|
+
system 'mvn', 'clean'
|
40
|
+
system 'mvn', 'package'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
task :check_18_mode do
|
45
|
+
if RUBY_VERSION !~ /1\.8/
|
46
|
+
warn 'Releasing gems in 1.9 mode does not work as of JRuby 1.6.5'
|
47
|
+
raise 'Nooooooo!'
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
51
|
+
task :gemfile_devel do
|
52
|
+
File.delete 'Gemfile' if File.exists? 'Gemfile'
|
53
|
+
File.symlink 'Gemfile-dev', 'Gemfile'
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'Touch version.rb so that the jar rebuilds'
|
57
|
+
task :touch do
|
58
|
+
system 'touch', 'lib/pacer/version.rb'
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "build the JAR at #{ Pacer::JAR_PATH }"
|
47
62
|
task :jar => Pacer::JAR_PATH
|
63
|
+
|
64
|
+
# Add dependency to bundler default tasks:
|
48
65
|
task :build => Pacer::JAR_PATH
|
49
66
|
task :install => Pacer::JAR_PATH
|
67
|
+
task :release => Pacer::JAR_PATH
|
data/bin/autotest
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
module Pacer
|
2
2
|
class MultiGraph < RubyGraph
|
3
|
-
def
|
4
|
-
|
3
|
+
def self.blank
|
4
|
+
PacerGraph.new SimpleEncoder, proc { MultiGraph.new }
|
5
5
|
end
|
6
6
|
|
7
|
+
protected
|
8
|
+
|
7
9
|
def vertex_class
|
8
10
|
MultiVertex
|
9
11
|
end
|
@@ -15,7 +17,7 @@ module Pacer
|
|
15
17
|
|
16
18
|
|
17
19
|
class MultiVertex < RubyVertex
|
18
|
-
import com.tinkerpop.pipes.util.MultiIterator
|
20
|
+
import com.tinkerpop.pipes.util.iterators.MultiIterator
|
19
21
|
|
20
22
|
def initialize(*args)
|
21
23
|
super
|
@@ -82,24 +84,12 @@ module Pacer
|
|
82
84
|
super
|
83
85
|
end
|
84
86
|
|
85
|
-
def
|
86
|
-
vs = vertices
|
87
|
-
if vs.any?
|
88
|
-
labels = extract_varargs_strings(labels)
|
89
|
-
p = Pacer::Pipes::IdentityPipe.new
|
90
|
-
p.setStarts(MultiIterator.new super(*labels), *vs.map { |v| v.getOutEdges(*labels).iterator })
|
91
|
-
p
|
92
|
-
else
|
93
|
-
super
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def getInEdges(*labels)
|
87
|
+
def getEdges(direction, *labels)
|
98
88
|
vs = vertices
|
99
89
|
if vs.any?
|
100
90
|
labels = extract_varargs_strings(labels)
|
101
91
|
p = Pacer::Pipes::IdentityPipe.new
|
102
|
-
p.setStarts
|
92
|
+
p.setStarts(MultiIterator.new super, *vs.map { |v| v.getEdges(direction, *labels).iterator })
|
103
93
|
p
|
104
94
|
else
|
105
95
|
super
|
@@ -115,7 +105,5 @@ module Pacer
|
|
115
105
|
def to_s
|
116
106
|
"m[#{ element_id }]"
|
117
107
|
end
|
118
|
-
|
119
|
-
include VertexExtensions
|
120
108
|
end
|
121
109
|
end
|
@@ -1,24 +1,48 @@
|
|
1
1
|
module Pacer
|
2
2
|
class RubyGraph
|
3
|
-
import com.tinkerpop.blueprints.
|
4
|
-
import com.tinkerpop.blueprints.
|
3
|
+
import com.tinkerpop.blueprints.Element
|
4
|
+
import com.tinkerpop.blueprints.Graph
|
5
|
+
import com.tinkerpop.blueprints.Features
|
5
6
|
|
6
7
|
include Graph
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
FEATURES = Features.new.tap do |features|
|
10
|
+
features.supportsDuplicateEdges = true
|
11
|
+
features.supportsSelfLoops = true
|
12
|
+
features.supportsSerializableObjectProperty = true
|
13
|
+
features.supportsBooleanProperty = true
|
14
|
+
features.supportsDoubleProperty = true
|
15
|
+
features.supportsFloatProperty = true
|
16
|
+
features.supportsIntegerProperty = true
|
17
|
+
features.supportsPrimitiveArrayProperty = true
|
18
|
+
features.supportsUniformListProperty = true
|
19
|
+
features.supportsMixedListProperty = true
|
20
|
+
features.supportsLongProperty = true
|
21
|
+
features.supportsMapProperty = true
|
22
|
+
features.supportsStringProperty = true
|
23
|
+
|
24
|
+
features.ignoresSuppliedIds = false
|
25
|
+
features.isPersistent = false
|
26
|
+
features.isRDFModel = false
|
27
|
+
features.isWrapper = false
|
28
|
+
|
29
|
+
features.supportsIndices = false
|
30
|
+
features.supportsKeyIndices = false
|
31
|
+
features.supportsVertexKeyIndex = false
|
32
|
+
features.supportsEdgeKeyIndex = false
|
33
|
+
features.supportsVertexIndex = false
|
34
|
+
features.supportsEdgeIndex = false
|
35
|
+
features.supportsTransactions = false
|
36
|
+
features.supportsVertexIteration = true
|
37
|
+
features.supportsEdgeIteration = true
|
38
|
+
features.supportsEdgeRetrieval = true
|
39
|
+
features.supportsVertexProperties = true
|
40
|
+
features.supportsEdgeProperties = true
|
41
|
+
features.supportsThreadedTransactions = false
|
18
42
|
end
|
19
43
|
|
20
|
-
def
|
21
|
-
|
44
|
+
def initialize
|
45
|
+
clear
|
22
46
|
end
|
23
47
|
|
24
48
|
def addVertex(id)
|
@@ -36,11 +60,14 @@ module Pacer
|
|
36
60
|
end
|
37
61
|
|
38
62
|
def removeVertex(vertex)
|
63
|
+
vertex.getEdges(Pacer::Pipes::BOTH).each do |e|
|
64
|
+
removeEdge e
|
65
|
+
end
|
39
66
|
@vertices.delete vertex.element_id
|
40
67
|
end
|
41
68
|
|
42
69
|
def getVertices
|
43
|
-
|
70
|
+
@vertices.values.to_iterable
|
44
71
|
end
|
45
72
|
|
46
73
|
def addEdge(id, outVertex, inVertex, label)
|
@@ -58,7 +85,7 @@ module Pacer
|
|
58
85
|
end
|
59
86
|
|
60
87
|
def getEdges
|
61
|
-
|
88
|
+
@edges.values.to_iterable
|
62
89
|
end
|
63
90
|
|
64
91
|
def clear
|
@@ -75,25 +102,19 @@ module Pacer
|
|
75
102
|
other.equal? self
|
76
103
|
end
|
77
104
|
|
78
|
-
def
|
79
|
-
|
105
|
+
def features
|
106
|
+
FEATURES
|
80
107
|
end
|
81
108
|
|
82
|
-
|
83
|
-
false
|
84
|
-
end
|
109
|
+
protected
|
85
110
|
|
86
|
-
def
|
87
|
-
|
111
|
+
def vertex_class
|
112
|
+
RubyVertex
|
88
113
|
end
|
89
114
|
|
90
|
-
def
|
91
|
-
|
115
|
+
def edge_class
|
116
|
+
RubyEdge
|
92
117
|
end
|
93
|
-
|
94
|
-
include GraphExtensions
|
95
|
-
|
96
|
-
protected
|
97
118
|
|
98
119
|
def next_id
|
99
120
|
@next_id += 1
|
@@ -101,10 +122,10 @@ module Pacer
|
|
101
122
|
end
|
102
123
|
|
103
124
|
class RubyElement
|
104
|
-
include com.tinkerpop.blueprints.
|
125
|
+
include com.tinkerpop.blueprints.Element
|
105
126
|
|
106
|
-
def initialize(
|
107
|
-
@
|
127
|
+
def initialize(raw_graph, element_id)
|
128
|
+
@raw_graph = raw_graph
|
108
129
|
@element_id = element_id
|
109
130
|
@properties = {}
|
110
131
|
end
|
@@ -136,6 +157,8 @@ module Pacer
|
|
136
157
|
|
137
158
|
protected
|
138
159
|
|
160
|
+
attr_reader :raw_graph
|
161
|
+
|
139
162
|
def extract_varargs_strings(labels)
|
140
163
|
if labels.first.is_a? ArrayJavaProxy
|
141
164
|
labels.first.map { |l| l.to_s }
|
@@ -147,32 +170,36 @@ module Pacer
|
|
147
170
|
|
148
171
|
|
149
172
|
class RubyVertex < RubyElement
|
150
|
-
include com.tinkerpop.blueprints.
|
173
|
+
include com.tinkerpop.blueprints.Vertex
|
174
|
+
import com.tinkerpop.blueprints.util.VerticesFromEdgesIterable
|
151
175
|
|
152
176
|
def getRawVertex
|
153
177
|
self
|
154
178
|
end
|
155
179
|
|
156
|
-
def
|
157
|
-
|
158
|
-
edges = graph.getEdges.select { |e| e.getInVertex == self and (labels.empty? or labels.include? e.getLabel) }
|
159
|
-
Pacer::Pipes::EnumerablePipe.new edges
|
180
|
+
def getVertices(direction, *labels)
|
181
|
+
VerticesFromEdgesIterable.new self, direction, *labels
|
160
182
|
end
|
161
183
|
|
162
|
-
def
|
184
|
+
def getEdges(direction, *labels)
|
163
185
|
labels = extract_varargs_strings(labels)
|
164
|
-
|
186
|
+
if direction == Pacer::Pipes::BOTH
|
187
|
+
edges = raw_graph.getEdges.select do |e|
|
188
|
+
( (e.getVertex(Pacer::Pipes::IN) == self or e.getVertex(Pacer::Pipes::OUT) == self) and
|
189
|
+
(labels.empty? or labels.include? e.getLabel) )
|
190
|
+
end
|
191
|
+
else
|
192
|
+
edges = raw_graph.getEdges.select { |e| e.getVertex(direction) == self and (labels.empty? or labels.include? e.getLabel) }
|
193
|
+
end
|
165
194
|
Pacer::Pipes::EnumerablePipe.new edges
|
166
195
|
end
|
167
|
-
|
168
|
-
include VertexExtensions
|
169
196
|
end
|
170
197
|
|
171
198
|
class RubyEdge < RubyElement
|
172
|
-
include com.tinkerpop.blueprints.
|
199
|
+
include com.tinkerpop.blueprints.Edge
|
173
200
|
|
174
|
-
def initialize(
|
175
|
-
super(
|
201
|
+
def initialize(raw_graph, id, out_vertex, in_vertex, label)
|
202
|
+
super(raw_graph, id)
|
176
203
|
@out_vertex = out_vertex
|
177
204
|
@in_vertex = in_vertex
|
178
205
|
@label = label.to_s
|
@@ -186,14 +213,12 @@ module Pacer
|
|
186
213
|
@label
|
187
214
|
end
|
188
215
|
|
189
|
-
def
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
216
|
+
def getVertex(direction)
|
217
|
+
if direction == Pacer::Pipes::OUT
|
218
|
+
@out_vertex
|
219
|
+
else
|
220
|
+
@in_vertex
|
221
|
+
end
|
195
222
|
end
|
196
|
-
|
197
|
-
include EdgeExtensions
|
198
223
|
end
|
199
224
|
end
|
data/lib/pacer/blueprints/tg.rb
CHANGED
@@ -1,100 +1,13 @@
|
|
1
1
|
module Pacer
|
2
|
-
import com.tinkerpop.blueprints.
|
3
|
-
import com.tinkerpop.blueprints.pgm.impls.tg.TinkerVertex
|
4
|
-
import com.tinkerpop.blueprints.pgm.impls.tg.TinkerEdge
|
5
|
-
import com.tinkerpop.blueprints.pgm.impls.tg.TinkerElement
|
6
|
-
import com.tinkerpop.blueprints.pgm.impls.tg.TinkerIndex
|
2
|
+
import com.tinkerpop.blueprints.impls.tg.TinkerGraph
|
7
3
|
|
8
|
-
# Create a new TinkerGraph. If path is given,
|
9
|
-
#
|
4
|
+
# Create a new TinkerGraph. If path is given, use Tinkergraph in
|
5
|
+
# its standard simple persistant mode.
|
10
6
|
def self.tg(path = nil)
|
11
|
-
graph = TinkerGraph.new
|
12
7
|
if path
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
# Extend the java class imported from blueprints.
|
20
|
-
class TinkerGraph
|
21
|
-
include GraphMixin
|
22
|
-
include GraphIndicesMixin
|
23
|
-
include GraphTransactionsStub
|
24
|
-
include ManagedTransactionsMixin
|
25
|
-
include Pacer::Core::Route
|
26
|
-
include Pacer::Core::Graph::GraphRoute
|
27
|
-
include Pacer::Core::Graph::GraphIndexRoute
|
28
|
-
|
29
|
-
def element_class
|
30
|
-
TinkerElement
|
31
|
-
end
|
32
|
-
|
33
|
-
def vertex_class
|
34
|
-
TinkerVertex
|
35
|
-
end
|
36
|
-
|
37
|
-
def edge_class
|
38
|
-
TinkerEdge
|
39
|
-
end
|
40
|
-
|
41
|
-
# Override to return an enumeration-friendly array of vertices.
|
42
|
-
def get_vertices
|
43
|
-
getVertices.iterator.to_route(:graph => self, :element_type => :vertex)
|
44
|
-
end
|
45
|
-
|
46
|
-
# Override to return an enumeration-friendly array of edges.
|
47
|
-
def get_edges
|
48
|
-
getEdges.iterator.to_route(:graph => self, :element_type => :edge)
|
49
|
-
end
|
50
|
-
|
51
|
-
def ==(other)
|
52
|
-
other.class == self.class and other.object_id == self.object_id
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
class TinkerIndex
|
58
|
-
include IndexMixin
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
# Extend the java class imported from blueprints.
|
63
|
-
class TinkerVertex
|
64
|
-
include Pacer::Core::Graph::VerticesRoute
|
65
|
-
include ElementMixin
|
66
|
-
include VertexMixin
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
# Extend the java class imported from blueprints.
|
71
|
-
class TinkerEdge
|
72
|
-
include Pacer::Core::Graph::EdgesRoute
|
73
|
-
include ElementMixin
|
74
|
-
include EdgeMixin
|
75
|
-
|
76
|
-
def in_vertex(extensions = nil)
|
77
|
-
v = inVertex
|
78
|
-
v.graph = graph
|
79
|
-
if extensions.is_a? Enumerable
|
80
|
-
v.add_extensions extensions
|
81
|
-
elsif extensions
|
82
|
-
v.add_extensions [extensions]
|
83
|
-
else
|
84
|
-
v
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def out_vertex(extensions = nil)
|
89
|
-
v = outVertex
|
90
|
-
v.graph = graph
|
91
|
-
if extensions.is_a? Enumerable
|
92
|
-
v.add_extensions extensions
|
93
|
-
elsif extensions
|
94
|
-
v.add_extensions [extensions]
|
95
|
-
else
|
96
|
-
v
|
97
|
-
end
|
8
|
+
PacerGraph.new SimpleEncoder, proc { TinkerGraph.new(path) }
|
9
|
+
else
|
10
|
+
PacerGraph.new SimpleEncoder, proc { TinkerGraph.new }
|
98
11
|
end
|
99
12
|
end
|
100
13
|
end
|
data/lib/pacer/blueprints.rb
CHANGED
@@ -2,16 +2,14 @@ module Pacer::Core::Graph
|
|
2
2
|
|
3
3
|
# Basic methods for routes that contain only edges.
|
4
4
|
module EdgesRoute
|
5
|
-
import com.tinkerpop.pipes.transform.OutVertexPipe
|
6
|
-
import com.tinkerpop.pipes.transform.InVertexPipe
|
7
|
-
import com.tinkerpop.pipes.transform.BothVerticesPipe
|
8
|
-
|
9
|
-
include ElementRoute
|
5
|
+
import com.tinkerpop.gremlin.pipes.transform.OutVertexPipe
|
6
|
+
import com.tinkerpop.gremlin.pipes.transform.InVertexPipe
|
7
|
+
import com.tinkerpop.gremlin.pipes.transform.BothVerticesPipe
|
10
8
|
|
11
9
|
# Extends the route with out vertices from this route's matching edges.
|
12
10
|
#
|
13
11
|
# @param [Array<Hash, extension>, Hash, extension] filter see {Pacer::Route#property_filter}
|
14
|
-
# @yield [
|
12
|
+
# @yield [VertexWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
15
13
|
# @return [VerticesRoute]
|
16
14
|
def out_v(*filters, &block)
|
17
15
|
Pacer::Route.property_filter(chain_route(:element_type => :vertex,
|
@@ -23,7 +21,7 @@ module Pacer::Core::Graph
|
|
23
21
|
# Extends the route with in vertices from this route's matching edges.
|
24
22
|
#
|
25
23
|
# @param [Array<Hash, extension>, Hash, extension] filter see {Pacer::Route#property_filter}
|
26
|
-
# @yield [
|
24
|
+
# @yield [VertexWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
27
25
|
# @return [VerticesRoute]
|
28
26
|
def in_v(*filters, &block)
|
29
27
|
Pacer::Route.property_filter(chain_route(:element_type => :vertex,
|
@@ -35,7 +33,7 @@ module Pacer::Core::Graph
|
|
35
33
|
# Extends the route with both in and oud vertices from this route's matching edges.
|
36
34
|
#
|
37
35
|
# @param [Array<Hash, extension>, Hash, extension] filter see {Pacer::Route#property_filter}
|
38
|
-
# @yield [
|
36
|
+
# @yield [VertexWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
39
37
|
# @return [VerticesRoute]
|
40
38
|
def both_v(*filters, &block)
|
41
39
|
Pacer::Route.property_filter(chain_route(:element_type => :vertex,
|
@@ -47,7 +45,7 @@ module Pacer::Core::Graph
|
|
47
45
|
# Extend route with the additional edge label, property and block filters.
|
48
46
|
#
|
49
47
|
# @param [Array<Hash, extension>, Hash, extension] filter see {Pacer::Route#property_filter}
|
50
|
-
# @yield [
|
48
|
+
# @yield [EdgeWrapper(Extensions::BlockFilterElement)] filter proc, see {Pacer::Route#property_filter}
|
51
49
|
# @return [EdgesRoute]
|
52
50
|
def e(*filters, &block)
|
53
51
|
filter(*filters, &block)
|
@@ -58,7 +56,7 @@ module Pacer::Core::Graph
|
|
58
56
|
#
|
59
57
|
# @return [Core::Route]
|
60
58
|
def labels
|
61
|
-
chain_route(:pipe_class => com.tinkerpop.pipes.transform.LabelPipe,
|
59
|
+
chain_route(:pipe_class => com.tinkerpop.gremlin.pipes.transform.LabelPipe,
|
62
60
|
:route_name => 'labels',
|
63
61
|
:element_type => :object)
|
64
62
|
end
|
@@ -80,13 +78,13 @@ module Pacer::Core::Graph
|
|
80
78
|
# @return [element_type(:edge)] The actual type varies based on
|
81
79
|
# which graph is in use.
|
82
80
|
def element_type
|
83
|
-
|
81
|
+
:edge
|
84
82
|
end
|
85
83
|
|
86
84
|
protected
|
87
85
|
|
88
86
|
def id_pipe_class
|
89
|
-
com.tinkerpop.pipes.transform.IdEdgePipe
|
87
|
+
com.tinkerpop.gremlin.pipes.transform.IdEdgePipe
|
90
88
|
end
|
91
89
|
end
|
92
90
|
end
|