require 'rubygems' require 'bud' class AtomicBatchWrites include Bud state do table :write, [:wid] => [:batch, :name, :val] table :write_log, [:wid] => [:batch, :name, :val, :prev_wid] table :commit, [:batch] table :dom, [:wid] scratch :live, write_log.schema scratch :write_commit_event, write.schema end bloom do write_commit_event <= (write * commit).lefts(:batch => :batch).notin(write_log, 0 => :wid) write_log <+ (write_commit_event * live).outer(:name => :name){|e, l| e + [l.wid.nil? ? 0 : l.wid]} dom <= write_log {|l| [l.prev_wid]} live <= write_log.notin(dom, :wid => :wid) end end