pacer-titan 0.0.1-java → 0.0.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +24 -0
- data/README.md +30 -16
- data/lib/pacer-titan/graph.rb +26 -19
- data/lib/pacer-titan/titan_query.rb +40 -7
- data/lib/pacer-titan/version.rb +1 -1
- data/pom.xml +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c638bc7d751817482ad2ffc01c64cf0041974d68
|
4
|
+
data.tar.gz: b72282e9ee400713ff77e081ca336d38144a461b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 873a8a7e52f1d6f1d851c862de4e20801310819b38046327bf1d62d21ece8b8c4970e4687ac207ab74553c3dcfa669ca4202a6abbb451f630aefe88086c6197e
|
7
|
+
data.tar.gz: 18c52b483fdfea0e4a94c1d655788c1257104d6d8ff417b4615e73b1f92ea9c35389a04d64a150af4c5266427408321b32004ccda70c172b11edf4da4e59c1de
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2010, TinkerPop [http://tinkerpop.com]
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
* Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
* Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
* Neither the name of the TinkerPop nor the
|
12
|
+
names of its contributors may be used to endorse or promote products
|
13
|
+
derived from this software without specific prior written permission.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL TINKERPOP BE LIABLE FOR ANY
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -5,27 +5,30 @@
|
|
5
5
|
[Tinkerpop](http://www.tinkerpop.com) stack.
|
6
6
|
|
7
7
|
This is an alpha-version pacer adapter with basic support for a [Titan](http://thinkaurelius.github.io/titan) graph in Pacer.
|
8
|
-
Based on Derrick's pacer-dex and pacer-neo4j gems.
|
9
8
|
|
10
9
|
## Installation
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
As always: ```gem 'pacer-titan'```, then you will need to load the jars for your storage backend of choice (see below).
|
12
|
+
|
13
|
+
If you want to hack at pacer-titan:
|
14
|
+
- You will need to install Maven first.
|
15
|
+
- Clone this repository.
|
16
|
+
- Run ```rake install``` in its directory to build Titan's jars.
|
17
|
+
- Include the gem in your project's gemfile, directing its path to your cloned copy.
|
16
18
|
|
17
19
|
## Backends
|
18
20
|
|
19
21
|
This gem includes Titan 0.4.2 and its dependencies.
|
20
22
|
|
21
|
-
It seems embedded backends (embedded Cassandra, embedded ElasticSearch) do not launch without extra work specifying their class paths when launching your app.
|
23
|
+
It seems embedded backends (embedded Cassandra, embedded ElasticSearch) do not launch without extra work specifying their class paths when launching your app.
|
22
24
|
|
23
25
|
The excellent [jBundler](https://github.com/mkristian/jbundler) does a great job of this for you, simply add any of the following to your Jarfile as needed:
|
24
26
|
|
25
|
-
|
27
|
+
```ruby
|
26
28
|
jar 'com.thinkaurelius.titan:titan-es', '~> 0.4.2' # ElasticSearch
|
27
|
-
jar 'com.thinkaurelius.titan:titan-cassandra', '~> 0.4.2' #
|
29
|
+
jar 'com.thinkaurelius.titan:titan-cassandra', '~> 0.4.2' # Cassandra
|
28
30
|
jar 'com.thinkaurelius.titan:titan-berkeleyje', '~> 0.4.2' # BerkeleyDB
|
31
|
+
```
|
29
32
|
|
30
33
|
You may find your JRuby JVM crashes under heavy load if you include too many jars; increase your -XX:MaxPermSize
|
31
34
|
|
@@ -33,19 +36,30 @@ You may find your JRuby JVM crashes under heavy load if you include too many jar
|
|
33
36
|
|
34
37
|
Opening a Titan graph in Pacer:
|
35
38
|
|
36
|
-
|
37
|
-
|
39
|
+
```ruby
|
40
|
+
require 'pacer'
|
41
|
+
require 'pacer-titan'
|
38
42
|
|
39
|
-
|
43
|
+
g = Pacer.titan 'path/to/titan_config.properties'
|
44
|
+
```
|
40
45
|
|
41
46
|
The graph settings are specified in an Apache Configuration .properties file.
|
42
47
|
|
43
48
|
## Titan-specific routes
|
44
49
|
|
45
|
-
You can use Titan's
|
46
|
-
|
50
|
+
You can use Titan's [indexing predicates](https://github.com/thinkaurelius/titan/wiki/Indexing-Backend-Overview#querying-an-index) in pacer routes.
|
51
|
+
```ruby
|
52
|
+
g.query{ has('text', Text::CONTAINS, 'lorem') }.out(:author)
|
53
|
+
```
|
54
|
+
Be sure to ```import com.thinkaurelius.titan.core.attribute.Text``` for the above example.
|
47
55
|
|
48
|
-
You can also use Titan's indexQuery() method to send queries in Lucene syntax to external indices
|
49
|
-
|
56
|
+
You can also use Titan's indexQuery() method to send queries in Lucene syntax to [external indices](https://github.com/thinkaurelius/titan/wiki/Direct-Index-Query):
|
57
|
+
```ruby
|
58
|
+
g.index_query(:text, '(lorem ipsum*)', index_name: 'search').out(:author)
|
59
|
+
```
|
50
60
|
|
51
|
-
The index_query route can take an array of indices as the first parameter, you can also pass an options hash as the third parameter to specify the index name if it is something other than 'search' as used in most of the Titan configuration examples.
|
61
|
+
The index_query route can take an array of indices as the first parameter, you can also pass an options hash as the third parameter to specify the index name if it is something other than 'search' as used in most of the Titan configuration examples.
|
62
|
+
|
63
|
+
## License
|
64
|
+
Based on Derrick Wiebe's pacer-dex and pacer-neo4j gems, as well as code by Steven McCraw and others on the pacer-users list.
|
65
|
+
This gem is released under the liberal MIT license.
|
data/lib/pacer-titan/graph.rb
CHANGED
@@ -1,28 +1,35 @@
|
|
1
1
|
module Pacer
|
2
2
|
module Titan
|
3
|
-
|
4
|
-
class FeatureProxy
|
5
|
-
def initialize original_features
|
6
|
-
@features = original_features
|
7
|
-
end
|
3
|
+
class Graph < PacerGraph
|
8
4
|
|
9
|
-
|
10
|
-
|
5
|
+
# Use GraphQuery for index lookups, based on pacer-neo4j's code:
|
6
|
+
private
|
7
|
+
def indexed_route(element_type, filters, block)
|
8
|
+
return super if search_manual_indices
|
9
|
+
|
10
|
+
filters.graph = self
|
11
|
+
filters.use_lookup!
|
12
|
+
query = indexed_properties(element_type, filters)
|
13
|
+
|
14
|
+
if query
|
15
|
+
route = exact_query(query, element_type: element_type, extensions: filters.extensions, wrapper: filters.wrapper)
|
16
|
+
|
17
|
+
filters.remove_property_keys key_indices(element_type)
|
18
|
+
if filters.any?
|
19
|
+
Pacer::Route.property_filter(route, filters, block)
|
20
|
+
else
|
21
|
+
route
|
22
|
+
end
|
23
|
+
elsif filters.route_modules.any?
|
24
|
+
mod = filters.route_modules.shift
|
25
|
+
Pacer::Route.property_filter(mod.route(self), filters, block)
|
26
|
+
end
|
11
27
|
end
|
12
|
-
|
13
|
-
def
|
14
|
-
|
28
|
+
|
29
|
+
def indexed_properties(type, filters)
|
30
|
+
filters.properties.select { |k, v| key_indices(type).include?(k) and not v.nil? }
|
15
31
|
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Graph < PacerGraph
|
19
|
-
def features
|
20
|
-
FeatureProxy.new(blueprints_graph.features)
|
21
|
-
end
|
22
32
|
|
23
|
-
def indices
|
24
|
-
key_indices
|
25
|
-
end
|
26
33
|
end
|
27
34
|
end
|
28
35
|
end
|
@@ -1,10 +1,23 @@
|
|
1
1
|
module Pacer
|
2
2
|
module Titan
|
3
3
|
class Graph
|
4
|
-
# Use Titan's QueryBuilder to access
|
5
|
-
# eg: g.query{ has('
|
6
|
-
# be sure to
|
7
|
-
def query(options = {
|
4
|
+
# Use Titan's QueryBuilder to access indices when you need to specify other comparison predicates
|
5
|
+
# eg: g.query{ has('description', Text::CONTAINS, 'abc').has('login', 'ilya') }.out(:messages)...
|
6
|
+
# be sure to import com.thinkaurelius.titan.core.attribute.Text for the above example
|
7
|
+
def query(options = {}, &query)
|
8
|
+
options[:element_type] ||= :vertex
|
9
|
+
|
10
|
+
chain_route options.merge(
|
11
|
+
query: query,
|
12
|
+
filter: :titan_query,
|
13
|
+
back: self
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Pass a hash of properties and values to look for in Titan's standard (exact) index
|
18
|
+
def exact_query(query, options={})
|
19
|
+
options[:element_type] ||= :vertex
|
20
|
+
|
8
21
|
chain_route options.merge(
|
9
22
|
query: query,
|
10
23
|
filter: :titan_query,
|
@@ -29,14 +42,34 @@ module Pacer
|
|
29
42
|
|
30
43
|
protected
|
31
44
|
|
45
|
+
def build_graph_centric_vertex_query(properties = {})
|
46
|
+
path = graph.blueprints_graph.query
|
47
|
+
properties.each do |key, value|
|
48
|
+
path = path.has("#{ key }", graph.encode_property(value))
|
49
|
+
end
|
50
|
+
path
|
51
|
+
end
|
52
|
+
|
32
53
|
def query_result
|
33
|
-
|
54
|
+
if query.is_a?(Array) || query.is_a?(Hash)
|
55
|
+
path = build_graph_centric_vertex_query(query)
|
56
|
+
elsif query.kind_of? Proc
|
57
|
+
path = graph.blueprints_graph.query.instance_exec(&query)
|
58
|
+
else
|
59
|
+
raise "Invalid query type for index lookup (takes a hash or block): #{ query }"
|
60
|
+
end
|
61
|
+
|
34
62
|
path.limit(top) if top
|
35
|
-
|
63
|
+
|
64
|
+
if element_type == :edge
|
65
|
+
path.edges
|
66
|
+
else
|
67
|
+
path.vertices
|
68
|
+
end
|
36
69
|
end
|
37
70
|
|
38
71
|
def source_iterator
|
39
|
-
query_result.to_route(element_type:
|
72
|
+
query_result.to_route(element_type: element_type, graph: graph)
|
40
73
|
end
|
41
74
|
|
42
75
|
def inspect_string
|
data/lib/pacer-titan/version.rb
CHANGED
data/pom.xml
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<artifactId>pacer-titan</artifactId>
|
8
8
|
<!-- NOTE: the following properties are automatically updated based on the values in lib/pacer-titan/version.rb -->
|
9
9
|
<properties>
|
10
|
-
<gem.version>0.0.
|
10
|
+
<gem.version>0.0.2</gem.version>
|
11
11
|
<blueprints.version>2.4.0</blueprints.version>
|
12
12
|
<pipes.version>2.4.0</pipes.version>
|
13
13
|
<titan.version>0.4.2</titan.version>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pacer-titan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Ilya Kardailsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pacer
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- .gitignore
|
35
35
|
- Gemfile
|
36
|
+
- LICENSE.txt
|
36
37
|
- README.md
|
37
38
|
- Rakefile
|
38
39
|
- config/cassandra-es.properties
|
@@ -46,7 +47,7 @@ files:
|
|
46
47
|
- pacer-titan.gemspec
|
47
48
|
- pom.xml
|
48
49
|
- pom/standalone.xml
|
49
|
-
- lib/pacer-titan-0.0.
|
50
|
+
- lib/pacer-titan-0.0.2-standalone.jar
|
50
51
|
homepage: http://www.github.com
|
51
52
|
licenses: []
|
52
53
|
metadata: {}
|