isomorfeus-data 2.0.17 → 2.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/isomorfeus/data/{ferret_accelerator.rb → document_accelerator.rb} +2 -2
- data/lib/isomorfeus/data/object_accelerator.rb +75 -0
- data/lib/isomorfeus/data/{hamster_storage_expander.rb → object_expander.rb} +6 -5
- data/lib/isomorfeus/data/version.rb +1 -1
- data/lib/isomorfeus-data.rb +3 -3
- data/lib/isomorfeus_data/lucid_document/mixin.rb +2 -2
- data/lib/isomorfeus_data/lucid_object/mixin.rb +16 -11
- metadata +17 -17
- data/lib/isomorfeus/data/hamster_accelerator.rb +0 -87
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 486e4017f0678ac8030a0c592ea66b0d7bdb3560a53c38533621476e49b024d2
|
4
|
+
data.tar.gz: 2aca7a9ff273dc9f4fd379e41b6d585a2de94929a2f75aeea89c2f5f2254d32c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75c4c28dff98ce69ec50c62280cbbf34a437aa09d3fbb2d3ebadd47ae580d1b05f9f793a9baf85cc10581599e78d12284ab71ca9c893fda939353777fbc36cfd
|
7
|
+
data.tar.gz: a9861886a1dc2021a52f4953d57e45733ae88f2279746546834c2495f76573a25f86d9469815216426c9f33ec041e7518f010501750a2274062306d4906a2438
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Isomorfeus
|
2
2
|
module Data
|
3
|
-
class
|
3
|
+
class DocumentAccelerator
|
4
4
|
def self.finalize(fer_acc)
|
5
5
|
proc { fer_acc.close_index }
|
6
6
|
end
|
@@ -73,7 +73,7 @@ module Isomorfeus
|
|
73
73
|
def open_index
|
74
74
|
FileUtils.mkdir_p(Isomorfeus.data_documents_path) unless Dir.exist?(Isomorfeus.data_documents_path)
|
75
75
|
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)
|
76
|
+
@index = Isomorfeus::Ferret::Index::Index.new(path: index_path, key: :key, auto_flush: true, lock_retry_time: 5, field_infos: field_infos)
|
77
77
|
@index.field_infos.add_field(:key, store: :yes, index: :yes, term_vector: :no) unless @index.field_infos[:key]
|
78
78
|
@doc_class.field_options.each do |field, options|
|
79
79
|
@index.field_infos.add_field(field, options) unless @index.field_infos[field]
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Data
|
3
|
+
class ObjectAccelerator
|
4
|
+
def self.finalize(ham_acc)
|
5
|
+
proc { ham_acc.close_index }
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_accessor :index
|
9
|
+
|
10
|
+
def initialize(&block)
|
11
|
+
if block_given?
|
12
|
+
res = block.call(self)
|
13
|
+
@index = res unless @index
|
14
|
+
else
|
15
|
+
open_index
|
16
|
+
end
|
17
|
+
ObjectSpace.define_finalizer(self, self.class.finalize(self))
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy_index
|
21
|
+
close_index
|
22
|
+
FileUtils.rm_rf(Isomorfeus.data_object_idx_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def close_index
|
26
|
+
@index.close
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_doc(document)
|
30
|
+
@index.add_document(document)
|
31
|
+
end
|
32
|
+
|
33
|
+
def destroy_doc(key)
|
34
|
+
id = get_doc_id(key)
|
35
|
+
@index.delete(id) if id
|
36
|
+
true
|
37
|
+
end
|
38
|
+
|
39
|
+
def load_doc(key)
|
40
|
+
id = get_doc_id(key)
|
41
|
+
@index.doc(id)&.load&.to_h if id
|
42
|
+
end
|
43
|
+
|
44
|
+
def save_doc(key, document)
|
45
|
+
id = get_doc_id(key)
|
46
|
+
if id
|
47
|
+
@index.update(id, document)
|
48
|
+
true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def search_each(query, options, &block)
|
53
|
+
@index.search_each(query, options, &block)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def get_doc_id(key)
|
59
|
+
# special characters must be escaped, characters taken from the ferret query parser documentation
|
60
|
+
escaped_key = key.gsub(/([\\\&\:\(\)\[\]\{\}\!\"\~\^\|\<\>\=\*\?\+\-\s])/, '\\\\\1')
|
61
|
+
top_docs = @index.search("sid_s_attr:\"#{escaped_key}\"", limit: 1)
|
62
|
+
id = top_docs.hits[0].doc if top_docs.total_hits == 1
|
63
|
+
end
|
64
|
+
|
65
|
+
def open_index
|
66
|
+
FileUtils.mkdir_p(Isomorfeus.data_object_idx_path) unless Dir.exist?(Isomorfeus.data_object_idx_path)
|
67
|
+
@index = Isomorfeus::Ferret::Index::Index.new(path: Isomorfeus.data_object_idx_path, key: :sid_s_attr, auto_flush: true, lock_retry_time: 5)
|
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]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Isomorfeus
|
2
2
|
module Data
|
3
|
-
class
|
3
|
+
class ObjectExpander
|
4
4
|
class << self
|
5
5
|
def environment
|
6
6
|
@environment
|
@@ -45,11 +45,12 @@ module Isomorfeus
|
|
45
45
|
end
|
46
46
|
@db = self.class.environment.database('objects', create: true)
|
47
47
|
@index_db = self.class.environment.database('index', create: true, dupsort: true)
|
48
|
+
@use_class_cache = !Isomorfeus.development?
|
48
49
|
ObjectSpace.define_finalizer(self, self.class.finalize(self.class))
|
49
50
|
end
|
50
51
|
|
51
52
|
def create_object(sid_s, obj)
|
52
|
-
Isomorfeus::Hamster::Marshal.dump(@db, sid_s, obj)
|
53
|
+
Isomorfeus::Hamster::Marshal.dump(@db, sid_s, obj, class_cache: @use_class_cache)
|
53
54
|
end
|
54
55
|
|
55
56
|
def destroy_object(sid_s)
|
@@ -58,11 +59,11 @@ module Isomorfeus
|
|
58
59
|
end
|
59
60
|
|
60
61
|
def load_object(sid_s)
|
61
|
-
Isomorfeus::Hamster::Marshal.load(@db, sid_s)
|
62
|
+
Isomorfeus::Hamster::Marshal.load(@db, sid_s, class_cache: @use_class_cache)
|
62
63
|
end
|
63
64
|
|
64
65
|
def save_object(sid_s, obj)
|
65
|
-
Isomorfeus::Hamster::Marshal.dump(@db, sid_s, obj)
|
66
|
+
Isomorfeus::Hamster::Marshal.dump(@db, sid_s, obj, class_cache: @use_class_cache)
|
66
67
|
end
|
67
68
|
|
68
69
|
def index_delete(key, val)
|
@@ -79,7 +80,7 @@ module Isomorfeus
|
|
79
80
|
|
80
81
|
def each(&block)
|
81
82
|
@db.each do |key, obj|
|
82
|
-
block.call(Isomorfeus::Hamster::Marshal.unserialize(obj))
|
83
|
+
block.call(Isomorfeus::Hamster::Marshal.unserialize(obj, class_cache: @use_class_cache))
|
83
84
|
end
|
84
85
|
end
|
85
86
|
|
data/lib/isomorfeus-data.rb
CHANGED
@@ -23,11 +23,11 @@ else
|
|
23
23
|
require 'active_support/core_ext/hash'
|
24
24
|
|
25
25
|
require 'isomorfeus-ferret'
|
26
|
-
require 'isomorfeus/data/
|
26
|
+
require 'isomorfeus/data/document_accelerator'
|
27
27
|
|
28
28
|
require 'isomorfeus-hamster'
|
29
|
-
require 'isomorfeus/data/
|
30
|
-
require 'isomorfeus/data/
|
29
|
+
require 'isomorfeus/data/object_expander'
|
30
|
+
require 'isomorfeus/data/object_accelerator'
|
31
31
|
|
32
32
|
require 'isomorfeus_data/lucid_query_result'
|
33
33
|
require 'isomorfeus_data/lucid_object/mixin'
|
@@ -92,9 +92,9 @@ module LucidDocument
|
|
92
92
|
def ferret_accelerator
|
93
93
|
return @ferret_accelerator if @ferret_accelerator
|
94
94
|
@ferret_accelerator = if @_setup_index_block
|
95
|
-
Isomorfeus::Data::
|
95
|
+
Isomorfeus::Data::DocumentAccelerator.new(self, &@_setup_index_block)
|
96
96
|
else
|
97
|
-
Isomorfeus::Data::
|
97
|
+
Isomorfeus::Data::DocumentAccelerator.new(self)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -90,18 +90,18 @@ module LucidObject
|
|
90
90
|
def hamster_storage_expander
|
91
91
|
return @hamster_storage_expander if @hamster_storage_expander
|
92
92
|
@hamster_storage_expander = if @_setup_environment_block
|
93
|
-
Isomorfeus::Data::
|
93
|
+
Isomorfeus::Data::ObjectExpander.new(&@_setup_index_block)
|
94
94
|
else
|
95
|
-
Isomorfeus::Data::
|
95
|
+
Isomorfeus::Data::ObjectExpander.new
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
99
|
def hamster_accelerator
|
100
100
|
return @hamster_accelerator if @hamster_accelerator
|
101
101
|
@hamster_accelerator = if @_setup_index_block
|
102
|
-
Isomorfeus::Data::
|
102
|
+
Isomorfeus::Data::ObjectAccelerator.new(&@_setup_index_block)
|
103
103
|
else
|
104
|
-
Isomorfeus::Data::
|
104
|
+
Isomorfeus::Data::ObjectAccelerator.new
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -113,7 +113,7 @@ module LucidObject
|
|
113
113
|
query = "+value:#{val} +class_name:#{self.name}"
|
114
114
|
query << " +attribute:#{attr}" if attr != '*'
|
115
115
|
self.hamster_accelerator.search_each(query, options) do |id|
|
116
|
-
doc = self.hamster_accelerator.
|
116
|
+
doc = self.hamster_accelerator.index.doc(id)&.load
|
117
117
|
if doc
|
118
118
|
sid_s = doc[:sid_s_attr].split(':|:')[0]
|
119
119
|
obj = self.load(key: sid_s)
|
@@ -123,12 +123,12 @@ module LucidObject
|
|
123
123
|
else
|
124
124
|
if val == '*'
|
125
125
|
self.hamster_storage_expander.each do |obj|
|
126
|
-
objs << obj if obj
|
126
|
+
objs << obj if obj.class == self
|
127
127
|
end
|
128
128
|
else
|
129
129
|
attr_s = ":[#{attr}]"
|
130
130
|
accept_all_attr = attr_s == ":[*]" ? true : false
|
131
|
-
self.hamster_storage_expander.search(":[:#{val}:]:") do |sid_s_attr|
|
131
|
+
self.hamster_storage_expander.search(":[#{self.name}]:|:[:#{val}:]:") do |sid_s_attr|
|
132
132
|
if accept_all_attr || sid_s_attr.end_with?(attr_s)
|
133
133
|
sid_s = sid_s_attr.split(':|:[')[0]
|
134
134
|
obj = self.load(key: sid_s)
|
@@ -145,7 +145,7 @@ module LucidObject
|
|
145
145
|
self.class.hamster_storage_expander.create_object(self.sid_s, self)
|
146
146
|
self.class.indexed_attributes.each do |attr, idx_type|
|
147
147
|
if idx_type == :text
|
148
|
-
self.
|
148
|
+
self._create_text_indexed_attribute(attr)
|
149
149
|
else
|
150
150
|
self._store_value_indexed_attribute(attr)
|
151
151
|
end
|
@@ -163,7 +163,7 @@ module LucidObject
|
|
163
163
|
else
|
164
164
|
old_val = self.hamster_storage_expander.index_get("#{sid_s}:|:[#{attr}]")
|
165
165
|
self.hamster_storage_expander.index_delete("#{sid_s}:|:[#{attr}]", old_val)
|
166
|
-
self.hamster_storage_expander.index_delete(":[:#{old_val}:]:", "#{sid_s}:|:[#{attr}]")
|
166
|
+
self.hamster_storage_expander.index_delete(":[#{self.name}]:|:[:#{old_val}:]:", "#{sid_s}:|:[#{attr}]")
|
167
167
|
end
|
168
168
|
end
|
169
169
|
true
|
@@ -200,6 +200,11 @@ module LucidObject
|
|
200
200
|
@_raw_attributes = attributes
|
201
201
|
end
|
202
202
|
|
203
|
+
def _create_text_indexed_attribute(attr)
|
204
|
+
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.hamster_accelerator.create_doc(doc)
|
206
|
+
end
|
207
|
+
|
203
208
|
def _store_text_indexed_attribute(attr)
|
204
209
|
doc = { sid_s_attr: "#{self.sid_s}:|:[#{attr}]", value: self.send(attr).to_s, attribute: attr.to_s, class_name: @class_name }
|
205
210
|
self.class.hamster_accelerator.save_doc("#{self.sid_s}:|:[#{attr}]", doc)
|
@@ -208,10 +213,10 @@ module LucidObject
|
|
208
213
|
def _store_value_indexed_attribute(attr)
|
209
214
|
old_val = self.class.hamster_storage_expander.index_get("#{self.sid_s}:|:[#{attr}]")
|
210
215
|
self.class.hamster_storage_expander.index_delete("#{self.sid_s}:|:[#{attr}]", old_val)
|
211
|
-
self.class.hamster_storage_expander.index_delete(":[:#{old_val}:]:", "#{self.sid_s}:|:[#{attr}]")
|
216
|
+
self.class.hamster_storage_expander.index_delete(":[#{self.class.name}]:|:[:#{old_val}:]:", "#{self.sid_s}:|:[#{attr}]")
|
212
217
|
val = "#{self.send(attr)}"[0..300]
|
213
218
|
self.class.hamster_storage_expander.index_put("#{self.sid_s}:|:[#{attr}]", val)
|
214
|
-
self.class.hamster_storage_expander.index_put(":[:#{val}:]:", "#{self.sid_s}:|:[#{attr}]")
|
219
|
+
self.class.hamster_storage_expander.index_put(":[#{self.class.name}]:|:[:#{val}:]:", "#{self.sid_s}:|:[#{attr}]")
|
215
220
|
end
|
216
221
|
|
217
222
|
def _unchange!
|
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.0.21
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -100,28 +100,28 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.6.
|
103
|
+
version: 0.6.3
|
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.3
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: isomorfeus-preact
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 10.6.
|
117
|
+
version: 10.6.30
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 10.6.
|
124
|
+
version: 10.6.30
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: isomorfeus-redux
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,28 +142,28 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - '='
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 2.0.
|
145
|
+
version: 2.0.21
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 2.0.
|
152
|
+
version: 2.0.21
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: isomorfeus
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - '='
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 2.0.
|
159
|
+
version: 2.0.21
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - '='
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 2.0.
|
166
|
+
version: 2.0.21
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rake
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,8 +192,7 @@ dependencies:
|
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: 3.10.0
|
195
|
-
description:
|
196
|
-
and Collections with ease.
|
195
|
+
description: Develop apps with powerfule reactive data access and queries.
|
197
196
|
email: jan@kursator.de
|
198
197
|
executables: []
|
199
198
|
extensions: []
|
@@ -207,13 +206,13 @@ files:
|
|
207
206
|
- lib/isomorfeus-data.rb
|
208
207
|
- lib/isomorfeus/data/attribute_support.rb
|
209
208
|
- lib/isomorfeus/data/config.rb
|
210
|
-
- lib/isomorfeus/data/
|
209
|
+
- lib/isomorfeus/data/document_accelerator.rb
|
211
210
|
- lib/isomorfeus/data/field_support.rb
|
212
211
|
- lib/isomorfeus/data/generic_class_api.rb
|
213
212
|
- lib/isomorfeus/data/generic_instance_api.rb
|
214
|
-
- lib/isomorfeus/data/hamster_accelerator.rb
|
215
|
-
- lib/isomorfeus/data/hamster_storage_expander.rb
|
216
213
|
- lib/isomorfeus/data/handler/generic.rb
|
214
|
+
- lib/isomorfeus/data/object_accelerator.rb
|
215
|
+
- lib/isomorfeus/data/object_expander.rb
|
217
216
|
- lib/isomorfeus/data/reducer.rb
|
218
217
|
- lib/isomorfeus/data/version.rb
|
219
218
|
- lib/isomorfeus_data/lucid_document/base.rb
|
@@ -228,11 +227,12 @@ files:
|
|
228
227
|
- opal/uri.rb
|
229
228
|
- opal/uri/common.rb
|
230
229
|
- opal/uri/generic.rb
|
231
|
-
homepage:
|
230
|
+
homepage: https://isomorfeus.com
|
232
231
|
licenses:
|
233
232
|
- MIT
|
234
233
|
metadata:
|
235
234
|
github_repo: ssh://github.com/isomorfeus/gems
|
235
|
+
source_code_uri: https://github.com/isomorfeus/isomorfeus-project/isomorfeus-data
|
236
236
|
post_install_message:
|
237
237
|
rdoc_options: []
|
238
238
|
require_paths:
|
@@ -251,5 +251,5 @@ requirements: []
|
|
251
251
|
rubygems_version: 3.3.3
|
252
252
|
signing_key:
|
253
253
|
specification_version: 4
|
254
|
-
summary:
|
254
|
+
summary: Reactive objects, documents, files and queries for isomorfeus.
|
255
255
|
test_files: []
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module Isomorfeus
|
2
|
-
module Data
|
3
|
-
class HamsterAccelerator
|
4
|
-
class << self
|
5
|
-
def index
|
6
|
-
@index
|
7
|
-
end
|
8
|
-
|
9
|
-
def index=(idx)
|
10
|
-
@index = idx
|
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
|
-
cls.index.close if cls.ref == 0
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def initialize(&block)
|
38
|
-
if block_given?
|
39
|
-
res = block.call(self)
|
40
|
-
self.class.index = res unless self.class.index
|
41
|
-
else
|
42
|
-
open_index
|
43
|
-
end
|
44
|
-
ObjectSpace.define_finalizer(self, self.class.finalize(self.class))
|
45
|
-
end
|
46
|
-
|
47
|
-
def destroy_index
|
48
|
-
close_index
|
49
|
-
FileUtils.rm_rf(Isomorfeus.data_object_idx_path)
|
50
|
-
end
|
51
|
-
|
52
|
-
def destroy_doc(id)
|
53
|
-
self.class.index.delete(id)
|
54
|
-
true
|
55
|
-
end
|
56
|
-
|
57
|
-
def load_doc(id)
|
58
|
-
self.class.index.doc(id)&.load
|
59
|
-
end
|
60
|
-
|
61
|
-
def save_doc(id, document)
|
62
|
-
self.class.index.update(id, document)
|
63
|
-
end
|
64
|
-
|
65
|
-
def search_each(query, options, &block)
|
66
|
-
self.class.index.search_each(query, options, &block)
|
67
|
-
end
|
68
|
-
|
69
|
-
private
|
70
|
-
|
71
|
-
def open_index
|
72
|
-
return self.class.refa if self.class.index
|
73
|
-
unless Dir.exist?(Isomorfeus.data_object_idx_path)
|
74
|
-
FileUtils.mkdir_p(Isomorfeus.data_object_idx_path)
|
75
|
-
fis = Isomorfeus::Ferret::Index::FieldInfos.new
|
76
|
-
fis.add_field(:attribute, store: :no)
|
77
|
-
fis.add_field(:class_name, store: :no)
|
78
|
-
fis.add_field(:value, store: :no)
|
79
|
-
fis.add_field(:sid_s_attr, store: :yes)
|
80
|
-
fis.create_index(Isomorfeus.data_object_idx_path)
|
81
|
-
end
|
82
|
-
self.class.index = Isomorfeus::Ferret::Index::Index.new(path: Isomorfeus.data_object_idx_path, id_field: :sid_s_attr)
|
83
|
-
self.class.refa
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|