Skip to content

Commit

Permalink
upgrade titan 0.5.4, include cassandra and es jars, rely on pacer to …
Browse files Browse the repository at this point in the history
…require lock_jar
  • Loading branch information
ilyakard committed Jun 1, 2015
1 parent 3bf92e1 commit 7cfd494
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 70 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
*.gem
.bundle
Gemfile.lock
pkg/*
target/*
lib/*.jar
tmp
pkg
4 changes: 3 additions & 1 deletion Jarfile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
jar 'com.thinkaurelius.titan:titan-core:0.5.1'
jar 'com.thinkaurelius.titan:titan-core:0.5.4'
jar 'com.thinkaurelius.titan:titan-es:0.5.4'
jar 'com.thinkaurelius.titan:titan-cassandra:0.5.4'
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,11 @@ This is an alpha-version pacer adapter with basic support for a [Titan](http://t

## Installation

As always: ```gem 'pacer-titan'```, then you will need to load the dependencies for your storage backend of choice (see below).
As always: ```gem 'pacer-titan'```.

## Backends

This gem includes Titan 0.5.1 core and its dependencies. You will also need to include the dependencies for your chosen Titan storage backend.

The excellent [lock_jar](https://github.com/mguymon/lock_jar) does a great job of this for you, simply add any of the following to your Jarfile as needed:

```ruby
jar 'com.thinkaurelius.titan:titan-es:0.5.1' # ElasticSearch
jar 'com.thinkaurelius.titan:titan-cassandra:0.5.1' # Cassandra
jar 'com.thinkaurelius.titan:titan-berkeleyje:0.5.1' # BerkeleyDB
```
This gem includes Titan 0.5.4 with the Cassandra backend and ElasticSearch.

## Usage

Expand Down
13 changes: 1 addition & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
require 'bundler'

Bundler::GemHelper.install_tasks

task default: :prepare

task :prepare do
require 'lock_jar'

# get jarfile relative the gem dir
lockfile = File.expand_path( "../Jarfile.lock", __FILE__ )

LockJar.install( lockfile: lockfile )
end
Bundler::GemHelper.install_tasks
8 changes: 0 additions & 8 deletions lib/pacer-titan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

require 'pacer-titan/version'

require 'lock_jar'
#LockJar.lock(File.join(File.dirname(__FILE__), "..", "Jarfile"))
LockJar.load

require 'pacer-titan/graph'
require 'pacer-titan/titan_query'
require 'pacer-titan/external_index_query'
Expand Down Expand Up @@ -36,10 +32,6 @@ def titan(path="config/inmemory.properties")

Titan::Graph.new(Pacer::TitanEncoder, open, shutdown)
end

def executing_route(route)
Rails.logger.debug "Pacer Titan executing route: #{route.description}" if defined? Rails
end
end
end

18 changes: 14 additions & 4 deletions lib/pacer-titan/encoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def self.encode_property(value)
value = value.strip
value = nil if value == ''
value
when Symbol
value.to_s
when Numeric
if value.is_a? Bignum
dump value
Expand All @@ -22,8 +24,10 @@ def self.encode_property(value)
end
when true, false
value.to_java
when DateTime, Time, Date
value.in_time_zone.utc.strftime ' time %Y-%m-%d %H:%M:%S.%L %z'
when Date
value.to_time.strftime ' time %Y-%m-%d'
when DateTime, Time
value.to_time.utc.strftime ' time %Y-%m-%d %H:%M:%S.%L %z'
when Array
if value.length == 0
value_type = Fixnum
Expand All @@ -46,6 +50,8 @@ def self.encode_property(value)
value.to_java :boolean
when String
value.to_java :string
when Symbol
value.to_java :string
else
dump value
end
Expand All @@ -57,8 +63,12 @@ def self.encode_property(value)
def self.decode_property(value)
if value.is_a? String and value[0, 1] == ' '
if value[1, 4] == 'time'
# FIXME: we lose the milliseconds here...
Time.zone.parse value[6..-1]
# FIXME: we lose the milliseconds here (and time zone if no Rails)...
if defined? Rails
Time.zone.parse value[6..-1]
else
Time.parse value[6..-1]
end
else
YAML.load(value[1..-1])
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pacer-titan/external_index_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def query_result
path = path.vertices.collect{ |v| v.get_element }
end

# expects query in the form of 'v.text:(lorem*)'
# expects query in the form of 'v.text:(lorem*)' to search 'text' vertex property with lucene query syntax '(lorem*)'
def build_titan_lucene_query(term, property)
if property.is_a? Array
queries = []
Expand Down
2 changes: 1 addition & 1 deletion lib/pacer-titan/graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Pacer
module Titan
class Graph < PacerGraph

# Include label in key indices so we can limit index queries by label
# Include label in key indices so we can limit index queries by vertex label
def key_indices(type = nil)
indices = super
indices.add 'label'
Expand Down
2 changes: 1 addition & 1 deletion lib/pacer-titan/titan_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Titan
class Graph
# Use Titan's QueryBuilder to access indices when you need to specify other comparison predicates
# eg: g.query{ has('description', Text::CONTAINS, 'abc').has('login', 'ilya') }.out(:messages)...
# be sure to import com.thinkaurelius.titan.core.attribute.Text for the above example
# import com.thinkaurelius.titan.core.attribute.Text for the above example
def query(options = {}, &query)
options[:element_type] ||= :vertex

Expand Down
6 changes: 2 additions & 4 deletions lib/pacer-titan/version.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Pacer
module Titan
VERSION = "0.0.6"
BLUEPRINTS_VERSION = "2.6.0"
PIPES_VERSION = "2.5.0"
PACER_REQ = ">= 2.0.0"
VERSION = "0.0.7"
PACER_REQ = ">= 2.0.6"
end
end
2 changes: 0 additions & 2 deletions pacer-titan.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ Gem::Specification.new do |s|
s.description = s.summary

s.add_dependency 'pacer', Pacer::Titan::PACER_REQ
s.add_dependency 'lock_jar', '~> 0.10.0'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.extensions = ["Rakefile"]
end
22 changes: 0 additions & 22 deletions pom/standalone.xml

This file was deleted.

0 comments on commit 7cfd494

Please sign in to comment.