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/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, "Bad inbound message of class #{obj.class}: #{obj.inspect}"
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, "Unknown synchronous storage engine #{storage.to_s}"
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, "Unknown async storage engine #{storage.to_s}"
73
+ raise BudError, "unknown async storage engine #{storage.to_s}"
74
74
  end
75
75
  end
76
76
 
@@ -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, "Failed to open dbm database '#{db_fname}': #{@dbm.errmsg}"
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[schema.index(c)] = v_ary[i]
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[schema.index(c)]}
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[schema.index(c)]}
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, "Failed to open TokyoCabinet DB '#{db_fname}': #{@hdb.errmsg}"
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[schema.index(c)] = v_ary[i]
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[schema.index(c)]}
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[schema.index(c)]}
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, "Illegal use of <+ with zookeeper store '#{@tabname}' on left"
167
+ raise BudError, "illegal use of <+ with zookeeper store '#{@tabname}' on left"
168
168
  end
169
169
 
170
170
  def <=(o)
171
- raise BudError, "Illegal use of <= with zookeeper store '#{@tabname}' on left"
171
+ raise BudError, "illegal use of <= with zookeeper store '#{@tabname}' on left"
172
172
  end
173
173
 
174
174
  def <<(o)
175
- raise BudError, "Illegal use of << with zookeeper store '#{@tabname}' on left"
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
- table :stratum_base, [:predicate, :stratum]
15
- table :stratum, [:predicate, :stratum]
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
@@ -40,7 +40,7 @@ class VizOnline #:nodoc: all
40
40
  lt = "#{t[0]}_vizlog".to_sym
41
41
  if t[2] == "Bud::BudChannel"
42
42
  lts = "#{snd_alias}_vizlog".to_sym
43
- @table_info << [snd_alias, t[2]]
43
+ @table_info << [snd_alias, t[2]]
44
44
  end
45
45
  @table_info << [t[0], t[2]]
46
46
  end
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, @dir, nil, false, nil, time.bud_time, card_info)
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.t_cycle, bud_instance.t_depends, bud_instance.t_rules, viz_name, output_base, fmt, collapse, bud_instance.meta_parser.depanalysis)
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, output_base, fmt, collapse, depanalysis=nil, budtime=-1, card_info=nil)
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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
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-06-01 00:00:00 Z
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: 3
185
+ hash: 25
186
186
  segments:
187
- - 0
188
- version: "0"
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