strokedb 0.0.2.1 → 0.0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +18 -20
- data/bench.html +4001 -0
- data/bin/strokedb +14 -0
- data/examples/movies.rb +105 -0
- data/examples/movies2.rb +97 -0
- data/examples/strokewiki/README +28 -0
- data/examples/strokewiki/view/edit.xhtml +27 -0
- data/examples/strokewiki/view/new.xhtml +26 -0
- data/examples/strokewiki/view/pages.xhtml +27 -0
- data/examples/strokewiki/view/show.xhtml +40 -0
- data/examples/strokewiki/view/versions.xhtml +25 -0
- data/examples/strokewiki/wiki.rb +106 -0
- data/examples/todo.rb +92 -0
- data/lib/strokedb.rb +85 -0
- data/lib/{config → strokedb}/config.rb +14 -9
- data/lib/strokedb/console.rb +87 -0
- data/lib/strokedb/core_ext.rb +10 -0
- data/lib/{util/ext → strokedb/core_ext}/blank.rb +1 -1
- data/lib/{util/ext → strokedb/core_ext}/enumerable.rb +0 -0
- data/lib/{util/ext → strokedb/core_ext}/fixnum.rb +0 -0
- data/lib/strokedb/core_ext/float.rb +4 -0
- data/lib/{util/ext → strokedb/core_ext}/hash.rb +0 -0
- data/lib/strokedb/core_ext/infinity.rb +33 -0
- data/lib/strokedb/core_ext/kernel.rb +41 -0
- data/lib/strokedb/core_ext/object.rb +16 -0
- data/lib/{util/ext → strokedb/core_ext}/string.rb +28 -1
- data/lib/strokedb/core_ext/symbol.rb +13 -0
- data/lib/strokedb/data_structures.rb +5 -0
- data/lib/strokedb/data_structures/chunked_skiplist.rb +123 -0
- data/lib/{data_structures → strokedb/data_structures}/inverted_list.rb +0 -0
- data/lib/{data_structures → strokedb/data_structures}/point_query.rb +0 -0
- data/lib/strokedb/data_structures/simple_skiplist.rb +350 -0
- data/lib/{data_structures → strokedb/data_structures}/skiplist.rb +1 -1
- data/lib/{document → strokedb}/document.rb +180 -71
- data/lib/{document → strokedb/document}/callback.rb +0 -0
- data/lib/{document → strokedb/document}/delete.rb +2 -2
- data/lib/strokedb/document/dsl.rb +4 -0
- data/lib/{document → strokedb/document/dsl}/associations.rb +0 -0
- data/lib/{document → strokedb/document/dsl}/coercions.rb +0 -0
- data/lib/strokedb/document/dsl/meta_dsl.rb +7 -0
- data/lib/{document → strokedb/document/dsl}/validations.rb +26 -21
- data/lib/{document → strokedb/document/dsl}/virtualize.rb +0 -0
- data/lib/{document → strokedb/document}/meta.rb +92 -29
- data/lib/{document → strokedb/document}/slot.rb +17 -5
- data/lib/{document → strokedb/document}/util.rb +0 -0
- data/lib/{document → strokedb/document}/versions.rb +2 -2
- data/lib/strokedb/index.rb +2 -0
- data/lib/strokedb/nsurl.rb +24 -0
- data/lib/strokedb/store.rb +149 -0
- data/lib/strokedb/stores.rb +6 -0
- data/lib/{stores → strokedb/stores}/chainable_storage.rb +20 -14
- data/lib/strokedb/stores/file_storage.rb +118 -0
- data/lib/{stores/inverted_list_index → strokedb/stores}/inverted_list_file_storage.rb +50 -0
- data/lib/strokedb/stores/memory_storage.rb +80 -0
- data/lib/{stores → strokedb/stores}/remote_store.rb +10 -4
- data/lib/strokedb/sync.rb +4 -0
- data/lib/{sync → strokedb/sync}/chain_sync.rb +0 -0
- data/lib/{sync → strokedb/sync}/diff.rb +12 -1
- data/lib/{sync/stroke_diff → strokedb/sync/diff}/array.rb +1 -1
- data/lib/{sync/stroke_diff → strokedb/sync/diff}/default.rb +0 -0
- data/lib/{sync/stroke_diff → strokedb/sync/diff}/hash.rb +1 -1
- data/lib/{sync/stroke_diff → strokedb/sync/diff}/string.rb +1 -1
- data/lib/{sync → strokedb/sync}/lamport_timestamp.rb +0 -0
- data/lib/{sync → strokedb/sync}/store_sync.rb +15 -7
- data/lib/strokedb/transaction.rb +78 -0
- data/lib/{util → strokedb}/util.rb +14 -7
- data/lib/strokedb/util/attach_dsl.rb +29 -0
- data/lib/{util → strokedb/util}/blankslate.rb +0 -0
- data/lib/strokedb/util/class_optimization.rb +93 -0
- data/lib/{util → strokedb/util}/inflect.rb +0 -0
- data/lib/strokedb/util/java_util.rb +13 -0
- data/lib/{util → strokedb/util}/lazy_array.rb +0 -0
- data/lib/{util → strokedb/util}/lazy_mapping_array.rb +4 -0
- data/lib/{util → strokedb/util}/lazy_mapping_hash.rb +0 -0
- data/lib/{util → strokedb/util}/serialization.rb +21 -0
- data/lib/strokedb/util/uuid.rb +159 -0
- data/lib/{util → strokedb/util}/xml.rb +0 -0
- data/lib/{view → strokedb}/view.rb +2 -2
- data/lib/strokedb/volumes.rb +5 -0
- data/lib/strokedb/volumes/archive_volume.rb +165 -0
- data/lib/strokedb/volumes/block_volume.rb +169 -0
- data/lib/strokedb/volumes/distributed_pointer.rb +43 -0
- data/lib/strokedb/volumes/fixed_length_skiplist_volume.rb +109 -0
- data/lib/strokedb/volumes/map_volume.rb +268 -0
- data/meta/MANIFEST +175 -0
- data/script/console +2 -70
- data/spec/integration/remote_store_spec.rb +70 -0
- data/spec/integration/search_spec.rb +76 -0
- data/spec/integration/spec_helper.rb +1 -0
- data/spec/lib/spec_helper.rb +1 -0
- data/spec/lib/strokedb/config_spec.rb +250 -0
- data/spec/lib/strokedb/core_ext/blank_spec.rb +20 -0
- data/spec/lib/strokedb/core_ext/extract_spec.rb +42 -0
- data/spec/lib/strokedb/core_ext/float_spec.rb +62 -0
- data/spec/lib/strokedb/core_ext/infinity_spec.rb +40 -0
- data/spec/lib/strokedb/core_ext/spec_helper.rb +1 -0
- data/spec/lib/strokedb/core_ext/string_spec.rb +25 -0
- data/spec/lib/strokedb/core_ext/symbol_spec.rb +8 -0
- data/spec/lib/strokedb/data_structures/chunked_skiplist_spec.rb +144 -0
- data/spec/lib/strokedb/data_structures/inverted_list_spec.rb +172 -0
- data/spec/lib/strokedb/data_structures/simple_skiplist_spec.rb +200 -0
- data/spec/lib/strokedb/data_structures/skiplist_spec.rb +253 -0
- data/spec/lib/strokedb/data_structures/spec_helper.rb +1 -0
- data/spec/lib/strokedb/document/associations_spec.rb +319 -0
- data/spec/lib/strokedb/document/callbacks_spec.rb +134 -0
- data/spec/lib/strokedb/document/coercions_spec.rb +110 -0
- data/spec/lib/strokedb/document/document_spec.rb +1063 -0
- data/spec/lib/strokedb/document/meta_meta_spec.rb +30 -0
- data/spec/lib/strokedb/document/meta_spec.rb +435 -0
- data/spec/lib/strokedb/document/metaslot_spec.rb +43 -0
- data/spec/lib/strokedb/document/slot_spec.rb +130 -0
- data/spec/lib/strokedb/document/spec_helper.rb +1 -0
- data/spec/lib/strokedb/document/validations_spec.rb +1081 -0
- data/spec/lib/strokedb/document/virtualize_spec.rb +80 -0
- data/spec/lib/strokedb/nsurl_spec.rb +73 -0
- data/spec/lib/strokedb/spec_helper.rb +1 -0
- data/spec/lib/strokedb/stores/chained_storages_spec.rb +116 -0
- data/spec/lib/strokedb/stores/spec_helper.rb +1 -0
- data/spec/lib/strokedb/stores/store_spec.rb +201 -0
- data/spec/lib/strokedb/stores/transaction_spec.rb +107 -0
- data/spec/lib/strokedb/sync/chain_sync_spec.rb +43 -0
- data/spec/lib/strokedb/sync/diff_spec.rb +111 -0
- data/spec/lib/strokedb/sync/lamport_timestamp_spec.rb +174 -0
- data/spec/lib/strokedb/sync/slot_diff_spec.rb +164 -0
- data/spec/lib/strokedb/sync/spec_helper.rb +1 -0
- data/spec/lib/strokedb/sync/store_sync_spec.rb +181 -0
- data/spec/lib/strokedb/sync/stroke_diff/array_spec.rb +97 -0
- data/spec/lib/strokedb/sync/stroke_diff/complex_spec.rb +58 -0
- data/spec/lib/strokedb/sync/stroke_diff/hash_spec.rb +144 -0
- data/spec/lib/strokedb/sync/stroke_diff/scalar_spec.rb +23 -0
- data/spec/lib/strokedb/sync/stroke_diff/spec_helper.rb +25 -0
- data/spec/lib/strokedb/sync/stroke_diff/string_spec.rb +61 -0
- data/spec/lib/strokedb/util/attach_dsl_spec.rb +45 -0
- data/spec/lib/strokedb/util/inflect_spec.rb +14 -0
- data/spec/lib/strokedb/util/lazy_array_spec.rb +157 -0
- data/spec/lib/strokedb/util/lazy_mapping_array_spec.rb +174 -0
- data/spec/lib/strokedb/util/lazy_mapping_hash_spec.rb +92 -0
- data/spec/lib/strokedb/util/spec_helper.rb +1 -0
- data/spec/lib/strokedb/util/uuid_spec.rb +46 -0
- data/spec/lib/strokedb/view_spec.rb +228 -0
- data/spec/lib/strokedb/volumes/archive_volume_spec.rb +105 -0
- data/spec/lib/strokedb/volumes/block_volume_spec.rb +100 -0
- data/spec/lib/strokedb/volumes/distributed_pointer_spec.rb +14 -0
- data/spec/lib/strokedb/volumes/fixed_length_skiplist_volume_spec.rb +177 -0
- data/spec/lib/strokedb/volumes/map_volume_spec.rb +172 -0
- data/spec/lib/strokedb/volumes/spec_helper.rb +1 -0
- data/spec/regression/docref_spec.rb +94 -0
- data/spec/regression/meta_spec.rb +23 -0
- data/spec/regression/spec_helper.rb +1 -0
- data/spec/regression/sync_spec.rb +36 -0
- data/spec/spec.opts +7 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/temp/storages/TIMESTAMP +1 -0
- data/spec/temp/storages/UUID +1 -0
- data/spec/temp/storages/database-sync/TIMESTAMP +1 -0
- data/spec/temp/storages/database-sync/UUID +1 -0
- data/spec/temp/storages/database-sync/config +1 -0
- data/spec/temp/storages/database-sync/file/LAST +1 -0
- data/spec/temp/storages/database-sync/file/bd/f6/bdf675e5-8a7b-494e-97f2-f74a14ccd95d.av +0 -0
- data/spec/temp/storages/database-sync/file/uindex.wal +0 -0
- data/spec/temp/storages/database-sync/inverted_list_file/INVERTED_INDEX +1 -0
- data/spec/temp/storages/inverted_list_storage/INVERTED_INDEX +0 -0
- data/strokedb.gemspec +120 -0
- data/task/benchmark.task +9 -0
- data/task/ditz.task +30 -0
- data/task/echoe.rb +17 -0
- data/task/rcov.task +50 -0
- data/task/rdoc.task +10 -0
- data/task/rspec.task +0 -0
- data/vendor/java_inline.rb +106 -0
- data/vendor/rbmodexcl/mrimodexcl.rb +82 -0
- data/vendor/rbmodexcl/rbmodexcl.rb +5 -0
- data/vendor/rbmodexcl/rbxmodexcl.rb +48 -0
- data/vendor/rbmodexcl/spec/unextend_spec.rb +50 -0
- data/vendor/rbmodexcl/spec/uninclude_spec.rb +26 -0
- metadata +271 -79
- data/CONTRIBUTORS +0 -7
- data/CREDITS +0 -13
- data/bin/sdbc +0 -2
- data/lib/init.rb +0 -57
- data/lib/stores/inverted_list_index/inverted_list_index.rb +0 -49
- data/lib/stores/skiplist_store/chunk.rb +0 -119
- data/lib/stores/skiplist_store/chunk_storage.rb +0 -21
- data/lib/stores/skiplist_store/file_chunk_storage.rb +0 -44
- data/lib/stores/skiplist_store/memory_chunk_storage.rb +0 -37
- data/lib/stores/skiplist_store/skiplist_store.rb +0 -217
- data/lib/stores/store.rb +0 -5
- data/lib/sync/stroke_diff/stroke_diff.rb +0 -9
- data/lib/util/ext/object.rb +0 -8
- data/lib/util/java_util.rb +0 -9
- data/lib/util/trigger_partition.rb +0 -136
- data/strokedb.rb +0 -75
data/lib/stores/store.rb
DELETED
data/lib/util/ext/object.rb
DELETED
data/lib/util/java_util.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
module Enumerable
|
2
|
-
class TriggerPartitionContext
|
3
|
-
def initialize(enum, &block)
|
4
|
-
@enum = enum
|
5
|
-
@cont = block
|
6
|
-
end
|
7
|
-
def fill(&block)
|
8
|
-
@fill = block
|
9
|
-
self
|
10
|
-
end
|
11
|
-
def emit
|
12
|
-
partitions = []
|
13
|
-
cont = @cont
|
14
|
-
fill = @fill
|
15
|
-
p = @enum.inject(nil) do |part, elem|
|
16
|
-
if part && cont.call(part, elem)
|
17
|
-
fill.call(part, elem)
|
18
|
-
part
|
19
|
-
else
|
20
|
-
partitions << part if part
|
21
|
-
yield(elem)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
partitions << p if p
|
25
|
-
partitions
|
26
|
-
end
|
27
|
-
end
|
28
|
-
def trigger_partition(&block)
|
29
|
-
TriggerPartitionContext.new(self, &block)
|
30
|
-
end
|
31
|
-
|
32
|
-
class TriggerPartitions
|
33
|
-
def self.partition(list)
|
34
|
-
partitions = []
|
35
|
-
p = list.inject(nil) do |part, elem|
|
36
|
-
if part && continue?(part, elem)
|
37
|
-
fill(part, elem)
|
38
|
-
part
|
39
|
-
else
|
40
|
-
partitions << part if part
|
41
|
-
emit(elem)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
partitions << p if p
|
45
|
-
partitions
|
46
|
-
end
|
47
|
-
def self.continue?(p, e)
|
48
|
-
true
|
49
|
-
end
|
50
|
-
def self.emit(e)
|
51
|
-
[e]
|
52
|
-
end
|
53
|
-
def self.fill(p, e)
|
54
|
-
p << e
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
if __FILE__ == $0
|
60
|
-
arr = [1,2,3,4,5, -1, -4, -3, 5, 6, 7, 8, -6, -7]
|
61
|
-
parr = arr.trigger_partition do |partition, element|
|
62
|
-
partition[0] > 0 && element > 0 || partition[0] < 0 && element < 0
|
63
|
-
end.fill do |p, e|
|
64
|
-
p << e
|
65
|
-
end.emit do |e|
|
66
|
-
[e]
|
67
|
-
end
|
68
|
-
|
69
|
-
p arr
|
70
|
-
p parr
|
71
|
-
|
72
|
-
# Class might be faster
|
73
|
-
class SignPartitions < Enumerable::TriggerPartitions
|
74
|
-
def self.continue?(partition, element)
|
75
|
-
partition[0] > 0 && element > 0 || partition[0] < 0 && element < 0
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
p Enumerable::TriggerPartitions.partition(arr)
|
80
|
-
p SignPartitions.partition(arr)
|
81
|
-
|
82
|
-
require 'benchmark'
|
83
|
-
include Benchmark
|
84
|
-
n = 1000
|
85
|
-
bm(32) do |x|
|
86
|
-
x.report("#{n} times:" ) do
|
87
|
-
n.times do
|
88
|
-
arr.trigger_partition do |partition, element|
|
89
|
-
partition[0] > 0 && element > 0 || partition[0] < 0 && element < 0
|
90
|
-
end.fill do |p, e|
|
91
|
-
p << e
|
92
|
-
end.emit do |e|
|
93
|
-
[e]
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
arrL = arr*28
|
98
|
-
x.report("#{n} times (x28 larger data):" ) do
|
99
|
-
n.times do
|
100
|
-
arrL.trigger_partition do |partition, element|
|
101
|
-
partition[0] > 0 && element > 0 || partition[0] < 0 && element < 0
|
102
|
-
end.fill do |p, e|
|
103
|
-
p << e
|
104
|
-
end.emit do |e|
|
105
|
-
[e]
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
# 35% faster
|
110
|
-
x.report("#{n} times (SignPartitions):" ) do
|
111
|
-
(n/5).times do
|
112
|
-
SignPartitions.partition(arrL)
|
113
|
-
SignPartitions.partition(arrL)
|
114
|
-
SignPartitions.partition(arrL)
|
115
|
-
SignPartitions.partition(arrL)
|
116
|
-
SignPartitions.partition(arrL)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
# + 17% faster (relative to SignPartitions)
|
120
|
-
x.report("#{n} times (raw code):" ) do
|
121
|
-
n.times do
|
122
|
-
parts = []
|
123
|
-
p = arrL.inject(nil) do |partition, element|
|
124
|
-
if partition && (partition[0] > 0 && element > 0 || partition[0] < 0 && element < 0)
|
125
|
-
partition << element
|
126
|
-
partition
|
127
|
-
else
|
128
|
-
parts << partition if partition
|
129
|
-
[element]
|
130
|
-
end
|
131
|
-
end
|
132
|
-
parts << p if p
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
data/strokedb.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
ruby_debug_path = File.dirname(__FILE__) + '/../dependencies/ruby-debug-0.10.0/cli/'
|
2
|
-
|
3
|
-
if ENV["DEBUGGER"]
|
4
|
-
if File.exist?(ruby_debug_path)
|
5
|
-
$:.unshift( ruby_debug_path )
|
6
|
-
else
|
7
|
-
puts "Using ruby-debug gem"
|
8
|
-
require 'rubygems'
|
9
|
-
end
|
10
|
-
|
11
|
-
require 'ruby-debug'
|
12
|
-
ENV["DEBUG"] = 1
|
13
|
-
else
|
14
|
-
module Kernel
|
15
|
-
def debugger; end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
require 'rubygems'
|
20
|
-
begin
|
21
|
-
require 'json'
|
22
|
-
rescue LoadError
|
23
|
-
begin
|
24
|
-
require 'json_pure'
|
25
|
-
rescue LoadError
|
26
|
-
raise LoadError, 'Could not find json or json_pure'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
require 'set'
|
31
|
-
require 'fileutils'
|
32
|
-
require 'drb'
|
33
|
-
require 'drb/acl'
|
34
|
-
require 'drb/unix'
|
35
|
-
|
36
|
-
class SmartassLoader
|
37
|
-
def initialize(pattern)
|
38
|
-
@pattern = pattern
|
39
|
-
@req_paths = {}
|
40
|
-
end
|
41
|
-
|
42
|
-
def require!
|
43
|
-
paths = Dir[File.dirname(__FILE__) + "/" + @pattern].select do |p|
|
44
|
-
(p !~ /\/java_/ || RUBY_PLATFORM =~ /java/) && p =~ /\.rb$/
|
45
|
-
end.sort.map do |p|
|
46
|
-
File.expand_path(p)
|
47
|
-
end
|
48
|
-
require_rest_paths(paths)
|
49
|
-
end
|
50
|
-
|
51
|
-
def require_rest_paths(paths, i = 0)
|
52
|
-
ENV['DEBUG'] = "1" if i == 10
|
53
|
-
ENV.delete('DEBUG') if i == 20
|
54
|
-
broken_paths = []
|
55
|
-
paths.each do |p|
|
56
|
-
begin
|
57
|
-
if @req_paths[p]
|
58
|
-
load p
|
59
|
-
puts "Resolved: #{p}" if ENV["DEBUG"]
|
60
|
-
else
|
61
|
-
@req_paths[p] = 1
|
62
|
-
require p
|
63
|
-
end
|
64
|
-
rescue NameError => e
|
65
|
-
puts "Not resolved: #{p}" if ENV["DEBUG"]
|
66
|
-
puts e if ENV["DEBUG"]
|
67
|
-
broken_paths.push p
|
68
|
-
end
|
69
|
-
end
|
70
|
-
# Stack grows...
|
71
|
-
require_rest_paths(broken_paths, i + 1) unless broken_paths.empty?
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
SmartassLoader.new("lib/**/*").require!
|