bud 0.0.3 → 0.0.4
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/README +33 -16
- data/bin/budplot +42 -65
- data/bin/budtimelines +235 -0
- data/bin/budvis +24 -122
- data/bin/rebl +1 -0
- data/docs/README.md +21 -10
- data/docs/bfs.md +4 -6
- data/docs/c.html +251 -0
- data/docs/cheat.md +45 -30
- data/docs/deploy.md +26 -26
- data/docs/getstarted.md +6 -4
- data/docs/visualizations.md +43 -31
- data/examples/chat/chat.rb +4 -9
- data/examples/chat/chat_server.rb +1 -8
- data/examples/deploy/deploy_ip_port +1 -0
- data/examples/deploy/keys.rb +5 -0
- data/examples/deploy/tokenring-ec2.rb +9 -9
- data/examples/deploy/{tokenring-local.rb → tokenring-fork.rb} +3 -5
- data/examples/deploy/tokenring-thread.rb +15 -0
- data/examples/deploy/tokenring.rb +25 -17
- data/lib/bud/aggs.rb +87 -25
- data/lib/bud/bud_meta.rb +48 -31
- data/lib/bud/bust/bust.rb +16 -15
- data/lib/bud/collections.rb +207 -232
- data/lib/bud/depanalysis.rb +1 -0
- data/lib/bud/deploy/countatomicdelivery.rb +8 -20
- data/lib/bud/deploy/deployer.rb +16 -16
- data/lib/bud/deploy/ec2deploy.rb +34 -35
- data/lib/bud/deploy/forkdeploy.rb +90 -0
- data/lib/bud/deploy/threaddeploy.rb +38 -0
- data/lib/bud/graphs.rb +103 -199
- data/lib/bud/joins.rb +190 -41
- data/lib/bud/monkeypatch.rb +84 -0
- data/lib/bud/rebl.rb +8 -1
- data/lib/bud/rewrite.rb +152 -49
- data/lib/bud/server.rb +1 -0
- data/lib/bud/state.rb +24 -10
- data/lib/bud/storage/dbm.rb +170 -0
- data/lib/bud/storage/tokyocabinet.rb +5 -1
- data/lib/bud/stratify.rb +6 -7
- data/lib/bud/viz.rb +31 -17
- data/lib/bud/viz_util.rb +204 -0
- data/lib/bud.rb +271 -244
- data/lib/bud.rb.orig +806 -0
- metadata +43 -22
- data/docs/bfs.raw +0 -251
- data/docs/diffs +0 -181
- data/examples/basics/out +0 -1103
- data/examples/basics/out.new +0 -856
- data/lib/bud/deploy/localdeploy.rb +0 -53
data/lib/bud/viz.rb
CHANGED
@@ -9,19 +9,17 @@ class VizOnline #:nodoc: all
|
|
9
9
|
@bud_instance = bud_instance
|
10
10
|
return if bud_instance.class == Stratification or @bud_instance.class == DepAnalysis
|
11
11
|
@meta_tables = {'t_rules' => 1, 't_depends' => 1, 't_table_info' => 1, 't_cycle' => 1, 't_stratum' => 1, 't_depends_tc' => 1, 't_table_schema' => 1}
|
12
|
-
@bud_instance.options[:
|
13
|
-
@table_info =
|
14
|
-
@table_schema =
|
15
|
-
|
16
|
-
@logtab = {}
|
12
|
+
@bud_instance.options[:dbm_dir] = "DBM_#{@bud_instance.class}_#{bud_instance.options[:tag]}_#{bud_instance.object_id}_#{bud_instance.port}"
|
13
|
+
@table_info = bud_instance.tables[:t_table_info]
|
14
|
+
@table_schema = bud_instance.tables[:t_table_schema]
|
15
|
+
@logtab = new_tab("the_big_log", [:table, :time, :contents], bud_instance)
|
17
16
|
tmp_set = []
|
18
17
|
@bud_instance.tables.each do |name, tbl|
|
19
|
-
next if name
|
20
|
-
|
18
|
+
next if name == "the_big_log"
|
21
19
|
# Temp collections don't have a schema until a fact has been inserted into
|
22
20
|
# them; for now, we just include an empty schema for them in the viz
|
23
21
|
if tbl.schema.nil?
|
24
|
-
schema = []
|
22
|
+
schema = [:a, :b, :c, :d]
|
25
23
|
else
|
26
24
|
schema = tbl.schema.clone
|
27
25
|
end
|
@@ -30,36 +28,52 @@ class VizOnline #:nodoc: all
|
|
30
28
|
|
31
29
|
tmp_set.each do |t|
|
32
30
|
news = [:c_bud_time]
|
31
|
+
snd_alias = t[0].to_s + "_snd"
|
33
32
|
@table_schema << [t[0], :c_bud_time, 0]
|
34
33
|
t[1].each_with_index do |s, i|
|
35
34
|
news << s
|
36
35
|
@table_schema << [t[0], s, i+1]
|
36
|
+
if t[2] == "Bud::BudChannel"
|
37
|
+
@table_schema << [snd_alias, s, i+1]
|
38
|
+
end
|
37
39
|
end
|
38
40
|
lt = "#{t[0]}_vizlog".to_sym
|
39
|
-
|
41
|
+
if t[2] == "Bud::BudChannel"
|
42
|
+
lts = "#{snd_alias}_vizlog".to_sym
|
43
|
+
@table_info << [snd_alias, t[2]]
|
44
|
+
end
|
40
45
|
@table_info << [t[0], t[2]]
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
44
49
|
def new_tab(name, schema, instance)
|
45
|
-
ret = Bud::
|
50
|
+
ret = Bud::BudDbmTable.new(name, instance, schema)
|
46
51
|
instance.tables[name] = ret
|
47
52
|
return ret
|
48
53
|
end
|
49
54
|
|
55
|
+
def add_rows(collection, tab)
|
56
|
+
collection.each do |row|
|
57
|
+
if collection.class == Hash
|
58
|
+
row = row[1]
|
59
|
+
end
|
60
|
+
newrow = [tab, @bud_instance.budtime, row]
|
61
|
+
@logtab << newrow
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
50
66
|
def do_cards
|
51
67
|
return if @bud_instance.class == Stratification or @bud_instance.class == DepAnalysis
|
52
68
|
@bud_instance.tables.each do |t|
|
53
69
|
tab = t[0]
|
54
|
-
next if tab
|
70
|
+
next if tab == "the_big_log"
|
55
71
|
next if @meta_tables[tab.to_s] and @bud_instance.budtime > 0
|
56
|
-
|
57
|
-
t[1].
|
58
|
-
|
59
|
-
row.each{ |r| newrow << r }
|
60
|
-
@logtab[tab] << newrow
|
72
|
+
add_rows(t[1], tab) unless t[1].class == Bud::BudPeriodic
|
73
|
+
if t[1].class == Bud::BudChannel
|
74
|
+
add_rows(t[1].pending, "#{tab}_snd")
|
61
75
|
end
|
62
|
-
@logtab
|
76
|
+
@logtab.tick
|
63
77
|
end
|
64
78
|
end
|
65
79
|
end
|
data/lib/bud/viz_util.rb
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bud/graphs'
|
3
|
+
|
4
|
+
module TraceCardinality
|
5
|
+
state do
|
6
|
+
table :full_info, [:bud_time, :table, :row]
|
7
|
+
scratch :cardinalities, [:bud_time, :table] => [:cnt]
|
8
|
+
scratch :times, [:bud_time]
|
9
|
+
end
|
10
|
+
|
11
|
+
bloom do
|
12
|
+
cardinalities <= full_info.group([full_info.bud_time, full_info.table], count)
|
13
|
+
times <= full_info {|f| [f.bud_time]}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module VizUtil #:nodoc: all
|
18
|
+
def graph_from_instance(bud_instance, viz_name, output_base, collapse=true, fmt=nil)
|
19
|
+
tabinf = {}
|
20
|
+
bud_instance.tables.each do |t|
|
21
|
+
tab = t[0].to_s
|
22
|
+
tabinf[tab] = t[1].class.to_s
|
23
|
+
end
|
24
|
+
write_graphs(tabinf, bud_instance.t_cycle, bud_instance.t_depends, bud_instance.t_rules, viz_name, output_base, fmt, collapse, bud_instance.meta_parser.depanalysis)
|
25
|
+
end
|
26
|
+
|
27
|
+
def write_graphs(tabinf, cycle, depends, rules, viz_name, output_base, fmt, collapse, depanalysis=nil, budtime=-1, card_info=nil)
|
28
|
+
staging = "#{viz_name}.staging"
|
29
|
+
gv = GraphGen.new(tabinf, cycle, staging, budtime, collapse, card_info)
|
30
|
+
gv.process(depends)
|
31
|
+
dump(rules, output_base, gv)
|
32
|
+
gv.finish(depanalysis, fmt)
|
33
|
+
inject_js(staging, "#{viz_name}.svg")
|
34
|
+
File.delete(staging)
|
35
|
+
end
|
36
|
+
|
37
|
+
def inject_js(input, fname)
|
38
|
+
fin = File.open(input, "r")
|
39
|
+
fout = File.open(fname, "w")
|
40
|
+
while line = fin.gets
|
41
|
+
fout.puts line.gsub("<title>G</title>", svg_javascript)
|
42
|
+
end
|
43
|
+
fin.close
|
44
|
+
fout.close
|
45
|
+
end
|
46
|
+
|
47
|
+
def dump(shredded_rules, output_base, gv_obj)
|
48
|
+
return if shredded_rules.nil?
|
49
|
+
|
50
|
+
fout = File.new("#{output_base}/style.css", "w")
|
51
|
+
fout.puts css
|
52
|
+
fout.close
|
53
|
+
code = {}
|
54
|
+
rules = {}
|
55
|
+
convertor = Syntax::Convertors::HTML.for_syntax "ruby"
|
56
|
+
shredded_rules.each do |s|
|
57
|
+
fout = File.new("#{output_base}/#{s[0]}.html", "w+")
|
58
|
+
fout.puts header
|
59
|
+
fout.puts "<h1>Rule #{s[0]}</h1><br>"
|
60
|
+
|
61
|
+
c = convertor.convert(s[4])
|
62
|
+
c.sub!(/^<pre>/, "<pre class=\"code\" style='font-size:20px'>\n")
|
63
|
+
fout.puts c
|
64
|
+
rules[s[0]] = [s[1], s[4]]
|
65
|
+
fout.close
|
66
|
+
end
|
67
|
+
|
68
|
+
rules.each_pair do |k, v|
|
69
|
+
if !code[v[0]]
|
70
|
+
code[v[0]] = ""
|
71
|
+
end
|
72
|
+
#code[v[0]] = "<br># RULE #{k}<br> " + code[v[0]] + "<br>" + v[1]
|
73
|
+
code[v[0]] = "\n# RULE #{k}\n " + code[v[0]] + "\n" + v[1]
|
74
|
+
end
|
75
|
+
gv_obj.nodes.each_pair do |k, v|
|
76
|
+
fout = File.new("#{output_base}/#{k}.html", "w+")
|
77
|
+
fout.puts header
|
78
|
+
k.split(", ").each do |i|
|
79
|
+
unless code[i].nil?
|
80
|
+
c = convertor.convert(code[i])
|
81
|
+
c.sub!(/^<pre>/, "<pre class=\"code\">\n")
|
82
|
+
fout.puts c
|
83
|
+
end
|
84
|
+
end
|
85
|
+
fout.puts("</body></html>")
|
86
|
+
fout.close
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def header
|
91
|
+
return "<html><meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>\n<head><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" /></head><body>"
|
92
|
+
end
|
93
|
+
|
94
|
+
def css
|
95
|
+
return <<END_CSS
|
96
|
+
pre.code {
|
97
|
+
padding: 1ex 1ex 1ex 1ex;
|
98
|
+
border: 4px groove #CC0000;
|
99
|
+
overflow-x: auto;
|
100
|
+
}
|
101
|
+
|
102
|
+
pre.code span.attribute { color: #009900; }
|
103
|
+
pre.code span.char { color: #F00; }
|
104
|
+
pre.code span.class { color: #A020F0; font-weight: bold; }
|
105
|
+
pre.code span.comment { color: #0000FF; }
|
106
|
+
pre.code span.constant { color: #008B8B; }
|
107
|
+
pre.code span.escape { color: #6A5ACD; }
|
108
|
+
pre.code span.expr { color: #2222CC; }
|
109
|
+
pre.code span.global { color: #11AA44; }
|
110
|
+
pre.code span.ident { color: #000000; }
|
111
|
+
pre.code span.keyword { color: #A52A2A; font-weight: bold; }
|
112
|
+
pre.code span.method { color: #008B8B; }
|
113
|
+
pre.code span.module { color: #A020F0; font-weight: bold; }
|
114
|
+
pre.code span.number { color: #DD00DD; }
|
115
|
+
pre.code span.punct { color: #6A5ACD; }
|
116
|
+
pre.code span.regex { color: #DD00DD; }
|
117
|
+
pre.code span.string { color: #DD00DD; }
|
118
|
+
pre.code span.symbol { color: #008B8B; }
|
119
|
+
END_CSS
|
120
|
+
end
|
121
|
+
|
122
|
+
def svg_javascript
|
123
|
+
return <<END_JS
|
124
|
+
<script type='text/javascript'>
|
125
|
+
<![CDATA[
|
126
|
+
|
127
|
+
var windows = new Array()
|
128
|
+
var info = new Array()
|
129
|
+
|
130
|
+
function openWin(target, time) {
|
131
|
+
win = window.open(target + \"_\" + time + \".html\", target, \"location=no,width=400,height=180,left=0,status=no\");
|
132
|
+
// hm, an associative array, how strange.
|
133
|
+
info[target] = 1
|
134
|
+
}
|
135
|
+
|
136
|
+
function advanceTo(time) {
|
137
|
+
arr = gup(\"wins\").split(\",\");
|
138
|
+
for (i=0; i < arr.length; i++) {
|
139
|
+
if (arr[i] != \"\") {
|
140
|
+
openWin(arr[i], time);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
str = '';
|
144
|
+
// getting 'key_cols'
|
145
|
+
for (var i in info) {
|
146
|
+
str = str + ',' + i;
|
147
|
+
}
|
148
|
+
self.window.location.href = 'tm_' + time + '.svg?wins=' + str;
|
149
|
+
}
|
150
|
+
|
151
|
+
// off the netz
|
152
|
+
function gup(name) {
|
153
|
+
name = name.replace(/[\[]/,\"\\\[\").replace(/[\]]/,\"\\\]\");
|
154
|
+
var regexS = \"[\\?&]\"+name+\"=([^&#]*)\";
|
155
|
+
var regex = new RegExp(regexS);
|
156
|
+
var results = regex.exec(window.location.href);
|
157
|
+
if (results == null)
|
158
|
+
return \"\";
|
159
|
+
else
|
160
|
+
return results[1];
|
161
|
+
}
|
162
|
+
|
163
|
+
]]>
|
164
|
+
</script>
|
165
|
+
END_JS
|
166
|
+
end
|
167
|
+
|
168
|
+
def get_meta2(dir)
|
169
|
+
meta_tabs = {"t_table_info" => :tabinf, "t_table_schema" => :tabscm, "t_cycle" => :cycle, "t_depends" => :depends, "t_rules" => :rules}
|
170
|
+
meta = {}
|
171
|
+
data = []
|
172
|
+
ret = DBM.open("#{dir}/the_big_log.dbm")
|
173
|
+
ret.each_pair do |k, v|
|
174
|
+
key = MessagePack.unpack(k)
|
175
|
+
tab = key.shift
|
176
|
+
time = key.shift
|
177
|
+
# paa
|
178
|
+
tup = key[0]
|
179
|
+
MessagePack.unpack(v).each {|val| tup << val}
|
180
|
+
if meta_tabs[tab]
|
181
|
+
raise "non-zero budtime. sure this is metadata?" if time != 0 and strict
|
182
|
+
meta[meta_tabs[tab]] ||= []
|
183
|
+
meta[meta_tabs[tab]] << tup
|
184
|
+
#ret << tup
|
185
|
+
else
|
186
|
+
data << [time, tab, tup]
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
meta_tabs.each_value do |tab|
|
191
|
+
meta[tab] ||= []
|
192
|
+
end
|
193
|
+
|
194
|
+
meta[:schminf] = {}
|
195
|
+
meta[:tabscm].each do |ts|
|
196
|
+
tab = ts[0].to_s
|
197
|
+
unless meta[:schminf][tab]
|
198
|
+
meta[:schminf][tab] = []
|
199
|
+
end
|
200
|
+
meta[:schminf][tab][ts[2]] = ts[1]
|
201
|
+
end
|
202
|
+
return meta, data
|
203
|
+
end
|
204
|
+
end
|