activecypher 0.10.4 → 0.11.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.
- checksums.yaml +4 -4
- data/lib/active_cypher/base.rb +18 -1
- data/lib/active_cypher/bolt/connection.rb +421 -16
- data/lib/active_cypher/bolt/driver.rb +3 -17
- data/lib/active_cypher/bolt/session.rb +70 -50
- data/lib/active_cypher/bolt/transaction.rb +3 -10
- data/lib/active_cypher/connection_adapters/abstract_adapter.rb +6 -26
- data/lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb +9 -1
- data/lib/active_cypher/connection_adapters/memgraph_adapter.rb +25 -2
- data/lib/active_cypher/connection_adapters/neo4j_adapter.rb +25 -2
- data/lib/active_cypher/connection_pool.rb +11 -14
- data/lib/active_cypher/fixtures.rb +9 -21
- data/lib/active_cypher/instrumentation.rb +1 -1
- data/lib/active_cypher/logging.rb +1 -5
- data/lib/active_cypher/migrator.rb +0 -2
- data/lib/active_cypher/model/connection_owner.rb +2 -1
- data/lib/active_cypher/model/querying.rb +2 -26
- data/lib/active_cypher/relationship.rb +12 -17
- data/lib/active_cypher/version.rb +1 -1
- data/lib/cyrel/ast/clause_adapter.rb +4 -10
- data/lib/cyrel/ast/compiler.rb +5 -18
- data/lib/cyrel/logging.rb +0 -2
- data/lib/cyrel/query.rb +1 -0
- metadata +1 -3
- data/lib/active_cypher/model/inspectable.rb +0 -28
- data/lib/cyrel/ast/simple_cache.rb +0 -50
data/lib/cyrel/ast/compiler.rb
CHANGED
@@ -11,13 +11,8 @@ module Cyrel
|
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@output = StringIO.new
|
14
|
-
|
15
|
-
|
16
|
-
@param_counter = Concurrent::AtomicFixnum.new(0)
|
17
|
-
else
|
18
|
-
@parameters = {}
|
19
|
-
@param_counter = 0
|
20
|
-
end
|
14
|
+
@parameters = {}
|
15
|
+
@param_counter = 0
|
21
16
|
@first_clause = true
|
22
17
|
@loop_variables = Set.new # Track loop variables that shouldn't be parameterized
|
23
18
|
end
|
@@ -573,17 +568,9 @@ module Cyrel
|
|
573
568
|
existing_key = @parameters.key(value)
|
574
569
|
return existing_key if existing_key
|
575
570
|
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
counter = @param_counter.increment
|
580
|
-
key = :"p#{counter}"
|
581
|
-
else
|
582
|
-
# Non-concurrent version
|
583
|
-
|
584
|
-
@param_counter += 1
|
585
|
-
key = :"p#{@param_counter}"
|
586
|
-
end
|
571
|
+
# Parameter registration
|
572
|
+
@param_counter += 1
|
573
|
+
key = :"p#{@param_counter}"
|
587
574
|
@parameters[key] = value
|
588
575
|
key
|
589
576
|
end
|
data/lib/cyrel/logging.rb
CHANGED
data/lib/cyrel/query.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activecypher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
@@ -154,7 +154,6 @@ files:
|
|
154
154
|
- lib/active_cypher/model/core.rb
|
155
155
|
- lib/active_cypher/model/countable.rb
|
156
156
|
- lib/active_cypher/model/destruction.rb
|
157
|
-
- lib/active_cypher/model/inspectable.rb
|
158
157
|
- lib/active_cypher/model/labelling.rb
|
159
158
|
- lib/active_cypher/model/persistence.rb
|
160
159
|
- lib/active_cypher/model/querying.rb
|
@@ -192,7 +191,6 @@ files:
|
|
192
191
|
- lib/cyrel/ast/remove_node.rb
|
193
192
|
- lib/cyrel/ast/return_node.rb
|
194
193
|
- lib/cyrel/ast/set_node.rb
|
195
|
-
- lib/cyrel/ast/simple_cache.rb
|
196
194
|
- lib/cyrel/ast/skip_node.rb
|
197
195
|
- lib/cyrel/ast/union_node.rb
|
198
196
|
- lib/cyrel/ast/unwind_node.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveCypher
|
4
|
-
module Model
|
5
|
-
# @!parse
|
6
|
-
# # Adds a custom inspect method for pretty-printing a compact, single-line summary of the object.
|
7
|
-
# # Because nothing says "debuggable" like a string that pretends your object is more interesting than it is.
|
8
|
-
module Inspectable
|
9
|
-
# Custom object inspection method for pretty-printing a compact,
|
10
|
-
# single-line summary of the object. Output examples:
|
11
|
-
#
|
12
|
-
# #<UserNode id="26" name="Alice" age=34> => persisted object
|
13
|
-
# #<UserNode (new) name="Bob"> => object not yet saved
|
14
|
-
#
|
15
|
-
def inspect
|
16
|
-
# Put 'internal_id' first like it's the main character (even if it's nil)
|
17
|
-
ordered = attributes.dup
|
18
|
-
ordered = ordered.slice('internal_id').merge(ordered.except('internal_id'))
|
19
|
-
|
20
|
-
# Turn each attr into "key: value" because we humans fear raw hashes
|
21
|
-
parts = ordered.map { |k, v| "#{k}: #{v.inspect}" }
|
22
|
-
|
23
|
-
# Wrap it all up in a fake-sane object string, so you can pretend your data is organized.
|
24
|
-
"#<#{self.class} #{parts.join(', ')}>"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'singleton'
|
4
|
-
|
5
|
-
module Cyrel
|
6
|
-
module AST
|
7
|
-
# Simple thread-safe compilation cache
|
8
|
-
# Because compiling the same query twice is like watching reruns
|
9
|
-
class SimpleCache
|
10
|
-
include Singleton
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@cache = {}
|
14
|
-
@mutex = Mutex.new
|
15
|
-
@max_size = 1000
|
16
|
-
end
|
17
|
-
|
18
|
-
def fetch(key)
|
19
|
-
@mutex.synchronize do
|
20
|
-
if @cache.key?(key)
|
21
|
-
@cache[key]
|
22
|
-
elsif block_given?
|
23
|
-
value = yield
|
24
|
-
store(key, value)
|
25
|
-
value
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def clear!
|
31
|
-
@mutex.synchronize { @cache.clear }
|
32
|
-
end
|
33
|
-
|
34
|
-
def size
|
35
|
-
@mutex.synchronize { @cache.size }
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def store(key, value)
|
41
|
-
# Simple LRU: remove oldest entries when cache is full
|
42
|
-
if @cache.size >= @max_size
|
43
|
-
# Remove half of the oldest entries
|
44
|
-
(@max_size / 2).times { @cache.shift }
|
45
|
-
end
|
46
|
-
@cache[key] = value
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|