isomorfeus-data 2.0.21 → 2.2.0
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/isomorfeus/data/config.rb +9 -9
- data/lib/isomorfeus/data/document_accelerator.rb +4 -8
- data/lib/isomorfeus/data/handler/generic.rb +22 -22
- data/lib/isomorfeus/data/object_accelerator.rb +9 -8
- data/lib/isomorfeus/data/object_expander.rb +15 -42
- data/lib/isomorfeus/data/reducer.rb +1 -1
- data/lib/isomorfeus/data/version.rb +1 -1
- data/lib/isomorfeus-data.rb +2 -0
- data/lib/isomorfeus_data/lucid_document/mixin.rb +8 -0
- data/lib/isomorfeus_data/lucid_file/mixin.rb +8 -0
- data/lib/isomorfeus_data/lucid_object/mixin.rb +51 -31
- data/lib/isomorfeus_data/lucid_query/mixin.rb +2 -1
- metadata +49 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cb046c8cee5e36e1b718bff9661851657c403efe02aefb81c999849e1e040a8d
|
|
4
|
+
data.tar.gz: c0eca11aada669a12d111c4d4e4e800b8ac46528e686dd3370b9d1958d51e964
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 530831d5f854d3ed6e3e2a87d13cc0bd2c9e2bdb960b369941668cf3f622dc3b67b281a39aaee4350045ee50c5e5bfc9a7a41d40f8fb2143147333fda8af9675
|
|
7
|
+
data.tar.gz: c56e046ff4ed72be681189c982b29772e37b2a048aa6183a8fc81e662315cef17552225665e7a471e65723a6c473e49b71d492a4d53be0bf6e71f810b26df726
|
|
@@ -56,7 +56,7 @@ module Isomorfeus
|
|
|
56
56
|
valid_file_classes[raw_class_name(klass)] = true
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
attr_accessor :
|
|
59
|
+
attr_accessor :storage_path
|
|
60
60
|
attr_accessor :files_path
|
|
61
61
|
|
|
62
62
|
attr_accessor :ferret_path
|
|
@@ -64,23 +64,23 @@ module Isomorfeus
|
|
|
64
64
|
|
|
65
65
|
attr_accessor :hamster_path
|
|
66
66
|
attr_accessor :hamster_mapsize
|
|
67
|
-
attr_accessor :
|
|
68
|
-
attr_accessor :
|
|
67
|
+
attr_accessor :data_object_envs_path
|
|
68
|
+
attr_accessor :data_object_idxs_path
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
if RUBY_ENGINE != 'opal'
|
|
73
|
-
self.
|
|
74
|
-
self.files_path = File.expand_path(File.join(self.
|
|
73
|
+
self.storage_path = File.expand_path(File.join(Isomorfeus.root, 'storage', Isomorfeus.env))
|
|
74
|
+
self.files_path = File.expand_path(File.join(self.storage_path, 'files'))
|
|
75
75
|
|
|
76
76
|
# documents and indices
|
|
77
|
-
self.ferret_path = File.expand_path(File.join(self.
|
|
77
|
+
self.ferret_path = File.expand_path(File.join(self.storage_path, 'ferret'))
|
|
78
78
|
self.data_documents_path = File.expand_path(File.join(self.ferret_path, 'documents'))
|
|
79
79
|
|
|
80
80
|
# objects, nodes and edges
|
|
81
|
-
self.hamster_path = File.expand_path(File.join(self.
|
|
81
|
+
self.hamster_path = File.expand_path(File.join(self.storage_path, 'hamster'))
|
|
82
82
|
self.hamster_mapsize = 4294967296
|
|
83
|
-
self.
|
|
84
|
-
self.
|
|
83
|
+
self.data_object_envs_path = File.expand_path(File.join(self.hamster_path, 'object_envs'))
|
|
84
|
+
self.data_object_idxs_path = File.expand_path(File.join(self.hamster_path, 'object_idxs'))
|
|
85
85
|
end
|
|
86
86
|
end
|
|
@@ -5,17 +5,17 @@ module Isomorfeus
|
|
|
5
5
|
proc { fer_acc.close_index }
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
attr_reader :doc_class, :doc_class_name
|
|
8
|
+
attr_reader :doc_class, :doc_class_name
|
|
9
9
|
attr_accessor :index
|
|
10
10
|
|
|
11
11
|
def initialize(doc_class, &block)
|
|
12
12
|
@doc_class = doc_class
|
|
13
13
|
@doc_class_name = doc_class.name
|
|
14
|
-
@doc_class_name_u = @doc_class_name.underscore
|
|
15
14
|
if block_given?
|
|
16
15
|
res = block.call(self)
|
|
17
16
|
@index = res unless @index
|
|
18
17
|
else
|
|
18
|
+
@index_path = File.expand_path(File.join(Isomorfeus.data_documents_path, @doc_class_name.underscore))
|
|
19
19
|
open_index
|
|
20
20
|
end
|
|
21
21
|
ObjectSpace.define_finalizer(self, self.class.finalize(self))
|
|
@@ -23,7 +23,7 @@ module Isomorfeus
|
|
|
23
23
|
|
|
24
24
|
def destroy_index
|
|
25
25
|
close_index
|
|
26
|
-
FileUtils.rm_rf(index_path
|
|
26
|
+
FileUtils.rm_rf(@index_path)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def close_index
|
|
@@ -66,14 +66,10 @@ module Isomorfeus
|
|
|
66
66
|
id = top_docs.hits[0].doc if top_docs.total_hits == 1
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
def index_path
|
|
70
|
-
File.expand_path(File.join(Isomorfeus.data_documents_path, @doc_class_name_u))
|
|
71
|
-
end
|
|
72
|
-
|
|
73
69
|
def open_index
|
|
74
70
|
FileUtils.mkdir_p(Isomorfeus.data_documents_path) unless Dir.exist?(Isomorfeus.data_documents_path)
|
|
75
71
|
field_infos = Isomorfeus::Ferret::Index::FieldInfos.new(store: :yes, index: :yes, term_vector: :with_positions_offsets)
|
|
76
|
-
@index = Isomorfeus::Ferret::Index::Index.new(path: index_path, key: :key, auto_flush: true, lock_retry_time: 5, field_infos: field_infos)
|
|
72
|
+
@index = Isomorfeus::Ferret::Index::Index.new(path: @index_path, key: :key, auto_flush: true, lock_retry_time: 5, field_infos: field_infos)
|
|
77
73
|
@index.field_infos.add_field(:key, store: :yes, index: :yes, term_vector: :no) unless @index.field_infos[:key]
|
|
78
74
|
@doc_class.field_options.each do |field, options|
|
|
79
75
|
@index.field_infos.add_field(field, options) unless @index.field_infos[field]
|
|
@@ -19,7 +19,7 @@ module Isomorfeus
|
|
|
19
19
|
response_agent.request[type_class_name].each_key do |action|
|
|
20
20
|
case action
|
|
21
21
|
when 'load' then process_load(response_agent, type_class, type_class_name)
|
|
22
|
-
when '
|
|
22
|
+
when 'execute' then process_execute(response_agent, type_class, type_class_name)
|
|
23
23
|
when 'create' then process_create(response_agent, type_class, type_class_name)
|
|
24
24
|
when 'save' then process_save(response_agent, type_class, type_class_name)
|
|
25
25
|
when 'destroy' then process_destroy(response_agent, type_class, type_class_name)
|
|
@@ -40,7 +40,7 @@ module Isomorfeus
|
|
|
40
40
|
data = response_agent.request[type_class_name]['create']
|
|
41
41
|
instance_data = data['instance']
|
|
42
42
|
included_items_data = data.key?('included_items') ? data['included_items'] : nil
|
|
43
|
-
if Isomorfeus.current_user.authorized?(type_class, :create,
|
|
43
|
+
if Isomorfeus.current_user.authorized?(type_class, :create, type_class.props_from_data(instance_data))
|
|
44
44
|
instance = type_class.instance_from_transport(instance_data, included_items_data)
|
|
45
45
|
created_type = instance.create
|
|
46
46
|
if created_type
|
|
@@ -56,6 +56,25 @@ module Isomorfeus
|
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
def process_execute(response_agent, type_class, type_class_name)
|
|
60
|
+
# 'Isomorfeus::Data::Handler::Generic', self.name, :execute, props_json
|
|
61
|
+
props = response_agent.request[type_class_name]['execute']
|
|
62
|
+
props.transform_keys!(&:to_sym)
|
|
63
|
+
if Isomorfeus.current_user.authorized?(type_class, :execute, props)
|
|
64
|
+
queried_type = type_class.execute(**props)
|
|
65
|
+
if queried_type
|
|
66
|
+
response_agent.outer_result = {} unless response_agent.outer_result
|
|
67
|
+
response_agent.outer_result.deep_merge!(data: queried_type.to_transport)
|
|
68
|
+
if queried_type.respond_to?(:included_items_to_transport)
|
|
69
|
+
response_agent.outer_result.deep_merge!(data: queried_type.included_items_to_transport)
|
|
70
|
+
end
|
|
71
|
+
response_agent.agent_result = { success: 'ok' }
|
|
72
|
+
else response_agent.error = { error: { type_class_name => 'Query returned nothing!' }}
|
|
73
|
+
end
|
|
74
|
+
else response_agent.error = { error: 'Access denied!' }
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
59
78
|
def process_load(response_agent, type_class, type_class_name)
|
|
60
79
|
# 'Isomorfeus::Data::Handler::Generic', self.name, :load, key: key
|
|
61
80
|
props = response_agent.request[type_class_name]['load']
|
|
@@ -75,31 +94,12 @@ module Isomorfeus
|
|
|
75
94
|
end
|
|
76
95
|
end
|
|
77
96
|
|
|
78
|
-
def process_query(response_agent, type_class, type_class_name)
|
|
79
|
-
# 'Isomorfeus::Data::Handler::Generic', self.name, :query, props_json
|
|
80
|
-
props = response_agent.request[type_class_name]['query']
|
|
81
|
-
props.transform_keys!(&:to_sym)
|
|
82
|
-
if Isomorfeus.current_user.authorized?(type_class, :query, props)
|
|
83
|
-
queried_type = type_class.execute(**props)
|
|
84
|
-
if queried_type
|
|
85
|
-
response_agent.outer_result = {} unless response_agent.outer_result
|
|
86
|
-
response_agent.outer_result.deep_merge!(data: queried_type.to_transport)
|
|
87
|
-
if queried_type.respond_to?(:included_items_to_transport)
|
|
88
|
-
response_agent.outer_result.deep_merge!(data: queried_type.included_items_to_transport)
|
|
89
|
-
end
|
|
90
|
-
response_agent.agent_result = { success: 'ok' }
|
|
91
|
-
else response_agent.error = { error: { type_class_name => 'Query returned nothing!' }}
|
|
92
|
-
end
|
|
93
|
-
else response_agent.error = { error: 'Access denied!' }
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
97
|
def process_save(response_agent, type_class, type_class_name)
|
|
98
98
|
# 'Isomorfeus::Data::Handler::Generic', self.name, :save, data_hash
|
|
99
99
|
data = response_agent.request[type_class_name]['save']
|
|
100
100
|
instance_data = data['instance']
|
|
101
101
|
included_items_data = data.key?('included_items') ? data['included_items'] : nil
|
|
102
|
-
if Isomorfeus.current_user.authorized?(type_class, :save,
|
|
102
|
+
if Isomorfeus.current_user.authorized?(type_class, :save, type_class.props_from_data(instance_data))
|
|
103
103
|
instance = type_class.instance_from_transport(instance_data, included_items_data)
|
|
104
104
|
saved_type = instance.save
|
|
105
105
|
if saved_type
|
|
@@ -7,11 +7,12 @@ module Isomorfeus
|
|
|
7
7
|
|
|
8
8
|
attr_accessor :index
|
|
9
9
|
|
|
10
|
-
def initialize(&block)
|
|
10
|
+
def initialize(object_class_name, &block)
|
|
11
11
|
if block_given?
|
|
12
12
|
res = block.call(self)
|
|
13
13
|
@index = res unless @index
|
|
14
14
|
else
|
|
15
|
+
@index_path = File.expand_path(File.join(Isomorfeus.data_object_idxs_path, object_class_name.underscore))
|
|
15
16
|
open_index
|
|
16
17
|
end
|
|
17
18
|
ObjectSpace.define_finalizer(self, self.class.finalize(self))
|
|
@@ -19,7 +20,7 @@ module Isomorfeus
|
|
|
19
20
|
|
|
20
21
|
def destroy_index
|
|
21
22
|
close_index
|
|
22
|
-
FileUtils.rm_rf(
|
|
23
|
+
FileUtils.rm_rf(@index_path)
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def close_index
|
|
@@ -63,12 +64,12 @@ module Isomorfeus
|
|
|
63
64
|
end
|
|
64
65
|
|
|
65
66
|
def open_index
|
|
66
|
-
FileUtils.mkdir_p(
|
|
67
|
-
@index = Isomorfeus::Ferret::Index::Index.new(path:
|
|
68
|
-
@index.field_infos.add_field(:attribute, store: :no, term_vector: :no) unless index.field_infos[:attribute]
|
|
69
|
-
@index.field_infos.add_field(:class_name, store: :no, term_vector: :no) unless index.field_infos[:class_name]
|
|
70
|
-
@index.field_infos.add_field(:value, store: :no) unless index.field_infos[:value]
|
|
71
|
-
@index.field_infos.add_field(:sid_s_attr, store: :yes, term_vector: :no) unless index.field_infos[:sid_s_attr]
|
|
67
|
+
FileUtils.mkdir_p(@index_path) unless Dir.exist?(@index_path)
|
|
68
|
+
@index = Isomorfeus::Ferret::Index::Index.new(path: @index_path, key: :sid_s_attr, auto_flush: true, lock_retry_time: 5)
|
|
69
|
+
@index.field_infos.add_field(:attribute, store: :no, term_vector: :no) unless @index.field_infos[:attribute]
|
|
70
|
+
@index.field_infos.add_field(:class_name, store: :no, term_vector: :no) unless @index.field_infos[:class_name]
|
|
71
|
+
@index.field_infos.add_field(:value, store: :no) unless @index.field_infos[:value]
|
|
72
|
+
@index.field_infos.add_field(:sid_s_attr, store: :yes, term_vector: :no) unless @index.field_infos[:sid_s_attr]
|
|
72
73
|
end
|
|
73
74
|
end
|
|
74
75
|
end
|
|
@@ -2,55 +2,30 @@ module Isomorfeus
|
|
|
2
2
|
module Data
|
|
3
3
|
class ObjectExpander
|
|
4
4
|
class << self
|
|
5
|
-
def
|
|
6
|
-
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def environment=(env)
|
|
10
|
-
@environment = env
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def ref
|
|
14
|
-
@ref ||= 0
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def ref=(val)
|
|
18
|
-
@ref = val
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def refa
|
|
22
|
-
self.ref += 1
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def refs
|
|
26
|
-
self.ref -= 1 if self.ref > 0
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def finalize(cls)
|
|
30
|
-
proc do
|
|
31
|
-
cls.refs
|
|
32
|
-
if cls.ref == 0
|
|
33
|
-
cls.environment.close rescue nil
|
|
34
|
-
end
|
|
35
|
-
end
|
|
5
|
+
def finalize(ins)
|
|
6
|
+
proc { ins.environment.close rescue nil }
|
|
36
7
|
end
|
|
37
8
|
end
|
|
38
9
|
|
|
39
|
-
|
|
10
|
+
attr_accessor :environment
|
|
11
|
+
|
|
12
|
+
def initialize(class_name:, compress: false, &block)
|
|
40
13
|
if block_given?
|
|
41
14
|
res = block.call(self)
|
|
42
|
-
self.
|
|
15
|
+
self.environment = res unless self.environment
|
|
43
16
|
else
|
|
17
|
+
@env_path = File.expand_path(File.join(Isomorfeus.data_object_envs_path, class_name.underscore))
|
|
44
18
|
open_environment
|
|
45
19
|
end
|
|
46
|
-
@db = self.
|
|
47
|
-
@index_db = self.
|
|
20
|
+
@db = self.environment.database('objects', create: true)
|
|
21
|
+
@index_db = self.environment.database('index', create: true, dupsort: true)
|
|
22
|
+
@compress = compress
|
|
48
23
|
@use_class_cache = !Isomorfeus.development?
|
|
49
|
-
ObjectSpace.define_finalizer(self, self.class.finalize(self
|
|
24
|
+
ObjectSpace.define_finalizer(self, self.class.finalize(self))
|
|
50
25
|
end
|
|
51
26
|
|
|
52
27
|
def create_object(sid_s, obj)
|
|
53
|
-
Isomorfeus::Hamster::Marshal.dump(@db, sid_s, obj, class_cache: @use_class_cache)
|
|
28
|
+
Isomorfeus::Hamster::Marshal.dump(@db, sid_s, obj, class_cache: @use_class_cache, compress: @compress)
|
|
54
29
|
end
|
|
55
30
|
|
|
56
31
|
def destroy_object(sid_s)
|
|
@@ -63,7 +38,7 @@ module Isomorfeus
|
|
|
63
38
|
end
|
|
64
39
|
|
|
65
40
|
def save_object(sid_s, obj)
|
|
66
|
-
Isomorfeus::Hamster::Marshal.dump(@db, sid_s, obj, class_cache: @use_class_cache)
|
|
41
|
+
Isomorfeus::Hamster::Marshal.dump(@db, sid_s, obj, class_cache: @use_class_cache, compress: @compress)
|
|
67
42
|
end
|
|
68
43
|
|
|
69
44
|
def index_delete(key, val)
|
|
@@ -91,10 +66,8 @@ module Isomorfeus
|
|
|
91
66
|
private
|
|
92
67
|
|
|
93
68
|
def open_environment
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
self.class.environment = Isomorfeus::Hamster.new(Isomorfeus.data_object_env_path, mapsize: Isomorfeus.hamster_mapsize)
|
|
97
|
-
self.class.refa
|
|
69
|
+
FileUtils.mkdir_p(@env_path) unless Dir.exist?(@env_path)
|
|
70
|
+
self.environment = Isomorfeus::Hamster.new(@env_path, mapsize: Isomorfeus.hamster_mapsize)
|
|
98
71
|
end
|
|
99
72
|
end
|
|
100
73
|
end
|
data/lib/isomorfeus-data.rb
CHANGED
|
@@ -2,7 +2,9 @@ require 'base64'
|
|
|
2
2
|
require 'stringio'
|
|
3
3
|
require 'data_uri'
|
|
4
4
|
require 'securerandom'
|
|
5
|
+
require 'isomorfeus-policy'
|
|
5
6
|
require 'isomorfeus-transport'
|
|
7
|
+
require 'isomorfeus-i18n'
|
|
6
8
|
require 'isomorfeus/data/config'
|
|
7
9
|
require 'isomorfeus/data/attribute_support'
|
|
8
10
|
require 'isomorfeus/data/field_support'
|
|
@@ -4,6 +4,7 @@ module LucidDocument
|
|
|
4
4
|
base.include(Isomorfeus::Data::FieldSupport)
|
|
5
5
|
base.extend(Isomorfeus::Data::GenericClassApi)
|
|
6
6
|
base.include(Isomorfeus::Data::GenericInstanceApi)
|
|
7
|
+
base.include(LucidI18n::Mixin)
|
|
7
8
|
|
|
8
9
|
base.instance_exec do
|
|
9
10
|
def escape_string(s)
|
|
@@ -85,6 +86,13 @@ module LucidDocument
|
|
|
85
86
|
new(key: key, revision: revision, fields: fields)
|
|
86
87
|
end
|
|
87
88
|
|
|
89
|
+
def props_from_data(instance_data)
|
|
90
|
+
key = instance_data[self.name].keys.first
|
|
91
|
+
revision = instance_data[self.name][key].key?('revision') ? instance_data[self.name][key]['revision'] : nil
|
|
92
|
+
fields = instance_data[self.name][key].key?('fields') ? instance_data[self.name][key]['fields'].transform_keys!(&:to_sym) : nil
|
|
93
|
+
LucidProps.new({ key: key, revision: revision }.merge!(fields))
|
|
94
|
+
end
|
|
95
|
+
|
|
88
96
|
def setup_index(&block)
|
|
89
97
|
@_setup_index_block = block
|
|
90
98
|
end
|
|
@@ -3,6 +3,7 @@ module LucidFile
|
|
|
3
3
|
def self.included(base)
|
|
4
4
|
base.extend(Isomorfeus::Data::GenericClassApi)
|
|
5
5
|
base.include(Isomorfeus::Data::GenericInstanceApi)
|
|
6
|
+
base.include(LucidI18n::Mixin)
|
|
6
7
|
|
|
7
8
|
def changed!
|
|
8
9
|
@_changed = true
|
|
@@ -140,6 +141,13 @@ module LucidFile
|
|
|
140
141
|
new(key: key, revision: revision, data_uri: data_uri)
|
|
141
142
|
end
|
|
142
143
|
|
|
144
|
+
def props_from_data(instance_data)
|
|
145
|
+
key = instance_data[self.name].keys.first
|
|
146
|
+
revision = instance_data[self.name][key].key?('revision') ? instance_data[self.name][key]['revision'] : nil
|
|
147
|
+
data_uri = instance_data[self.name][key].key?('data_uri') ? instance_data[self.name][key]['data_uri'] : nil
|
|
148
|
+
LucidProps.new({ key: key, revision: revision, data_uri: data_uri })
|
|
149
|
+
end
|
|
150
|
+
|
|
143
151
|
def files_path
|
|
144
152
|
@files_path ||= Isomorfeus.files_path
|
|
145
153
|
end
|
|
@@ -4,6 +4,17 @@ module LucidObject
|
|
|
4
4
|
base.include(Isomorfeus::Data::AttributeSupport)
|
|
5
5
|
base.extend(Isomorfeus::Data::GenericClassApi)
|
|
6
6
|
base.include(Isomorfeus::Data::GenericInstanceApi)
|
|
7
|
+
base.include(LucidI18n::Mixin)
|
|
8
|
+
|
|
9
|
+
base.instance_exec do
|
|
10
|
+
def store_compressed(quality: 5)
|
|
11
|
+
@_store_compressed = quality
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def _store_compressed
|
|
15
|
+
@_store_compressed
|
|
16
|
+
end
|
|
17
|
+
end
|
|
7
18
|
|
|
8
19
|
def [](name)
|
|
9
20
|
send(name)
|
|
@@ -79,6 +90,13 @@ module LucidObject
|
|
|
79
90
|
new(key: key, revision: revision, attributes: attributes)
|
|
80
91
|
end
|
|
81
92
|
|
|
93
|
+
def props_from_data(instance_data)
|
|
94
|
+
key = instance_data[self.name].keys.first
|
|
95
|
+
revision = instance_data[self.name][key].key?('revision') ? instance_data[self.name][key]['revision'] : nil
|
|
96
|
+
attributes = instance_data[self.name][key].key?('attributes') ? instance_data[self.name][key]['attributes'].transform_keys!(&:to_sym) : nil
|
|
97
|
+
LucidProps.new({ key: key, revision: revision }.merge!(attributes))
|
|
98
|
+
end
|
|
99
|
+
|
|
82
100
|
def setup_environment(&block)
|
|
83
101
|
@_setup_environment_block = block
|
|
84
102
|
end
|
|
@@ -87,21 +105,23 @@ module LucidObject
|
|
|
87
105
|
@_setup_index_block = block
|
|
88
106
|
end
|
|
89
107
|
|
|
90
|
-
def
|
|
91
|
-
return @
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
def object_expander
|
|
109
|
+
return @object_expander if @object_expander
|
|
110
|
+
compress = _store_compressed
|
|
111
|
+
compress = false if compress.nil?
|
|
112
|
+
@object_expander = if @_setup_environment_block
|
|
113
|
+
Isomorfeus::Data::ObjectExpander.new(class_name: self.to_s, compress: compress, &@_setup_index_block)
|
|
114
|
+
else
|
|
115
|
+
Isomorfeus::Data::ObjectExpander.new(class_name: self.to_s, compress: compress)
|
|
116
|
+
end
|
|
97
117
|
end
|
|
98
118
|
|
|
99
|
-
def
|
|
100
|
-
return @
|
|
101
|
-
@
|
|
102
|
-
Isomorfeus::Data::ObjectAccelerator.new(&@_setup_index_block)
|
|
119
|
+
def object_accelerator
|
|
120
|
+
return @object_accelerator if @object_accelerator
|
|
121
|
+
@object_accelerator = if @_setup_index_block
|
|
122
|
+
Isomorfeus::Data::ObjectAccelerator.new(self.to_s, &@_setup_index_block)
|
|
103
123
|
else
|
|
104
|
-
Isomorfeus::Data::ObjectAccelerator.new
|
|
124
|
+
Isomorfeus::Data::ObjectAccelerator.new(self.to_s)
|
|
105
125
|
end
|
|
106
126
|
end
|
|
107
127
|
|
|
@@ -112,8 +132,8 @@ module LucidObject
|
|
|
112
132
|
if idx_type == :text
|
|
113
133
|
query = "+value:#{val} +class_name:#{self.name}"
|
|
114
134
|
query << " +attribute:#{attr}" if attr != '*'
|
|
115
|
-
self.
|
|
116
|
-
doc = self.
|
|
135
|
+
self.object_accelerator.search_each(query, options) do |id|
|
|
136
|
+
doc = self.object_accelerator.index.doc(id)&.load
|
|
117
137
|
if doc
|
|
118
138
|
sid_s = doc[:sid_s_attr].split(':|:')[0]
|
|
119
139
|
obj = self.load(key: sid_s)
|
|
@@ -122,13 +142,13 @@ module LucidObject
|
|
|
122
142
|
end
|
|
123
143
|
else
|
|
124
144
|
if val == '*'
|
|
125
|
-
self.
|
|
145
|
+
self.object_expander.each do |obj|
|
|
126
146
|
objs << obj if obj.class == self
|
|
127
147
|
end
|
|
128
148
|
else
|
|
129
149
|
attr_s = ":[#{attr}]"
|
|
130
150
|
accept_all_attr = attr_s == ":[*]" ? true : false
|
|
131
|
-
self.
|
|
151
|
+
self.object_expander.search(":[#{self.name}]:|:[:#{val}:]:") do |sid_s_attr|
|
|
132
152
|
if accept_all_attr || sid_s_attr.end_with?(attr_s)
|
|
133
153
|
sid_s = sid_s_attr.split(':|:[')[0]
|
|
134
154
|
obj = self.load(key: sid_s)
|
|
@@ -142,7 +162,7 @@ module LucidObject
|
|
|
142
162
|
|
|
143
163
|
execute_create do
|
|
144
164
|
self.key = SecureRandom.uuid unless self.key
|
|
145
|
-
self.class.
|
|
165
|
+
self.class.object_expander.create_object(self.sid_s, self)
|
|
146
166
|
self.class.indexed_attributes.each do |attr, idx_type|
|
|
147
167
|
if idx_type == :text
|
|
148
168
|
self._create_text_indexed_attribute(attr)
|
|
@@ -156,14 +176,14 @@ module LucidObject
|
|
|
156
176
|
execute_destroy do |key:|
|
|
157
177
|
key = key.to_s
|
|
158
178
|
sid_s = key.start_with?('[') ? key : gen_sid_s(key)
|
|
159
|
-
self.
|
|
179
|
+
self.object_expander.destroy_object(sid_s)
|
|
160
180
|
self.indexed_attributes.each do |attr, idx_type|
|
|
161
181
|
if idx_type == :text
|
|
162
|
-
self.
|
|
182
|
+
self.object_accelerator.destroy_doc("#{sid_s}:|:[#{attr}]")
|
|
163
183
|
else
|
|
164
|
-
old_val = self.
|
|
165
|
-
self.
|
|
166
|
-
self.
|
|
184
|
+
old_val = self.object_expander.index_get("#{sid_s}:|:[#{attr}]")
|
|
185
|
+
self.object_expander.index_delete("#{sid_s}:|:[#{attr}]", old_val)
|
|
186
|
+
self.object_expander.index_delete(":[#{self.name}]:|:[:#{old_val}:]:", "#{sid_s}:|:[#{attr}]")
|
|
167
187
|
end
|
|
168
188
|
end
|
|
169
189
|
true
|
|
@@ -172,12 +192,12 @@ module LucidObject
|
|
|
172
192
|
execute_load do |key:|
|
|
173
193
|
key = key.to_s
|
|
174
194
|
sid_s = key.start_with?('[') ? key : gen_sid_s(key)
|
|
175
|
-
self.
|
|
195
|
+
self.object_expander.load_object(sid_s)
|
|
176
196
|
end
|
|
177
197
|
|
|
178
198
|
execute_save do
|
|
179
199
|
self.key = SecureRandom.uuid unless self.key
|
|
180
|
-
self.class.
|
|
200
|
+
self.class.object_expander.save_object(self.sid_s, self)
|
|
181
201
|
self.class.indexed_attributes.each do |attr, val|
|
|
182
202
|
if val == :text
|
|
183
203
|
self._store_text_indexed_attribute(attr)
|
|
@@ -202,21 +222,21 @@ module LucidObject
|
|
|
202
222
|
|
|
203
223
|
def _create_text_indexed_attribute(attr)
|
|
204
224
|
doc = { sid_s_attr: "#{self.sid_s}:|:[#{attr}]", value: self.send(attr).to_s, attribute: attr.to_s, class_name: @class_name }
|
|
205
|
-
self.class.
|
|
225
|
+
self.class.object_accelerator.create_doc(doc)
|
|
206
226
|
end
|
|
207
227
|
|
|
208
228
|
def _store_text_indexed_attribute(attr)
|
|
209
229
|
doc = { sid_s_attr: "#{self.sid_s}:|:[#{attr}]", value: self.send(attr).to_s, attribute: attr.to_s, class_name: @class_name }
|
|
210
|
-
self.class.
|
|
230
|
+
self.class.object_accelerator.save_doc("#{self.sid_s}:|:[#{attr}]", doc)
|
|
211
231
|
end
|
|
212
232
|
|
|
213
233
|
def _store_value_indexed_attribute(attr)
|
|
214
|
-
old_val = self.class.
|
|
215
|
-
self.class.
|
|
216
|
-
self.class.
|
|
234
|
+
old_val = self.class.object_expander.index_get("#{self.sid_s}:|:[#{attr}]")
|
|
235
|
+
self.class.object_expander.index_delete("#{self.sid_s}:|:[#{attr}]", old_val)
|
|
236
|
+
self.class.object_expander.index_delete(":[#{self.class.name}]:|:[:#{old_val}:]:", "#{self.sid_s}:|:[#{attr}]")
|
|
217
237
|
val = "#{self.send(attr)}"[0..300]
|
|
218
|
-
self.class.
|
|
219
|
-
self.class.
|
|
238
|
+
self.class.object_expander.index_put("#{self.sid_s}:|:[#{attr}]", val)
|
|
239
|
+
self.class.object_expander.index_put(":[#{self.class.name}]:|:[:#{val}:]:", "#{self.sid_s}:|:[#{attr}]")
|
|
220
240
|
end
|
|
221
241
|
|
|
222
242
|
def _unchange!
|
|
@@ -2,6 +2,7 @@ module LucidQuery
|
|
|
2
2
|
module Mixin
|
|
3
3
|
def self.included(base)
|
|
4
4
|
base.extend(LucidPropDeclaration::Mixin)
|
|
5
|
+
base.include(LucidI18n::Mixin)
|
|
5
6
|
|
|
6
7
|
if RUBY_ENGINE == 'opal'
|
|
7
8
|
base.instance_exec do
|
|
@@ -22,7 +23,7 @@ module LucidQuery
|
|
|
22
23
|
end
|
|
23
24
|
props = validated_props(props)
|
|
24
25
|
props[:key] = query_result_instance.key
|
|
25
|
-
Isomorfeus::Transport.promise_send_path( 'Isomorfeus::Data::Handler::Generic', self.name, :
|
|
26
|
+
Isomorfeus::Transport.promise_send_path( 'Isomorfeus::Data::Handler::Generic', self.name, :execute, props).then do |agent|
|
|
26
27
|
agent.process do
|
|
27
28
|
query_result_instance._load_from_store!
|
|
28
29
|
Isomorfeus.store.dispatch(type: 'DATA_LOAD', data: agent.full_response[:data])
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: isomorfeus-data
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jan Biedermann
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-02-
|
|
11
|
+
date: 2022-02-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 7.0.
|
|
19
|
+
version: 7.0.2
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 7.0.
|
|
26
|
+
version: 7.0.2
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: oj
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -72,98 +72,126 @@ dependencies:
|
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.14.
|
|
75
|
+
version: 0.14.17
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.14.
|
|
82
|
+
version: 0.14.17
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: isomorfeus-ferret
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 0.12.
|
|
89
|
+
version: 0.12.6
|
|
90
90
|
type: :runtime
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 0.12.
|
|
96
|
+
version: 0.12.6
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: isomorfeus-hamster
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 0.6.
|
|
103
|
+
version: 0.6.6
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 0.6.
|
|
110
|
+
version: 0.6.6
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: isomorfeus-i18n
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - '='
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 2.2.0
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - '='
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 2.2.0
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: isomorfeus-policy
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - '='
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 2.2.0
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - '='
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 2.2.0
|
|
111
139
|
- !ruby/object:Gem::Dependency
|
|
112
140
|
name: isomorfeus-preact
|
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
|
114
142
|
requirements:
|
|
115
143
|
- - "~>"
|
|
116
144
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: 10.6.
|
|
145
|
+
version: 10.6.40
|
|
118
146
|
type: :runtime
|
|
119
147
|
prerelease: false
|
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
149
|
requirements:
|
|
122
150
|
- - "~>"
|
|
123
151
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: 10.6.
|
|
152
|
+
version: 10.6.40
|
|
125
153
|
- !ruby/object:Gem::Dependency
|
|
126
154
|
name: isomorfeus-redux
|
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
|
128
156
|
requirements:
|
|
129
157
|
- - "~>"
|
|
130
158
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: 4.1.
|
|
159
|
+
version: 4.1.18
|
|
132
160
|
type: :runtime
|
|
133
161
|
prerelease: false
|
|
134
162
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
163
|
requirements:
|
|
136
164
|
- - "~>"
|
|
137
165
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: 4.1.
|
|
166
|
+
version: 4.1.18
|
|
139
167
|
- !ruby/object:Gem::Dependency
|
|
140
168
|
name: isomorfeus-transport
|
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
|
142
170
|
requirements:
|
|
143
171
|
- - '='
|
|
144
172
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: 2.0
|
|
173
|
+
version: 2.2.0
|
|
146
174
|
type: :runtime
|
|
147
175
|
prerelease: false
|
|
148
176
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
177
|
requirements:
|
|
150
178
|
- - '='
|
|
151
179
|
- !ruby/object:Gem::Version
|
|
152
|
-
version: 2.0
|
|
180
|
+
version: 2.2.0
|
|
153
181
|
- !ruby/object:Gem::Dependency
|
|
154
182
|
name: isomorfeus
|
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
|
156
184
|
requirements:
|
|
157
185
|
- - '='
|
|
158
186
|
- !ruby/object:Gem::Version
|
|
159
|
-
version: 2.0
|
|
187
|
+
version: 2.2.0
|
|
160
188
|
type: :development
|
|
161
189
|
prerelease: false
|
|
162
190
|
version_requirements: !ruby/object:Gem::Requirement
|
|
163
191
|
requirements:
|
|
164
192
|
- - '='
|
|
165
193
|
- !ruby/object:Gem::Version
|
|
166
|
-
version: 2.0
|
|
194
|
+
version: 2.2.0
|
|
167
195
|
- !ruby/object:Gem::Dependency
|
|
168
196
|
name: rake
|
|
169
197
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -184,15 +212,15 @@ dependencies:
|
|
|
184
212
|
requirements:
|
|
185
213
|
- - "~>"
|
|
186
214
|
- !ruby/object:Gem::Version
|
|
187
|
-
version: 3.
|
|
215
|
+
version: 3.11.0
|
|
188
216
|
type: :development
|
|
189
217
|
prerelease: false
|
|
190
218
|
version_requirements: !ruby/object:Gem::Requirement
|
|
191
219
|
requirements:
|
|
192
220
|
- - "~>"
|
|
193
221
|
- !ruby/object:Gem::Version
|
|
194
|
-
version: 3.
|
|
195
|
-
description: Develop apps with
|
|
222
|
+
version: 3.11.0
|
|
223
|
+
description: Develop apps with powerful reactive data access and queries.
|
|
196
224
|
email: jan@kursator.de
|
|
197
225
|
executables: []
|
|
198
226
|
extensions: []
|