Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 24, 2011
Darrick Wiebe Started on OrientDB Graph support but currently not working.
Right now Orient crashes half way through the test suite. I'm not sure if it's something I do or not, it happens always on reset between sections of the test suite.

To reproduce, install JRuby 1.6.0 and run on the command line:
  gem install bundler
  bundle install
  GRAPHS=orient bundle exec autotest
3f08a2a
View
2 .rspec
@@ -1 +1 @@
-#--format d
+--format d
View
1 lib/pacer.rb
@@ -14,6 +14,7 @@ module Pacer
end
require File.join(PATH, 'vendor/blueprints-neo4j-adapter-0.2-SNAPSHOT-standalone.jar')
+ require File.join(PATH, 'vendor/blueprints-orientdb-adapter-0.2-SNAPSHOT-standalone.jar')
START_TIME = Time.now
end
View
1 lib/pacer/blueprints.rb
@@ -1,2 +1,3 @@
require 'pacer/blueprints/tg'
require 'pacer/blueprints/neo4j'
+require 'pacer/blueprints/orient'
View
128 lib/pacer/blueprints/orient.rb
@@ -0,0 +1,128 @@
+module Pacer
+ OrientGraph = com.tinkerpop.blueprints.pgm.impls.orientdb.OrientGraph
+ OrientVertex = com.tinkerpop.blueprints.pgm.impls.orientdb.OrientVertex
+ OrientEdge = com.tinkerpop.blueprints.pgm.impls.orientdb.OrientEdge
+ OrientElement = com.tinkerpop.blueprints.pgm.impls.orientdb.OrientElement
+ OrientIndex = com.tinkerpop.blueprints.pgm.impls.orientdb.OrientIndex
+
+ class << self
+ # for local graphs use orient("local:#{ path }")
+ def orient(url, args = {})
+ Pacer.starting_graph(self, url) do
+ if args[:username]
+ OrientGraph.new(url, args[:username], args[:password])
+ else
+ OrientGraph.new(url)
+ end
+ end
+ end
+ end
+
+ class OrientGraph
+ include GraphMixin
+ include GraphTransactionsMixin
+ include ManagedTransactionsMixin
+ include Pacer::Core::Route
+ include Pacer::Core::Graph::GraphRoute
+
+ # Override to return an enumeration-friendly array of vertices.
+ def get_vertices
+ getVertices.to_route(:graph => self, :element_type => :vertex)
+ end
+
+ # Override to return an enumeration-friendly array of edges.
+ def get_edges
+ getEdges.to_route(:graph => self, :element_type => :edge)
+ end
+
+ def element_type(et = nil)
+ return nil unless et
+ if et == OrientVertex or et == OrientEdge or et == OrientElement
+ et
+ else
+ case et
+ when :vertex, com.tinkerpop.blueprints.pgm.Vertex, VertexMixin
+ OrientVertex
+ when :edge, com.tinkerpop.blueprints.pgm.Edge, EdgeMixin
+ OrientEdge
+ when :mixed, com.tinkerpop.blueprints.pgm.Element, ElementMixin
+ OrientElement
+ when :object
+ Object
+ else
+ if et == Object
+ Object
+ elsif et == OrientVertex.java_class.to_java
+ OrientVertex
+ elsif et == OrientEdge.java_class.to_java
+ OrientEdge
+ else
+ raise ArgumentError, 'Element type may be one of :vertex or :edge'
+ end
+ end
+ end
+ end
+
+ def sanitize_properties(props)
+ props
+ end
+
+ def encode_property(value)
+ if value.is_a? String
+ value = value.strip
+ value unless value == ''
+ else
+ value
+ end
+ end
+
+ def decode_property(value)
+ value
+ end
+ end
+
+
+ class OrientIndex
+ include IndexMixin
+ end
+
+
+ # Extend the java class imported from blueprints.
+ class OrientVertex
+ include Pacer::Core::Graph::VerticesRoute
+ include ElementMixin
+ include VertexMixin
+ end
+
+
+ # Extend the java class imported from blueprints.
+ class OrientEdge
+ include Pacer::Core::Graph::EdgesRoute
+ include ElementMixin
+ include EdgeMixin
+
+ def in_vertex(extensions = nil)
+ v = inVertex
+ v.graph = graph
+ if extensions.is_a? Enumerable
+ v.add_extensions extensions
+ elsif extensions
+ v.add_extensions [extensions]
+ else
+ v
+ end
+ end
+
+ def out_vertex(extensions = nil)
+ v = outVertex
+ v.graph = graph
+ if extensions.is_a? Enumerable
+ v.add_extensions extensions
+ elsif extensions
+ v.add_extensions [extensions]
+ else
+ v
+ end
+ end
+ end
+end
View
133 spec/pacer/blueprints/orient_spec.rb
@@ -0,0 +1,133 @@
+require 'spec_helper'
+
+for_orient do
+ describe Pacer::OrientGraph do
+ let(:v0) { graph.create_vertex }
+ let(:v1) { graph.create_vertex }
+ let(:e0) { graph.create_edge '0', v0, v1, :default }
+
+ describe '#element_type' do
+ context 'invalid' do
+ it { expect { graph.element_type(:nothing) }.to raise_error(ArgumentError) }
+ end
+
+ context ':vertex' do
+ subject { graph.element_type(:vertex) }
+ it { should == com.tinkerpop.blueprints.pgm.impls.orientdb.OrientVertex }
+ end
+
+ context 'a vertex' do
+ subject { graph.element_type(v0) }
+ it { should == com.tinkerpop.blueprints.pgm.impls.orientdb.OrientVertex }
+ end
+
+ context ':edge' do
+ subject { graph.element_type(:edge) }
+ it { should == com.tinkerpop.blueprints.pgm.impls.orientdb.OrientEdge }
+ end
+
+ context 'an edge' do
+ subject { graph.element_type(e0) }
+ it { should == com.tinkerpop.blueprints.pgm.impls.orientdb.OrientEdge }
+ end
+
+ context ':mixed' do
+ subject { graph.element_type(:mixed) }
+ it { should == com.tinkerpop.blueprints.pgm.impls.orientdb.OrientElement }
+ end
+
+ context ':object' do
+ subject { graph.element_type(:object) }
+ it { should == Object }
+ end
+
+ context 'from element_type' do
+ context ':vertex' do
+ subject { graph.element_type(graph.element_type :vertex) }
+ it { should == com.tinkerpop.blueprints.pgm.impls.orientdb.OrientVertex }
+ end
+
+ context ':edge' do
+ subject { graph.element_type(graph.element_type :edge) }
+ it { should == com.tinkerpop.blueprints.pgm.impls.orientdb.OrientEdge }
+ end
+
+ context ':mixed' do
+ subject { graph.element_type(graph.element_type :mixed) }
+ it { should == com.tinkerpop.blueprints.pgm.impls.orientdb.OrientElement }
+ end
+
+ context ':object' do
+ subject { graph.element_type(graph.element_type :object) }
+ it { should == Object }
+ end
+ end
+
+ context 'from index_class' do
+ context ':vertex' do
+ subject { graph.element_type(graph.index_class :vertex) }
+ it { should == com.tinkerpop.blueprints.pgm.impls.orientdb.OrientVertex }
+ end
+
+ context ':edge' do
+ subject { graph.element_type(graph.index_class :edge) }
+ it { should == com.tinkerpop.blueprints.pgm.impls.orientdb.OrientEdge }
+ end
+ end
+ end
+
+ describe '#indices' do
+ subject { graph.indices.to_a }
+ its(:count) { should == 2 }
+ end
+
+ describe '#sanitize_properties' do
+ specify 'returns its argument' do
+ arg = { :a => 1 }
+ graph.sanitize_properties(arg).should equal(arg)
+ end
+ end
+
+ describe '#in_vertex' do
+ it 'should wrap the vertex' do
+ v = e0.in_vertex(Tackle::SimpleMixin)
+ v.should == v1
+ v.extensions.should include(Tackle::SimpleMixin)
+ end
+
+ it 'should wrap the vertex 2' do
+ v = e0.in_vertex([Tackle::SimpleMixin])
+ v.should == v1
+ v.extensions.should include(Tackle::SimpleMixin)
+ end
+ end
+
+ describe '#out_vertex' do
+ it 'should wrap the vertex' do
+ v = e0.out_vertex(Tackle::SimpleMixin)
+ v.should == v0
+ v.extensions.should include(Tackle::SimpleMixin)
+ end
+
+ it 'should wrap the vertex 2' do
+ v = e0.out_vertex([Tackle::SimpleMixin])
+ v.should == v0
+ v.extensions.should include(Tackle::SimpleMixin)
+ end
+ end
+
+ describe '#get_vertices' do
+ before { e0 }
+ subject { graph.get_vertices }
+ it { should be_a(Pacer::Core::Route) }
+ its(:count) { should == 2 }
+ end
+
+ describe '#get_edges' do
+ before { e0 }
+ subject { graph.get_edges }
+ it { should be_a(Pacer::Core::Route) }
+ its(:count) { should == 1 }
+ end
+ end
+end
View
24 spec/spec_helper.rb
@@ -75,6 +75,7 @@ def in_editor?
def for_each_graph(usage_style = :read_write, indices = true, &block)
for_tg(usage_style, indices, &block)
for_neo4j(usage_style, indices, &block)
+ for_orient(usage_style, indices, &block)
end
def use_graph?(name)
@@ -156,6 +157,10 @@ def for_neo4j(usage_style = :read_write, indices = true, &block)
for_transactional_graph('neo4j', usage_style, indices, $neo_graph, $neo_graph2, $neo_graph_no_indices, block)
end
+def for_orient(usage_style = :read_write, indices = true, &block)
+ for_transactional_graph('orient', usage_style, indices, $orient_graph, $orient_graph2, $orient_graph_no_indices, block)
+end
+
def use_simple_graph_data
let(:setup_data) { e0; e1 }
let(:v0) { graph.create_vertex :name => 'eliza' }
@@ -228,3 +233,22 @@ def use_pacer_graphml_data(usage_style = :read_write, version = '')
$neo_graph_no_indices.drop_index :vertices
$neo_graph_no_indices.drop_index :edges
end
+
+if use_graph?('orient')
+ path1 = File.expand_path('tmp/spec.orient')
+ dir = Pathname.new(path1)
+ dir.rmtree if dir.exist?
+ $orient_graph = Pacer.orient("local:#{path1}")
+
+ path2 = File.expand_path('tmp/spec.orient.2')
+ dir = Pathname.new(path2)
+ dir.rmtree if dir.exist?
+ $orient_graph2 = Pacer.orient("local:#{path2}")
+
+ path3 = File.expand_path('tmp/spec_no_indices.orient')
+ dir = Pathname.new(path3)
+ dir.rmtree if dir.exist?
+ $orient_graph_no_indices = Pacer.orient("local:#{path3}")
+ $orient_graph_no_indices.drop_index :vertices
+ $orient_graph_no_indices.drop_index :edges
+end
View
BIN vendor/blueprints-orientdb-adapter-0.2-SNAPSHOT-standalone.jar
Binary file not shown.

No commit comments for this range

Something went wrong with that request. Please try again.