pacer 2.0.10.pre-java → 2.0.12-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +5 -13
  2. data/.autotest +0 -4
  3. data/.gitignore +1 -0
  4. data/.travis.yml +2 -2
  5. data/Rakefile +25 -0
  6. data/blog/detach_benchmarks.txt +56 -0
  7. data/ext/.classpath +26 -0
  8. data/ext/.gitignore +44 -0
  9. data/ext/.project +23 -0
  10. data/ext/pom.xml +76 -0
  11. data/ext/src/main/java/com/xnlogic/pacer/pipes/BlackboxPipeline.java +56 -0
  12. data/ext/src/main/java/com/xnlogic/pacer/pipes/CollectionFilterPipe.java +18 -0
  13. data/ext/src/main/java/com/xnlogic/pacer/pipes/EdgesPipe.java +26 -0
  14. data/ext/src/main/java/com/xnlogic/pacer/pipes/ExpandablePipe.java +93 -0
  15. data/ext/src/main/java/com/xnlogic/pacer/pipes/IdCollectionFilterPipe.java +50 -0
  16. data/ext/src/main/java/com/xnlogic/pacer/pipes/IsEmptyPipe.java +35 -0
  17. data/ext/src/main/java/com/xnlogic/pacer/pipes/IsUniquePipe.java +58 -0
  18. data/ext/src/main/java/com/xnlogic/pacer/pipes/LabelCollectionFilterPipe.java +32 -0
  19. data/ext/src/main/java/com/xnlogic/pacer/pipes/LabelPrefixPipe.java +23 -0
  20. data/ext/src/main/java/com/xnlogic/pacer/pipes/NeverPipe.java +10 -0
  21. data/ext/src/main/java/com/xnlogic/pacer/pipes/VerticesPipe.java +26 -0
  22. data/ext/src/test/java/com/xnlogic/pacer/pipes/BlackboxPipelineTest.java +33 -0
  23. data/ext/src/test/java/com/xnlogic/pacer/pipes/CollectionFilterPipeTest.java +50 -0
  24. data/ext/src/test/java/com/xnlogic/pacer/pipes/EdgesPipeTest.java +103 -0
  25. data/ext/src/test/java/com/xnlogic/pacer/pipes/ExpandablePipeTest.java +66 -0
  26. data/ext/src/test/java/com/xnlogic/pacer/pipes/IdCollectionFilterPipeTest.java +85 -0
  27. data/ext/src/test/java/com/xnlogic/pacer/pipes/IsUniquePipeTest.java +62 -0
  28. data/ext/src/test/java/com/xnlogic/pacer/pipes/LabelCollectionFilterPipeTest.java +97 -0
  29. data/ext/src/test/java/com/xnlogic/pacer/pipes/LabelPrefixPipeTest.java +69 -0
  30. data/ext/src/test/java/com/xnlogic/pacer/pipes/NeverPipeTest.java +17 -0
  31. data/ext/src/test/java/com/xnlogic/pacer/pipes/VerticesPipeTest.java +97 -0
  32. data/lib/pacer/core/graph/element_route.rb +2 -2
  33. data/lib/pacer/core/graph/path_route.rb +2 -2
  34. data/lib/pacer/core/route.rb +77 -1
  35. data/lib/pacer/filter/property_filter/edge_filters.rb +5 -1
  36. data/lib/pacer/filter/property_filter/filters.rb +23 -7
  37. data/lib/pacer/pipe/path_wrapping_pipe.rb +14 -3
  38. data/lib/pacer/pipe/wrapping_pipe.rb +15 -4
  39. data/lib/pacer/pipes.rb +15 -13
  40. data/lib/pacer/route.rb +1 -0
  41. data/lib/pacer/side_effect/as_var.rb +1 -1
  42. data/lib/pacer/side_effect/is_unique.rb +2 -2
  43. data/lib/pacer/transform/branch.rb +1 -1
  44. data/lib/pacer/transform/lookup_ids.rb +1 -1
  45. data/lib/pacer/transform/path_tree.rb +1 -1
  46. data/lib/pacer/transform/reduce.rb +1 -1
  47. data/lib/pacer/transform/sort_section.rb +17 -9
  48. data/lib/pacer/transform/stream_sort.rb +1 -0
  49. data/lib/pacer/transform/stream_uniq.rb +1 -0
  50. data/lib/pacer/transform/wrapped_path.rb +1 -1
  51. data/lib/pacer/version.rb +1 -1
  52. data/lib/pacer/visitors/section.rb +10 -3
  53. data/lib/pacer/visitors/visits_section.rb +4 -4
  54. data/lib/pacer-ext.jar +0 -0
  55. data/lib/pacer.rb +1 -0
  56. data/pacer.gemspec +2 -1
  57. data/spec/pacer/filter/property_filter_spec.rb +17 -0
  58. data/spec/pacer/transform/path_spec.rb +10 -0
  59. data/spec/pacer/transform/sort_section_spec.rb +8 -1
  60. metadata +59 -30
  61. data/lib/pacer/pipe/blackbox_pipeline.rb +0 -55
  62. data/lib/pacer/pipe/collection_filter_pipe.rb +0 -12
  63. data/lib/pacer/pipe/edges_pipe.rb +0 -22
  64. data/lib/pacer/pipe/expandable_pipe.rb +0 -51
  65. data/lib/pacer/pipe/id_collection_filter_pipe.rb +0 -37
  66. data/lib/pacer/pipe/is_empty_pipe.rb +0 -23
  67. data/lib/pacer/pipe/is_unique_pipe.rb +0 -51
  68. data/lib/pacer/pipe/label_collection_filter_pipe.rb +0 -15
  69. data/lib/pacer/pipe/label_prefix_pipe.rb +0 -15
  70. data/lib/pacer/pipe/never_pipe.rb +0 -9
  71. data/lib/pacer/pipe/vertices_pipe.rb +0 -22
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ODM1N2U4OTViZWJmYjM1MGQzNmFjYzU3NDAxMjVjM2E4OTExNTZlMw==
5
- data.tar.gz: !binary |-
6
- ZGYwYjg5MjgxZjVkYjVhNGU3YjA3MGVjMGI5ZWJkZGMwMjE0OTEwMA==
2
+ SHA1:
3
+ metadata.gz: c1d6ed458658599f541aebf48b0858211c9c5a12
4
+ data.tar.gz: e8da00bad64ae64ee08e59ed07640b4ba61a8851
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NjY3OTJhMWEzNzQ1MmFhM2FlZTA4MmUzOWVkMGQyZjkzNDEyMWMwOWMzZTdj
10
- YmY5NjY5NTEyYjhjMTc0NzkwNGZlNTM1YWQ2ODRmY2JkYmQ2MWJhNWU5Y2E1
11
- NmQ2NGYzN2YzOTcwM2Q3ZTFiMjQwZGZiNGMxNTZlMWM5OTUyNDA=
12
- data.tar.gz: !binary |-
13
- YzU5NWU3NTUwZGRjMjNjMGVhOGFjYTA4OTQ2ZDVjZDkwYTM5YzNmYjhkNGNl
14
- NzQ2M2U1NzQ4MmI2MmY5YTAxOWFlNzZjOGI3MmQ1N2U0Mzk3NjQ4ODdmM2Jl
15
- ZWNlMzgzODMzYTljNWRhODY3OTNkYTY2MmM2MWE4ZWM5NWYyMTU=
6
+ metadata.gz: a6ba6daeb5f72cbafbfe17664c1188089e9a939194c3b5810ebbf38851a473e21b7bf9a95df25215671ce38deca8dd543adfc4334ec70f6dc502a652e13ae606
7
+ data.tar.gz: b27450c26b112b401a905ef1b5a889b213c5166615440eb7c1b931bb909891e6972102470d803306c102d67c18cab19008a7fe4c0cbdad69635738f9458a72ef
data/.autotest CHANGED
@@ -1,7 +1,3 @@
1
- require 'autotest/growl'
2
-
3
- Autotest::Growl::clear_terminal = false
4
-
5
1
  Autotest.add_hook(:initialize) {|at|
6
2
  at.add_exception %r{\.git} # ignore Version Control System
7
3
  at.add_exception %r{/\.} # ignore any file that starts with a . (dot)
data/.gitignore CHANGED
@@ -34,3 +34,4 @@ vendor/
34
34
  private/
35
35
  Gemfile-custom
36
36
  Jarfile.lock
37
+ Jarfile.*.lock
data/.travis.yml CHANGED
@@ -1,13 +1,13 @@
1
1
  before_install:
2
2
  - rvm uninstall jruby
3
3
  - rvm use jruby-1.7.18 --install
4
+ - export JRUBY_OPTS=--dev
4
5
  language: ruby
5
6
  jdk:
6
7
  - oraclejdk7
7
- - oraclejdk8
8
8
  rvm:
9
9
  - jruby-1.7.18
10
- script: bundle exec rspec && (bundle exec rake release || echo "Not released")
10
+ script: bundle exec rake spec && (bundle exec rake release || echo "Not released")
11
11
  deploy:
12
12
  provider: rubygems
13
13
  api_key:
data/Rakefile CHANGED
@@ -9,7 +9,14 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
9
9
  spec.pattern = FileList['spec/**/*_spec.rb']
10
10
  end
11
11
 
12
+ task :mvn_tests do
13
+ cd 'ext' do
14
+ sh 'mvn test'
15
+ end
16
+ end
17
+
12
18
  task :default => :spec
19
+ task :spec => :compile
13
20
 
14
21
  task :check_18_mode do
15
22
  if RUBY_VERSION !~ /1\.8/
@@ -20,3 +27,21 @@ end
20
27
 
21
28
  require 'xn_gem_release_tasks'
22
29
  XNGemReleaseTasks.setup Pacer, 'lib/pacer/version.rb'
30
+
31
+ task :build => :compile
32
+
33
+ require 'rake/javaextensiontask'
34
+ Rake::JavaExtensionTask.new('pacer-ext') do |ext|
35
+ require 'lock_jar'
36
+ LockJar.lock
37
+ locked_jars = LockJar.load
38
+
39
+ ext.name = 'pacer-ext'
40
+ ext.ext_dir = 'ext/src/main/java'
41
+ ext.lib_dir = 'lib'
42
+ ext.source_version = '1.7'
43
+ ext.target_version = '1.7'
44
+ ext.classpath = locked_jars.map {|x| File.expand_path x}.join ':'
45
+ end
46
+
47
+ task :compile => :mvn_tests
@@ -0,0 +1,56 @@
1
+ sp = g.v.detach { |v| v.out_e.in_v(name: 'Joe').element_ids }
2
+ spp = sp.call
3
+ Benchmark.bmbm { |x|
4
+ x.report('a') { 50000.times { g.v.detach { |v| v.out_e.in_v(name: 'Joe').element_ids } } }
5
+ x.report('b') { 50000.times { sp.call } }
6
+ x.report('c') { 50000.times { sp.call.call(v) } }
7
+ x.report('d') { 50000.times { spp.call(v) } }
8
+ x.report('e') { 50000.times { v.out_e.in_v(name: 'Joe').element_ids.to_a } }
9
+ x.report('f') { 50000.times { v.out_edges.map { |e| e.in_vertex }.select { |z| z[:name] == 'Joe' }.map { |z| z.element_id }.first } }
10
+ }
11
+
12
+ Rehearsal -------------------------------------
13
+ a 7.080000 0.070000 7.150000 ( 6.729000)
14
+ b 0.890000 0.010000 0.900000 ( 0.668000)
15
+ c 3.530000 0.080000 3.610000 ( 1.760000)
16
+ d 0.080000 0.000000 0.080000 ( 0.083000)
17
+ e 7.500000 0.020000 7.520000 ( 6.873000)
18
+ f 15.830000 0.030000 15.860000 ( 15.594000)
19
+ --------------------------- total: 35.120000sec
20
+
21
+ user system total real
22
+ a 6.660000 0.010000 6.670000 ( 6.449000)
23
+ b 0.660000 0.000000 0.660000 ( 0.587000)
24
+ c 3.840000 0.040000 3.880000 ( 1.883000)
25
+ d 0.090000 0.000000 0.090000 ( 0.083000)
26
+ e 7.450000 0.030000 7.480000 ( 6.951000)
27
+ f 14.720000 0.020000 14.740000 ( 14.519000)
28
+
29
+
30
+
31
+ sp = g.v.detach { |v| v.out_e.in_v(name: 'Joe') }
32
+ spp = sp.call g
33
+ Benchmark.bmbm { |x|
34
+ x.report('a') { 50000.times { g.v.detach { |v| v.out_e.in_v(name: 'Joe') } } }
35
+ x.report('b') { 50000.times { sp.call } }
36
+ x.report('c') { 50000.times { sp.call.call(v) } }
37
+ x.report('d') { 50000.times { spp.call(v) } }
38
+ x.report('e') { 50000.times { v.out_e.in_v(name: 'Joe').to_a } }
39
+ x.report('f') { 50000.times { v.out_edges.map { |e| e.in_vertex }.select { |z| z[:name] == 'Joe' }.first } }
40
+ }
41
+ Rehearsal -------------------------------------
42
+ a 6.500000 0.060000 6.560000 ( 6.427000)
43
+ b 0.920000 0.020000 0.940000 ( 0.636000)
44
+ c 2.790000 0.070000 2.860000 ( 2.444000)
45
+ d 1.190000 0.010000 1.200000 ( 1.089000)
46
+ e 8.160000 0.020000 8.180000 ( 7.638000)
47
+ f 15.970000 0.030000 16.000000 ( 15.868000)
48
+ --------------------------- total: 35.740000sec
49
+
50
+ user system total real
51
+ a 6.250000 0.010000 6.260000 ( 6.079000)
52
+ b 1.710000 0.030000 1.740000 ( 0.931000)
53
+ c 2.770000 0.010000 2.780000 ( 2.301000)
54
+ d 1.170000 0.010000 1.180000 ( 1.032000)
55
+ e 7.950000 0.010000 7.960000 ( 7.528000)
56
+ f 14.820000 0.030000 14.850000 ( 14.777000)
data/ext/.classpath ADDED
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <classpath>
3
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
4
+ <attributes>
5
+ <attribute name="optional" value="true"/>
6
+ <attribute name="maven.pomderived" value="true"/>
7
+ </attributes>
8
+ </classpathentry>
9
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
10
+ <attributes>
11
+ <attribute name="optional" value="true"/>
12
+ <attribute name="maven.pomderived" value="true"/>
13
+ </attributes>
14
+ </classpathentry>
15
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
16
+ <attributes>
17
+ <attribute name="maven.pomderived" value="true"/>
18
+ </attributes>
19
+ </classpathentry>
20
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
21
+ <attributes>
22
+ <attribute name="maven.pomderived" value="true"/>
23
+ </attributes>
24
+ </classpathentry>
25
+ <classpathentry kind="output" path="target/classes"/>
26
+ </classpath>
data/ext/.gitignore ADDED
@@ -0,0 +1,44 @@
1
+ Created by https://www.gitignore.io
2
+
3
+ ### Maven ###
4
+ target/
5
+ pom.xml.tag
6
+ pom.xml.releaseBackup
7
+ pom.xml.versionsBackup
8
+ pom.xml.next
9
+ release.properties
10
+
11
+ ### TODO: Move this IDE-specific declarations out of here ###
12
+ ### Eclipse ###
13
+ *.pydevproject
14
+ .metadata
15
+ .gradle
16
+ bin/
17
+ tmp/
18
+ *.tmp
19
+ *.bak
20
+ *.swp
21
+ *~.nib
22
+ local.properties
23
+ .settings/
24
+ .loadpath
25
+
26
+ # External tool builders
27
+ .externalToolBuilders/
28
+
29
+ # Locally stored "Eclipse launch configurations"
30
+ *.launch
31
+
32
+ # CDT-specific
33
+ .cproject
34
+
35
+ # PDT-specific
36
+ .buildpath
37
+
38
+ # sbteclipse plugin
39
+ .target
40
+
41
+ # TeXlipse plugin
42
+ .texlipse
43
+
44
+
data/ext/.project ADDED
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>pacer</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.jdt.core.javabuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>org.eclipse.m2e.core.maven2Builder</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ </buildSpec>
19
+ <natures>
20
+ <nature>org.eclipse.jdt.core.javanature</nature>
21
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
22
+ </natures>
23
+ </projectDescription>
data/ext/pom.xml ADDED
@@ -0,0 +1,76 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
+ <modelVersion>4.0.0</modelVersion>
3
+ <groupId>pacer</groupId>
4
+ <artifactId>pacer</artifactId>
5
+ <packaging>jar</packaging>
6
+ <version>0.1.0-SNAPSHOT</version>
7
+ <name>pacer</name>
8
+ <description>FIXME: write description</description>
9
+ <url>http://example.com/FIXME</url>
10
+ <licenses>
11
+ <license>
12
+ <name>Eclipse Public License</name>
13
+ <url>http://www.eclipse.org/legal/epl-v10.html</url>
14
+ </license>
15
+ </licenses>
16
+ <build>
17
+ <testSourceDirectory>src/test/java</testSourceDirectory>
18
+ <plugins>
19
+ <plugin>
20
+ <groupId>org.codehaus.mojo</groupId>
21
+ <artifactId>build-helper-maven-plugin</artifactId>
22
+ <version>1.7</version>
23
+ <executions>
24
+ <execution>
25
+ <id>add-source</id>
26
+ <phase>generate-sources</phase>
27
+ <goals>
28
+ <goal>add-source</goal>
29
+ </goals>
30
+ <configuration>
31
+ <sources>
32
+ <source>dev</source>
33
+ <source>src/java</source>
34
+ </sources>
35
+ </configuration>
36
+ </execution>
37
+ </executions>
38
+ </plugin>
39
+ <plugin>
40
+ <groupId>org.apache.maven.plugins</groupId>
41
+ <artifactId>maven-surefire-plugin</artifactId>
42
+ <version>2.18</version>
43
+ </plugin>
44
+ </plugins>
45
+ </build>
46
+ <repositories>
47
+ <repository>
48
+ <id>central</id>
49
+ <url>https://repo1.maven.org/maven2/</url>
50
+ <snapshots>
51
+ <enabled>false</enabled>
52
+ </snapshots>
53
+ <releases>
54
+ <enabled>true</enabled>
55
+ </releases>
56
+ </repository>
57
+ </repositories>
58
+ <dependencies>
59
+ <dependency>
60
+ <groupId>com.tinkerpop.blueprints</groupId>
61
+ <artifactId>blueprints-core</artifactId>
62
+ <version>2.6.0</version>
63
+ </dependency>
64
+ <dependency>
65
+ <groupId>com.tinkerpop</groupId>
66
+ <artifactId>pipes</artifactId>
67
+ <version>2.6.0</version>
68
+ </dependency>
69
+ <dependency>
70
+ <groupId>junit</groupId>
71
+ <artifactId>junit</artifactId>
72
+ <version>4.11</version>
73
+ </dependency>
74
+ </dependencies>
75
+ </project>
76
+
@@ -0,0 +1,56 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import java.util.Iterator;
4
+ import java.util.List;
5
+
6
+ import com.tinkerpop.pipes.Pipe;
7
+
8
+ public class BlackboxPipeline<S, E> implements Pipe<S, E> {
9
+ private Pipe<S, ?> startPipe;
10
+ private Pipe<?, E> endPipe;
11
+
12
+ public BlackboxPipeline(Pipe<S, ?> startPipe, Pipe<?, E> endPipe) {
13
+ this.startPipe = startPipe;
14
+ this.endPipe = endPipe;
15
+ }
16
+
17
+ public void setStarts(final Iterator<S> pipe) {
18
+ this.startPipe.setStarts(pipe);
19
+ }
20
+
21
+ public void setStarts(final Iterable<S> pipe) {
22
+ this.setStarts(pipe.iterator());
23
+ }
24
+
25
+ public E next() {
26
+ return this.endPipe.next();
27
+ }
28
+
29
+ public boolean hasNext() {
30
+ return this.endPipe.hasNext();
31
+ }
32
+
33
+ public void reset() {
34
+ this.endPipe.reset();
35
+ }
36
+
37
+ public void enablePath(boolean enable) {
38
+ this.endPipe.enablePath(enable);
39
+ }
40
+
41
+ public List<?> getCurrentPath() {
42
+ return this.endPipe.getCurrentPath();
43
+ }
44
+
45
+ public Iterator<E> iterator() {
46
+ return this.endPipe.iterator();
47
+ }
48
+
49
+ public void remove() {
50
+ throw new UnsupportedOperationException();
51
+ }
52
+
53
+ public String toString() {
54
+ return "[" + this.startPipe.toString() + "..." + this.endPipe.toString() + "]";
55
+ }
56
+ }
@@ -0,0 +1,18 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import com.tinkerpop.blueprints.Contains;
4
+ import com.tinkerpop.pipes.util.structures.AsMap;
5
+
6
+ import java.util.Collection;
7
+
8
+ public class CollectionFilterPipe<S> extends com.tinkerpop.pipes.filter.CollectionFilterPipe<S> {
9
+
10
+ public CollectionFilterPipe(final Collection<S> storedCollection, final Contains contains) {
11
+ super(storedCollection, contains);
12
+ }
13
+
14
+ public CollectionFilterPipe(final Contains contains, final AsMap asMap, final String... namedSteps) {
15
+ super(contains, asMap, namedSteps);
16
+ }
17
+
18
+ }
@@ -0,0 +1,26 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import java.util.Iterator;
4
+
5
+ import com.tinkerpop.blueprints.Edge;
6
+ import com.tinkerpop.blueprints.Graph;
7
+ import com.tinkerpop.pipes.AbstractPipe;
8
+
9
+ public class EdgesPipe extends AbstractPipe<Graph, Edge> {
10
+ private Iterator<Edge> iter;
11
+ private Graph starts;
12
+
13
+ public void setStarts(Iterator<Graph> starts) {
14
+ // TODO: Error checking?
15
+ this.starts = (Graph)starts.next();
16
+ this.iter = this.starts.getEdges().iterator();
17
+ }
18
+
19
+ protected Edge processNextStart() {
20
+ return this.iter.next();
21
+ }
22
+
23
+ public void reset() {
24
+ this.iter = this.starts.getEdges().iterator();
25
+ }
26
+ }
@@ -0,0 +1,93 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import com.tinkerpop.pipes.AbstractPipe;
4
+ import com.tinkerpop.pipes.Pipe;
5
+ import java.util.Queue;
6
+ import java.util.LinkedList;
7
+ import java.util.List;
8
+ import java.util.ArrayList;
9
+
10
+ public class ExpandablePipe<T> extends AbstractPipe<T, T> {
11
+ private Queue<EPTriple> queue;
12
+ private Object metadata;
13
+ private Object nextMetadata;
14
+
15
+ private List path;
16
+ private List nextPath;
17
+
18
+ public ExpandablePipe() {
19
+ this.queue = new LinkedList<EPTriple>();
20
+ }
21
+
22
+ public void add(T element, Object metadata, List path) {
23
+ this.queue.add(new EPTriple(element, metadata, path));
24
+ }
25
+
26
+ public void add(T element, Object metadata) {
27
+ this.add(element, metadata, null);
28
+ }
29
+
30
+ public void add(T element) {
31
+ this.add(element, null, null);
32
+ }
33
+
34
+ public Object getMetadata() {
35
+ return this.metadata;
36
+ }
37
+
38
+ public T next() {
39
+ T toReturn = null;
40
+
41
+ try {
42
+ toReturn = super.next();
43
+ } finally {
44
+ this.path = this.nextPath;
45
+ this.metadata = this.nextMetadata;
46
+ }
47
+
48
+ return toReturn;
49
+ }
50
+
51
+ protected T processNextStart() {
52
+ if (this.queue.isEmpty()) {
53
+ this.nextMetadata = null;
54
+ T r = this.starts.next();
55
+
56
+ if (this.pathEnabled && this.starts instanceof Pipe) {
57
+ this.nextPath = ((Pipe)this.starts).getCurrentPath();
58
+ } else {
59
+ this.nextPath = new ArrayList();
60
+ }
61
+ return r;
62
+ } else {
63
+ EPTriple triple = this.queue.remove();
64
+ this.nextMetadata = triple.metadata;
65
+ this.nextPath = triple.path;
66
+ return triple.element;
67
+ }
68
+ }
69
+
70
+ public List getPathToHere() {
71
+ List path = new ArrayList();
72
+
73
+ if (this.path != null) {
74
+ for (Object p : this.path) {
75
+ path.add(p);
76
+ }
77
+ }
78
+
79
+ return path;
80
+ }
81
+
82
+ private class EPTriple {
83
+ public T element;
84
+ public Object metadata;
85
+ public List path;
86
+
87
+ public EPTriple(T element, Object metadata, List path) {
88
+ this.element = element;
89
+ this.metadata = metadata;
90
+ this.path = path;
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,50 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import java.util.Collection;
4
+ import java.util.HashSet;
5
+ import java.util.Set;
6
+
7
+ import com.tinkerpop.blueprints.Contains;
8
+ import com.tinkerpop.blueprints.Element;
9
+ import com.tinkerpop.pipes.AbstractPipe;
10
+
11
+ public class IdCollectionFilterPipe<E extends Element> extends AbstractPipe<E, E> {
12
+ private Set ids;
13
+ private boolean containsIn;
14
+
15
+ // TODO: Consider making this a derived exception. Also, this constructor is the reverse of the Ruby one. Is this ok?
16
+ // Also also, is an Object array the way to go? Can we nail down the type further?
17
+ public IdCollectionFilterPipe(final Collection ids, final Contains comparison) throws RuntimeException {
18
+ super();
19
+ if (ids instanceof Set) {
20
+ this.ids = (Set)ids;
21
+ } else if (ids == null) {
22
+ this.ids = new HashSet();
23
+ } else {
24
+ this.ids = new HashSet();
25
+ this.ids.addAll(ids);
26
+ }
27
+ if (comparison == Contains.IN)
28
+ this.containsIn = true;
29
+ else if (comparison == Contains.NOT_IN)
30
+ this.containsIn = false;
31
+ else
32
+ throw new RuntimeException("Unknown comparison type for ID collection filter");
33
+ }
34
+
35
+ protected E processNextStart() {
36
+ if (this.containsIn) {
37
+ while (true) {
38
+ E e = this.starts.next();
39
+ if (e != null && this.ids.contains(e.getId()))
40
+ return e;
41
+ }
42
+ } else {
43
+ while (true) {
44
+ E e = this.starts.next();
45
+ if (e != null && !this.ids.contains(e.getId()))
46
+ return e;
47
+ }
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,35 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import java.util.NoSuchElementException;
4
+
5
+ import com.tinkerpop.pipes.AbstractPipe;
6
+ import com.tinkerpop.pipes.util.FastNoSuchElementException;
7
+
8
+ public class IsEmptyPipe<T> extends AbstractPipe<T, Boolean> {
9
+ private boolean raise;
10
+
11
+ public IsEmptyPipe() {
12
+ super();
13
+ this.raise = false;
14
+ }
15
+
16
+ protected Boolean processNextStart() throws NoSuchElementException{
17
+ if (this.raise) {
18
+ throw FastNoSuchElementException.instance();
19
+ }
20
+
21
+ try {
22
+ this.starts.next();
23
+ this.raise = true;
24
+ } catch (NoSuchElementException nsee) {
25
+ return true;
26
+ }
27
+
28
+ throw FastNoSuchElementException.instance();
29
+ }
30
+
31
+ public void reset() {
32
+ this.raise = false;
33
+ super.reset();
34
+ }
35
+ }
@@ -0,0 +1,58 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import java.util.NoSuchElementException;
4
+
5
+ import com.tinkerpop.pipes.AbstractPipe;
6
+ import com.tinkerpop.pipes.filter.DuplicateFilterPipe;
7
+ import com.tinkerpop.pipes.util.iterators.ExpandableIterator;
8
+
9
+ public class IsUniquePipe<T> extends AbstractPipe<T, T> {
10
+ private boolean unique;
11
+ private ExpandableIterator<T> expando;
12
+ private DuplicateFilterPipe<T> uniquePipe;
13
+
14
+ public IsUniquePipe() {
15
+ super();
16
+ this.prepareState();
17
+ }
18
+
19
+ protected T processNextStart() {
20
+ T value = this.starts.next();
21
+
22
+ if (this.unique)
23
+ this.checkUniqueness(value);
24
+
25
+ return value;
26
+ }
27
+
28
+ public void reset() {
29
+ super.reset();
30
+ this.prepareState();
31
+ }
32
+
33
+ public boolean isUnique() {
34
+ return this.unique;
35
+ }
36
+
37
+ public boolean getSideEffect() {
38
+ return this.unique;
39
+ }
40
+
41
+ protected void checkUniqueness(T value) {
42
+ try {
43
+ this.expando.add(value);
44
+ this.uniquePipe.next();
45
+ } catch (NoSuchElementException nsee) {
46
+ this.unique = false;
47
+ this.uniquePipe = null;
48
+ this.expando = null;
49
+ }
50
+ }
51
+
52
+ protected void prepareState() {
53
+ this.unique = true;
54
+ this.expando = new ExpandableIterator<T>();
55
+ this.uniquePipe = new DuplicateFilterPipe<T>();
56
+ this.uniquePipe.setStarts(this.expando);
57
+ }
58
+ }