bud 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/budplot +37 -12
- data/bin/budtimelines +20 -22
- data/bin/budvis +1 -1
- data/docs/cheat.md +54 -17
- data/docs/operational.md +1 -1
- data/lib/bud.rb +31 -18
- data/lib/bud/bud_meta.rb +7 -7
- data/lib/bud/bust/bust.rb +2 -2
- data/lib/bud/collections.rb +80 -68
- data/lib/bud/deploy/ec2deploy.rb +1 -1
- data/lib/bud/graphs.rb +9 -11
- data/lib/bud/joins.rb +29 -20
- data/lib/bud/monkeypatch.rb +8 -2
- data/lib/bud/rebl.rb +29 -13
- data/lib/bud/rewrite.rb +40 -39
- data/lib/bud/server.rb +1 -1
- data/lib/bud/state.rb +3 -3
- data/lib/bud/storage/dbm.rb +4 -4
- data/lib/bud/storage/tokyocabinet.rb +4 -4
- data/lib/bud/storage/zookeeper.rb +3 -3
- data/lib/bud/stratify.rb +6 -3
- data/lib/bud/viz.rb +1 -1
- data/lib/bud/viz_util.rb +11 -7
- metadata +10 -8
data/lib/bud/server.rb
CHANGED
@@ -37,7 +37,7 @@ module Bud
|
|
37
37
|
def message_received(obj)
|
38
38
|
unless (obj.class <= Array and obj.length == 2 and
|
39
39
|
@bud.tables.include?(obj[0].to_sym) and obj[1].class <= Array)
|
40
|
-
raise BudError, "
|
40
|
+
raise BudError, "bad inbound message of class #{obj.class}: #{obj.inspect}"
|
41
41
|
end
|
42
42
|
|
43
43
|
@bud.rtracer.recv(obj) if @bud.options[:rtrace]
|
data/lib/bud/state.rb
CHANGED
@@ -44,7 +44,7 @@ module Bud
|
|
44
44
|
@tables[name] = Bud::BudTable.new(name, self, schema)
|
45
45
|
end
|
46
46
|
|
47
|
-
# declare a syncronously-flushed persistent collection. default schema <tt>[:key] => [:val]</tt>.
|
47
|
+
# declare a syncronously-flushed persistent collection. default schema <tt>[:key] => [:val]</tt>.
|
48
48
|
def sync(name, storage, schema=nil)
|
49
49
|
define_collection(name)
|
50
50
|
case storage
|
@@ -55,7 +55,7 @@ module Bud
|
|
55
55
|
@tables[name] = Bud::BudTcTable.new(name, self, schema)
|
56
56
|
@tc_tables[name] = @tables[name]
|
57
57
|
else
|
58
|
-
raise BudError, "
|
58
|
+
raise BudError, "unknown synchronous storage engine #{storage.to_s}"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -70,7 +70,7 @@ module Bud
|
|
70
70
|
@tables[name] = Bud::BudZkTable.new(name, options[:path], options[:addr], self)
|
71
71
|
@zk_tables[name] = @tables[name]
|
72
72
|
else
|
73
|
-
raise BudError, "
|
73
|
+
raise BudError, "unknown async storage engine #{storage.to_s}"
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
data/lib/bud/storage/dbm.rb
CHANGED
@@ -30,7 +30,7 @@ module Bud
|
|
30
30
|
end
|
31
31
|
@dbm = DBM.open(db_fname, 0666, flags)
|
32
32
|
if @dbm.nil?
|
33
|
-
raise BudError, "
|
33
|
+
raise BudError, "failed to open dbm database '#{db_fname}': #{@dbm.errmsg}"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -68,7 +68,7 @@ module Bud
|
|
68
68
|
t[k] = k_ary[i]
|
69
69
|
end
|
70
70
|
val_cols.each_with_index do |c,i|
|
71
|
-
t[
|
71
|
+
t[cols.index(c)] = v_ary[i]
|
72
72
|
end
|
73
73
|
tuple_accessors(t)
|
74
74
|
end
|
@@ -115,7 +115,7 @@ module Bud
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def merge_tuple(key, tuple)
|
118
|
-
val = val_cols.map{|c| tuple[
|
118
|
+
val = val_cols.map{|c| tuple[cols.index(c)]}
|
119
119
|
key_s = MessagePack.pack(key)
|
120
120
|
val_s = MessagePack.pack(val)
|
121
121
|
if @dbm.has_key?(key_s)
|
@@ -154,7 +154,7 @@ module Bud
|
|
154
154
|
cols_str = @dbm[k_str]
|
155
155
|
unless cols_str.nil?
|
156
156
|
db_cols = MessagePack.unpack(cols_str)
|
157
|
-
delete_cols = val_cols.map{|c| tuple[
|
157
|
+
delete_cols = val_cols.map{|c| tuple[cols.index(c)]}
|
158
158
|
if db_cols == delete_cols
|
159
159
|
@dbm.delete k_str
|
160
160
|
end
|
@@ -35,7 +35,7 @@ module Bud
|
|
35
35
|
flags |= TokyoCabinet::HDB::OTRUNC
|
36
36
|
end
|
37
37
|
if !@hdb.open(db_fname, flags)
|
38
|
-
raise BudError, "
|
38
|
+
raise BudError, "failed to open TokyoCabinet DB '#{db_fname}': #{@hdb.errmsg}"
|
39
39
|
end
|
40
40
|
@hdb.tranbegin
|
41
41
|
end
|
@@ -74,7 +74,7 @@ module Bud
|
|
74
74
|
t[k] = k_ary[i]
|
75
75
|
end
|
76
76
|
val_cols.each_with_index do |c,i|
|
77
|
-
t[
|
77
|
+
t[cols.index(c)] = v_ary[i]
|
78
78
|
end
|
79
79
|
tuple_accessors(t)
|
80
80
|
end
|
@@ -121,7 +121,7 @@ module Bud
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def merge_tuple(key, tuple)
|
124
|
-
val = val_cols.map{|c| tuple[
|
124
|
+
val = val_cols.map{|c| tuple[cols.index(c)]}
|
125
125
|
key_s = MessagePack.pack(key)
|
126
126
|
val_s = MessagePack.pack(val)
|
127
127
|
if @hdb.putkeep(key_s, val_s) == false
|
@@ -158,7 +158,7 @@ module Bud
|
|
158
158
|
cols_str = @hdb[k_str]
|
159
159
|
unless cols_str.nil?
|
160
160
|
hdb_cols = MessagePack.unpack(cols_str)
|
161
|
-
delete_cols = val_cols.map{|c| tuple[
|
161
|
+
delete_cols = val_cols.map{|c| tuple[cols.index(c)]}
|
162
162
|
if hdb_cols == delete_cols
|
163
163
|
@hdb.delete k_str
|
164
164
|
end
|
@@ -164,15 +164,15 @@ module Bud
|
|
164
164
|
end
|
165
165
|
|
166
166
|
superator "<+" do |o|
|
167
|
-
raise BudError, "
|
167
|
+
raise BudError, "illegal use of <+ with zookeeper store '#{@tabname}' on left"
|
168
168
|
end
|
169
169
|
|
170
170
|
def <=(o)
|
171
|
-
raise BudError, "
|
171
|
+
raise BudError, "illegal use of <= with zookeeper store '#{@tabname}' on left"
|
172
172
|
end
|
173
173
|
|
174
174
|
def <<(o)
|
175
|
-
raise BudError, "
|
175
|
+
raise BudError, "illegal use of << with zookeeper store '#{@tabname}' on left"
|
176
176
|
end
|
177
177
|
end
|
178
178
|
end
|
data/lib/bud/stratify.rb
CHANGED
@@ -8,12 +8,15 @@ class Stratification # :nodoc: all
|
|
8
8
|
# Data inserted by client (Bud rewrite code)
|
9
9
|
table :depends, [:rule, :head, :op, :body, :neg]
|
10
10
|
|
11
|
+
# Intermediate state
|
11
12
|
scratch :depends_clean, [:head, :body, :neg, :temporal]
|
12
13
|
scratch :depends_tc, [:head, :body, :via, :neg, :temporal]
|
14
|
+
scratch :stratum_base, [:predicate, :stratum]
|
15
|
+
|
16
|
+
# Output state
|
13
17
|
scratch :cycle, [:predicate, :via, :neg, :temporal]
|
14
|
-
|
15
|
-
|
16
|
-
table :top_strat, [:stratum]
|
18
|
+
scratch :stratum, [:predicate, :stratum]
|
19
|
+
scratch :top_strat, [:stratum]
|
17
20
|
end
|
18
21
|
|
19
22
|
def declaration
|
data/lib/bud/viz.rb
CHANGED
data/lib/bud/viz_util.rb
CHANGED
@@ -51,10 +51,10 @@ class VizHelper
|
|
51
51
|
end
|
52
52
|
|
53
53
|
d = "#{@dir}/tm_#{time.bud_time}"
|
54
|
-
write_graphs(@t_tabinf, @t_cycle, @t_depends, @t_rules, d,
|
54
|
+
write_graphs(@t_tabinf, builtin_tables, @t_cycle, @t_depends, @t_rules, d,
|
55
|
+
@dir, nil, false, nil, time.bud_time, card_info)
|
55
56
|
end
|
56
57
|
end
|
57
|
-
|
58
58
|
end
|
59
59
|
|
60
60
|
|
@@ -65,12 +65,15 @@ module VizUtil #:nodoc: all
|
|
65
65
|
tab = t[0].to_s
|
66
66
|
tabinf[tab] = t[1].class.to_s
|
67
67
|
end
|
68
|
-
write_graphs(tabinf, bud_instance.
|
68
|
+
write_graphs(tabinf, bud_instance.builtin_tables, bud_instance.t_cycle,
|
69
|
+
bud_instance.t_depends, bud_instance.t_rules, viz_name,
|
70
|
+
output_base, fmt, collapse, bud_instance.meta_parser.depanalysis)
|
69
71
|
end
|
70
72
|
|
71
|
-
def write_graphs(tabinf, cycle, depends, rules, viz_name,
|
73
|
+
def write_graphs(tabinf, builtin_tables, cycle, depends, rules, viz_name,
|
74
|
+
output_base, fmt, collapse, depanalysis=nil, budtime=-1, card_info=nil)
|
72
75
|
staging = "#{viz_name}.staging"
|
73
|
-
gv = GraphGen.new(tabinf, cycle, staging, budtime, collapse, card_info)
|
76
|
+
gv = GraphGen.new(tabinf, builtin_tables, cycle, staging, budtime, collapse, card_info)
|
74
77
|
gv.process(depends)
|
75
78
|
dump(rules, output_base, gv)
|
76
79
|
gv.finish(depanalysis, fmt)
|
@@ -117,7 +120,7 @@ module VizUtil #:nodoc: all
|
|
117
120
|
code[v[0]] = "\n# RULE #{k}\n " + code[v[0]] + "\n" + v[1]
|
118
121
|
end
|
119
122
|
gv_obj.nodes.each_pair do |k, v|
|
120
|
-
fout = File.new("#{output_base}/#{k}.html", "w+")
|
123
|
+
fout = File.new("#{output_base}/#{k[0..55]}.html", "w+")
|
121
124
|
fout.puts header
|
122
125
|
k.split(", ").each do |i|
|
123
126
|
unless code[i].nil?
|
@@ -213,6 +216,8 @@ END_JS
|
|
213
216
|
meta_tabs = {"t_table_info" => :tabinf, "t_table_schema" => :tabscm, "t_cycle" => :cycle, "t_depends" => :depends, "t_rules" => :rules}
|
214
217
|
meta = {}
|
215
218
|
data = []
|
219
|
+
|
220
|
+
dir = Dir.glob("#{dir}/bud*").first
|
216
221
|
ret = DBM.open("#{dir}/the_big_log.dbm")
|
217
222
|
ret.each_pair do |k, v|
|
218
223
|
key = MessagePack.unpack(k)
|
@@ -270,5 +275,4 @@ END_JS
|
|
270
275
|
stream.puts "</tr>"
|
271
276
|
stream.close
|
272
277
|
end
|
273
|
-
|
274
278
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Peter Alvaro
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-
|
21
|
+
date: 2011-10-09 00:00:00 Z
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
24
|
name: backports
|
@@ -180,12 +180,14 @@ dependencies:
|
|
180
180
|
requirement: &id012 !ruby/object:Gem::Requirement
|
181
181
|
none: false
|
182
182
|
requirements:
|
183
|
-
- -
|
183
|
+
- - <
|
184
184
|
- !ruby/object:Gem::Version
|
185
|
-
hash:
|
185
|
+
hash: 25
|
186
186
|
segments:
|
187
|
-
-
|
188
|
-
|
187
|
+
- 1
|
188
|
+
- 3
|
189
|
+
- 1
|
190
|
+
version: 1.3.1
|
189
191
|
type: :runtime
|
190
192
|
version_requirements: *id012
|
191
193
|
- !ruby/object:Gem::Dependency
|