tempest_db 0.12.1
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.
- data/lib/base_thrift_client.rb +37 -0
- data/lib/gen/tempest_constants.rb +9 -0
- data/lib/gen/tempest_d_b_service.rb +481 -0
- data/lib/gen/tempest_db_constants.rb +13 -0
- data/lib/gen/tempest_db_types.rb +129 -0
- data/lib/gen/tempest_graph_service.rb +701 -0
- data/lib/gen/tempest_types.rb +93 -0
- data/lib/tempest_db.rb +82 -0
- metadata +55 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (0.9.3)
|
3
|
+
#
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'thrift'
|
8
|
+
|
9
|
+
class InvalidNodeIdException < ::Thrift::Exception
|
10
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
11
|
+
def initialize(message=nil)
|
12
|
+
super()
|
13
|
+
self.message = message
|
14
|
+
end
|
15
|
+
|
16
|
+
MESSAGE = 1
|
17
|
+
|
18
|
+
FIELDS = {
|
19
|
+
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
|
20
|
+
}
|
21
|
+
|
22
|
+
def struct_fields; FIELDS; end
|
23
|
+
|
24
|
+
def validate
|
25
|
+
end
|
26
|
+
|
27
|
+
::Thrift::Struct.generate_accessors self
|
28
|
+
end
|
29
|
+
|
30
|
+
class InvalidIndexException < ::Thrift::Exception
|
31
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
32
|
+
def initialize(message=nil)
|
33
|
+
super()
|
34
|
+
self.message = message
|
35
|
+
end
|
36
|
+
|
37
|
+
MESSAGE = 1
|
38
|
+
|
39
|
+
FIELDS = {
|
40
|
+
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
|
41
|
+
}
|
42
|
+
|
43
|
+
def struct_fields; FIELDS; end
|
44
|
+
|
45
|
+
def validate
|
46
|
+
end
|
47
|
+
|
48
|
+
::Thrift::Struct.generate_accessors self
|
49
|
+
end
|
50
|
+
|
51
|
+
class InvalidArgumentException < ::Thrift::Exception
|
52
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
53
|
+
def initialize(message=nil)
|
54
|
+
super()
|
55
|
+
self.message = message
|
56
|
+
end
|
57
|
+
|
58
|
+
MESSAGE = 1
|
59
|
+
|
60
|
+
FIELDS = {
|
61
|
+
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
|
62
|
+
}
|
63
|
+
|
64
|
+
def struct_fields; FIELDS; end
|
65
|
+
|
66
|
+
def validate
|
67
|
+
end
|
68
|
+
|
69
|
+
::Thrift::Struct.generate_accessors self
|
70
|
+
end
|
71
|
+
|
72
|
+
class BidirectionalPPRParams
|
73
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
74
|
+
RELATIVEERROR = 1
|
75
|
+
RESETPROBABILITY = 2
|
76
|
+
MINPROBABILITY = 3
|
77
|
+
|
78
|
+
FIELDS = {
|
79
|
+
RELATIVEERROR => {:type => ::Thrift::Types::DOUBLE, :name => 'relativeError'},
|
80
|
+
RESETPROBABILITY => {:type => ::Thrift::Types::DOUBLE, :name => 'resetProbability'},
|
81
|
+
MINPROBABILITY => {:type => ::Thrift::Types::DOUBLE, :name => 'minProbability', :optional => true}
|
82
|
+
}
|
83
|
+
|
84
|
+
def struct_fields; FIELDS; end
|
85
|
+
|
86
|
+
def validate
|
87
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field relativeError is unset!') unless @relativeError
|
88
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field resetProbability is unset!') unless @resetProbability
|
89
|
+
end
|
90
|
+
|
91
|
+
::Thrift::Struct.generate_accessors self
|
92
|
+
end
|
93
|
+
|
data/lib/tempest_db.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# Copyright 2016 Teapot, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
4
|
+
# file except in compliance with the License. You may obtain a copy of the License at
|
5
|
+
#
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software distributed
|
9
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
11
|
+
# specific language governing permissions and limitations under the License.
|
12
|
+
|
13
|
+
# This file defines a ruby TempestClient class for TempestDB. The client wraps the methods
|
14
|
+
# provided by the thrift generated client, and also makes some methods easier to use.
|
15
|
+
# For example, it converts the types of attributes into the correct dynamic ruby type, and allows
|
16
|
+
# optional arguments (which thrift 0.9.3 doesn't support) for some methods.
|
17
|
+
|
18
|
+
$:.push(File.expand_path(File.join(File.dirname(__FILE__),"gen")))
|
19
|
+
|
20
|
+
require 'tempest_d_b_service'
|
21
|
+
require 'tempest_db_constants'
|
22
|
+
require 'tempest_db_types'
|
23
|
+
require 'base_thrift_client'
|
24
|
+
|
25
|
+
# May also require the types and the constants for more complex services
|
26
|
+
|
27
|
+
module Teapot
|
28
|
+
module TempestDB
|
29
|
+
class TempestClient < Teapot::BaseThriftClient
|
30
|
+
def init_executor(protocol)
|
31
|
+
Teapot::TempestDB::TempestDBService::Client.new(protocol)
|
32
|
+
end
|
33
|
+
|
34
|
+
def TempestClient.jsonToValue(json_attribute)
|
35
|
+
if json_attribute[0] == '"'
|
36
|
+
json_attribute[1...-1]
|
37
|
+
elsif json_attribute == "true"
|
38
|
+
true
|
39
|
+
elsif json_attribute == "false"
|
40
|
+
false
|
41
|
+
elsif json_attribute == "null"
|
42
|
+
nil
|
43
|
+
else
|
44
|
+
# If this isn't an int, the server made a mistake, and there isn't much the client can do.
|
45
|
+
json_attribute.to_i
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def getMultiNodeAttribute(graphName, nodeIds, attributeName)
|
50
|
+
id_to_json = get_executor.getMultiNodeAttributeAsJSON(graphName, nodeIds, attributeName)
|
51
|
+
Hash[id_to_json.map{ |k,v| [k, TempestClient.jsonToValue(v)] }]
|
52
|
+
end
|
53
|
+
|
54
|
+
def getNodeAttribute(graphName, nodeId, attributeName)
|
55
|
+
self.getMultiNodeAttribute(graphName, [nodeId], attributeName)[nodeId]
|
56
|
+
end
|
57
|
+
|
58
|
+
def kStepOutNeighborsFiltered(edgeType, sourceId, k, sqlClause: "", degreeFilter: {}, alternating: true)
|
59
|
+
get_executor.kStepOutNeighborsFiltered(edgeType, sourceId, k, sqlClause, degreeFilter, alternating)
|
60
|
+
end
|
61
|
+
def kStepInNeighborsFiltered(edgeType, sourceId, k, sqlClause: "", degreeFilter: {}, alternating: true)
|
62
|
+
get_executor.kStepInNeighborsFiltered(edgeType, sourceId, k, sqlClause, degreeFilter, alternating)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Delegate other methods to the thrift generated method
|
66
|
+
# Note: for autocomplete and documentation, we could improve usability by listing methods
|
67
|
+
# explicitly (as we do for python), but that would require manual changes whenever the thrift
|
68
|
+
# api changes, so for ruby we automatically delegate all other methods.
|
69
|
+
def method_missing(m, *args)
|
70
|
+
get_executor.send m, *args
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_tempest_client(server = 'localhost', port = 10001)
|
77
|
+
Teapot::TempestDB::TempestClient.new(server, port)
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_empty_filter()
|
81
|
+
Hash.new
|
82
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tempest_db
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.12.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Peter Lofgren
|
9
|
+
- Pranav Dandekar
|
10
|
+
- Ashish Goel
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
15
|
+
dependencies: []
|
16
|
+
description: Client for Tempest Graph Database.
|
17
|
+
email: peter@teapot.co
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- lib/base_thrift_client.rb
|
23
|
+
- lib/gen/tempest_constants.rb
|
24
|
+
- lib/gen/tempest_d_b_service.rb
|
25
|
+
- lib/gen/tempest_db_constants.rb
|
26
|
+
- lib/gen/tempest_db_types.rb
|
27
|
+
- lib/gen/tempest_graph_service.rb
|
28
|
+
- lib/gen/tempest_types.rb
|
29
|
+
- lib/tempest_db.rb
|
30
|
+
homepage: http://teapot.co
|
31
|
+
licenses:
|
32
|
+
- Apache 2
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 1.8.23
|
52
|
+
signing_key:
|
53
|
+
specification_version: 3
|
54
|
+
summary: Client for Tempest Graph Database
|
55
|
+
test_files: []
|