cloudwow-not_relational 0.1.0 → 0.1.2
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/VERSION.yml +1 -1
- data/lib/not_relational/berkeley_repository.rb +2 -2
- data/lib/not_relational/configuration.rb +10 -10
- data/lib/not_relational/domain_model.rb +12 -10
- data/lib/not_relational/geo.rb +1 -0
- data/lib/not_relational/lazy_loading_text.rb +3 -3
- data/lib/not_relational/memcache_repository.rb +6 -6
- data/lib/not_relational/memory_repository.rb +6 -6
- data/lib/not_relational/memory_storage.rb +7 -0
- data/lib/not_relational/property_description.rb +2 -2
- data/lib/not_relational/repository_factory.rb +3 -3
- data/lib/not_relational/repository_interface.rb +2 -2
- data/lib/not_relational/{repository.rb → sdb_repository.rb} +269 -231
- data/lib/not_relational/storage.rb +2 -2
- data/lib/not_relational.rb +5 -2
- data/test/models/album.rb +1 -1
- data/test/models/blurb_wording.rb +1 -1
- data/test/models/friend_request.rb +1 -1
- data/test/models/group.rb +1 -1
- data/test/models/media_item.rb +1 -1
- data/test/models/message.rb +1 -1
- data/test/models/node.rb +1 -1
- data/test/models/outgoing_email.rb +1 -1
- data/test/models/user.rb +1 -1
- data/test/models/weblab.rb +2 -2
- data/test/unit_tests/album_test.rb +1 -5
- data/test/unit_tests/blurb_test.rb +2 -2
- data/test/unit_tests/comment_test.rb +2 -2
- data/test/unit_tests/composite_key_test.rb +1 -1
- data/test/unit_tests/enum_test.rb +1 -1
- data/test/unit_tests/group_test.rb +2 -2
- data/test/unit_tests/mediaitem_test.rb +2 -2
- data/test/unit_tests/memcache_repository_test.rb +2 -2
- data/test/unit_tests/memory_repository_test.rb +1 -1
- data/test/unit_tests/node_test.rb +2 -2
- data/test/unit_tests/place_test.rb +2 -2
- data/test/unit_tests/reference_set_test.rb +1 -1
- data/test/unit_tests/repository_factory_test.rb +1 -1
- data/test/unit_tests/tag_test.rb +2 -2
- data/test/unit_tests/user_test.rb +2 -2
- metadata +5 -5
data/VERSION.yml
CHANGED
@@ -10,7 +10,7 @@ module NotRelational
|
|
10
10
|
aws_secret_key= nil,
|
11
11
|
memcache_servers = nil ,
|
12
12
|
dummy=nil,
|
13
|
-
|
13
|
+
use_seperate_domain_per_model=nil,
|
14
14
|
options={}
|
15
15
|
)
|
16
16
|
|
@@ -38,7 +38,7 @@ end
|
|
38
38
|
end
|
39
39
|
def find_one(table_name, primary_key,attribute_descriptions)#, non_clob_attribute_names, clob_attribute_names)
|
40
40
|
end
|
41
|
-
def
|
41
|
+
def get_text(table_name,primary_key,clob_name)
|
42
42
|
end
|
43
43
|
def destroy(table_name, primary_key)
|
44
44
|
end
|
@@ -5,12 +5,12 @@ module NotRelational
|
|
5
5
|
class Configuration
|
6
6
|
|
7
7
|
attr_reader :repository_class
|
8
|
-
attr_reader :
|
9
|
-
attr_reader :
|
8
|
+
attr_reader :base_domain_name
|
9
|
+
attr_reader :blob_bucket
|
10
10
|
attr_reader :aws_key_id
|
11
11
|
attr_reader :aws_secret_key
|
12
12
|
attr_reader :memcache_servers
|
13
|
-
attr_reader :
|
13
|
+
attr_reader :use_seperate_domain_per_model
|
14
14
|
attr_reader :fail_fast
|
15
15
|
|
16
16
|
attr_reader :cipher_key_file
|
@@ -28,17 +28,17 @@ module NotRelational
|
|
28
28
|
if not_relational_config.has_key?("repository_class")
|
29
29
|
@repository_class=eval not_relational_config["repository_class"]
|
30
30
|
else
|
31
|
-
@repository_class=NotRelational::
|
31
|
+
@repository_class=NotRelational::MemoryRepository
|
32
32
|
end
|
33
|
-
@
|
34
|
-
@
|
33
|
+
@base_domain_name= not_relational_config["domain_name_prefix"] || ""
|
34
|
+
@blob_bucket= not_relational_config["blob_bucket"]
|
35
35
|
@aws_key_id = not_relational_config["aws_key_id"]
|
36
36
|
@aws_secret_key = not_relational_config["aws_secret_key"]
|
37
37
|
@memcache_servers= not_relational_config['memcache_servers']
|
38
|
-
@memcache_servers = memcache_servers.split(",") if memcache_servers
|
38
|
+
@memcache_servers = memcache_servers.split(",") if memcache_servers and memcache_servers.respond_to?(:split)
|
39
39
|
|
40
|
-
@
|
41
|
-
@fail_fast=not_relational_config['fail_fast']
|
40
|
+
@use_seperate_domain_per_model=not_relational_config['use_seperate_domain_per_model']||false
|
41
|
+
@fail_fast=not_relational_config['fail_fast'] ||false
|
42
42
|
|
43
43
|
@cipher_key_file = not_relational_config['cipher_key_file']
|
44
44
|
@cipher_key_file ||= "./.cipher_key"
|
@@ -98,7 +98,7 @@ end
|
|
98
98
|
config_file_path = File.join("config", "database.yml")
|
99
99
|
end
|
100
100
|
|
101
|
-
config_section =(ENV['
|
101
|
+
config_section =(ENV['NOT_RELATIONAL_ENV'] || "production")+"_not_relational"
|
102
102
|
end
|
103
103
|
if config_file_path and config_section
|
104
104
|
config_file = YAML.load(File.open( config_file_path))
|
@@ -165,7 +165,7 @@ module NotRelational
|
|
165
165
|
end
|
166
166
|
def is_dirty(attribute_name)
|
167
167
|
if @attribute_values[attribute_name]!= nil &&
|
168
|
-
@attribute_values[attribute_name].
|
168
|
+
@attribute_values[attribute_name].is_a?(LazyLoadingText)
|
169
169
|
return @attribute_values[attribute_name].is_dirty
|
170
170
|
else
|
171
171
|
return true
|
@@ -193,7 +193,7 @@ module NotRelational
|
|
193
193
|
|
194
194
|
GETTERDONE
|
195
195
|
end
|
196
|
-
if attribute_description.value_type==:
|
196
|
+
if attribute_description.value_type==:text
|
197
197
|
clob_attribute_names<<attribute_description.name
|
198
198
|
else
|
199
199
|
non_clob_attribute_names<<attribute_description.name
|
@@ -228,7 +228,7 @@ module NotRelational
|
|
228
228
|
|
229
229
|
GETTERDONE
|
230
230
|
|
231
|
-
elsif type==:
|
231
|
+
elsif type==:text
|
232
232
|
class_eval <<-GETTERDONE
|
233
233
|
|
234
234
|
def #{attribute_description.name}
|
@@ -338,7 +338,9 @@ module NotRelational
|
|
338
338
|
#{module_name+domain_class.to_s}.find(self.#{foreign_key_attribute})
|
339
339
|
end
|
340
340
|
GETTERDONE
|
341
|
-
|
341
|
+
if foreign_key_attribute.is_a?(Array)
|
342
|
+
index("#{foreign_key_attribute}_index".to_sym,[foreign_key_attribute])
|
343
|
+
end
|
342
344
|
end
|
343
345
|
|
344
346
|
end
|
@@ -629,7 +631,7 @@ module NotRelational
|
|
629
631
|
result={}
|
630
632
|
# #todo refactor to avoid this copy
|
631
633
|
self.class.attribute_descriptions.values.each do |description|
|
632
|
-
if !description.
|
634
|
+
if !description.is_text? || is_dirty(description.name)
|
633
635
|
result[description.name]=@attribute_values[description.name]
|
634
636
|
end
|
635
637
|
end
|
@@ -679,7 +681,7 @@ module NotRelational
|
|
679
681
|
attributes={}
|
680
682
|
# #todo refactor to avoid this copy
|
681
683
|
self.class.attribute_descriptions.values.each do |description|
|
682
|
-
if !description.
|
684
|
+
if !description.is_text? || is_dirty(description.name)
|
683
685
|
value=@attribute_values[description.name]
|
684
686
|
attributes[description]=value
|
685
687
|
end
|
@@ -788,13 +790,13 @@ module NotRelational
|
|
788
790
|
end
|
789
791
|
def istantiate(sdb_attributes,repository)
|
790
792
|
this_result=new(sdb_attributes||{})
|
791
|
-
|
793
|
+
get_text_proc=nil
|
792
794
|
clob_attribute_names.each do |clob_attribute_name|
|
793
|
-
|
794
|
-
repository.
|
795
|
+
get_text_proc= proc {
|
796
|
+
repository.get_text(self.table_name,this_result.primary_key,clob_attribute_name)
|
795
797
|
}
|
796
798
|
|
797
|
-
this_result.set_attribute(clob_attribute_name, LazyLoadingText.new(
|
799
|
+
this_result.set_attribute(clob_attribute_name, LazyLoadingText.new(get_text_proc))
|
798
800
|
end
|
799
801
|
this_result
|
800
802
|
end
|
data/lib/not_relational/geo.rb
CHANGED
@@ -6,8 +6,8 @@ module NotRelational
|
|
6
6
|
class LazyLoadingText
|
7
7
|
attr_reader :is_dirty
|
8
8
|
attr_reader :has_loaded
|
9
|
-
def initialize(
|
10
|
-
@
|
9
|
+
def initialize(get_text_proc)
|
10
|
+
@get_text_proc=get_text_proc
|
11
11
|
@has_loaded=false
|
12
12
|
@is_dirty=false
|
13
13
|
end
|
@@ -19,7 +19,7 @@ class LazyLoadingText
|
|
19
19
|
end
|
20
20
|
def value
|
21
21
|
if !@did_load
|
22
|
-
@value= @
|
22
|
+
@value= @get_text_proc.call
|
23
23
|
@has_loaded=true
|
24
24
|
end
|
25
25
|
return @value
|
@@ -12,13 +12,13 @@ module NotRelational
|
|
12
12
|
aws_secret_key= nil,
|
13
13
|
memcache_servers = nil ,
|
14
14
|
a_storage=nil,
|
15
|
-
|
15
|
+
use_seperate_domain_per_model=nil,
|
16
16
|
options={}
|
17
17
|
)
|
18
18
|
options[:memory_only] ||=(aws_key_id==nil)
|
19
19
|
@storage||=Storage.new(aws_key_id,aws_secret_key,memcache_servers,[],options)
|
20
20
|
@domain_name=domain_name
|
21
|
-
@
|
21
|
+
@storage_bucket=clob_bucket
|
22
22
|
end
|
23
23
|
|
24
24
|
def pause
|
@@ -42,7 +42,7 @@ module NotRelational
|
|
42
42
|
end
|
43
43
|
record["metadata%table_name"]=table_name
|
44
44
|
record["metadata%primary_key"]=key
|
45
|
-
@storage.put(@
|
45
|
+
@storage.put(@storage_bucket,key,record)
|
46
46
|
end
|
47
47
|
def query_ids(table_name,attribute_descriptions,options)
|
48
48
|
raise " not supported for memcache repo"
|
@@ -55,17 +55,17 @@ module NotRelational
|
|
55
55
|
def find_one(table_name, primary_key,attribute_descriptions)#, non_clob_attribute_names, clob_attribute_names)
|
56
56
|
|
57
57
|
key=make_cache_key(table_name,primary_key)
|
58
|
-
@storage.get(@
|
58
|
+
@storage.get(@storage_bucket,key)
|
59
59
|
|
60
60
|
|
61
61
|
end
|
62
|
-
def
|
62
|
+
def get_text(table_name,primary_key,clob_name)
|
63
63
|
raise " not supported for memcache repo"
|
64
64
|
|
65
65
|
end
|
66
66
|
def destroy(table_name, primary_key)
|
67
67
|
key=make_cache_key(table_name,primary_key);
|
68
|
-
@storage.put(@
|
68
|
+
@storage.put(@storage_bucket,key,nil)
|
69
69
|
|
70
70
|
end
|
71
71
|
private
|
@@ -13,7 +13,7 @@ module NotRelational
|
|
13
13
|
aws_secret_key= nil,
|
14
14
|
memcache_servers = nil ,
|
15
15
|
dummy=nil,
|
16
|
-
|
16
|
+
use_seperate_domain_per_model=nil,
|
17
17
|
options={}
|
18
18
|
)
|
19
19
|
clear
|
@@ -43,8 +43,8 @@ module NotRelational
|
|
43
43
|
end
|
44
44
|
|
45
45
|
attributes.each do |description,value|
|
46
|
-
if description.
|
47
|
-
@storage.put("",
|
46
|
+
if description.is_text?
|
47
|
+
@storage.put("",make_storage_key(table_name,primary_key,description.name),value)
|
48
48
|
else
|
49
49
|
record[description.name]=value
|
50
50
|
end
|
@@ -211,8 +211,8 @@ module NotRelational
|
|
211
211
|
return @records[make_cache_key(table_name,primary_key)]
|
212
212
|
end
|
213
213
|
|
214
|
-
def
|
215
|
-
return @storage.get("",
|
214
|
+
def get_text(table_name,primary_key,clob_name)
|
215
|
+
return @storage.get("",make_storage_key(table_name,primary_key,clob_name))
|
216
216
|
|
217
217
|
end
|
218
218
|
|
@@ -264,7 +264,7 @@ module NotRelational
|
|
264
264
|
return "cached_objects/#{table_name}/#{primary_key}"
|
265
265
|
end
|
266
266
|
|
267
|
-
def
|
267
|
+
def make_storage_key(table_name,primary_key,clob_name)
|
268
268
|
return "clobs/#{table_name}/#{flatten_key(primary_key)}/#{clob_name}"
|
269
269
|
end
|
270
270
|
|
@@ -23,11 +23,18 @@ class MemoryStorage
|
|
23
23
|
return @attributes[bucket+"sdsdw555"+key]['Content-Type'] if @attributes.has_key?(bucket+"sdsdw555"+key)
|
24
24
|
return nil
|
25
25
|
end
|
26
|
+
def copy(from_bucket,from_key,to_bucket,to_key,attributes=nil)
|
27
|
+
o=get(from_bucket,from_key)
|
28
|
+
put(to_bucket,to_key,o,attributes)
|
26
29
|
|
30
|
+
end
|
27
31
|
def clear()
|
28
32
|
@stuff={}
|
29
33
|
@attributes={}
|
30
34
|
end
|
35
|
+
def real_s3
|
36
|
+
return self
|
37
|
+
end
|
31
38
|
end
|
32
39
|
|
33
40
|
end
|
@@ -24,8 +24,8 @@ class PropertyDescription
|
|
24
24
|
self.is_encrypted=is_encrypted
|
25
25
|
self.is_encrypted=options[:is_encrypted] if options.has_key?(:is_encrypted)
|
26
26
|
end
|
27
|
-
def
|
28
|
-
|
27
|
+
def is_text?
|
28
|
+
return self.value_type==:text
|
29
29
|
end
|
30
30
|
def format_for_sdb(value)
|
31
31
|
return format_for_sdb_single( value) unless self.is_collection==true
|
@@ -26,13 +26,13 @@ module NotRelational
|
|
26
26
|
|
27
27
|
options[:fail_fast]=config.fail_fast
|
28
28
|
@repository= config.repository_class.new(
|
29
|
-
config.
|
30
|
-
config.
|
29
|
+
config.base_domain_name,
|
30
|
+
config.blob_bucket,
|
31
31
|
config.aws_key_id,
|
32
32
|
config.aws_secret_key,
|
33
33
|
config.memcache_servers,
|
34
34
|
nil,
|
35
|
-
config.
|
35
|
+
config.use_seperate_domain_per_model,
|
36
36
|
options)
|
37
37
|
|
38
38
|
end
|
@@ -10,7 +10,7 @@ module NotRelational
|
|
10
10
|
aws_secret_key= nil,
|
11
11
|
memcache_servers = nil ,
|
12
12
|
dummy=nil,
|
13
|
-
|
13
|
+
use_seperate_domain_per_model=nil,
|
14
14
|
options={}
|
15
15
|
)
|
16
16
|
|
@@ -38,7 +38,7 @@ end
|
|
38
38
|
end
|
39
39
|
def find_one(table_name, primary_key,attribute_descriptions)#, non_clob_attribute_names, clob_attribute_names)
|
40
40
|
end
|
41
|
-
def
|
41
|
+
def get_text(table_name,primary_key,clob_name)
|
42
42
|
end
|
43
43
|
def destroy(table_name, primary_key)
|
44
44
|
end
|