Skip to content
Browse files

make dbm the default store for visualization

  • Loading branch information...
1 parent 56adcb1 commit 7387e12e98944185459ed4abfcc6f482b3ec3948 @jhellerstein jhellerstein committed Apr 13, 2011
Showing with 39 additions and 29 deletions.
  1. +8 −10 bin/budvis
  2. +0 −1 bud.gemspec
  3. +7 −0 docs/cheat.md
  4. +1 −2 docs/getstarted.md
  5. +7 −7 docs/visualizations.md
  6. +1 −1 lib/bud/storage/dbm.rb
  7. +13 −5 test/tc_wc.rb
  8. +2 −3 test/ts_bud.rb
View
18 bin/budvis
@@ -1,11 +1,10 @@
#!/usr/bin/env ruby
require 'rubygems'
-require 'tokyocabinet'
+require 'dbm'
require 'bud'
require 'bud/graphs'
-include TokyoCabinet
-BUD_TC_DIR = "#{ARGV[0]}/bud_"
+BUD_DBM_DIR = "#{ARGV[0]}/bud_"
class VizHelper
include Bud
@@ -123,9 +122,9 @@ end
def usage
puts "Usage:"
- puts "Running a Bud program with option :trace => true will cause a TC directory TC_dir to be created (Class_ObjectId_Port)"
- puts "> budvis TC_dir"
- puts "This will create a series of svg files in TC_dir, the root of which will be named tm_0_expanded.svg. Open in a browser.\n"
+ puts "Running a Bud program with option :trace => true will cause a DBM directory DVM_dir to be created (Class_ObjectId_Port)"
+ puts "> budvis DBM_dir"
+ puts "This will create a series of svg files in DBM_dir, the root of which will be named tm_0_expanded.svg. Open in a browser.\n"
puts "e.g."
puts "> ruby test/tc_carts.rb"
puts "> budvis BCS_2159661360_"
@@ -137,13 +136,12 @@ usage unless ARGV[0]
@tables = {}
-Dir.new(BUD_TC_DIR).entries.each do |file|
+Dir.new(BUD_DBM_DIR).entries.each do |file|
next if file =~ /^\./
puts "FILE is #{file}"
- hdb = TokyoCabinet::HDB.new
- ret = hdb.open("#{BUD_TC_DIR}/#{file}", HDB::OREADER)
+ ret = DBM.open("#{BUD_DBM_DIR}/#{file}", DBM::O_RDONLY)
raise "db not found" unless ret
- @tables[file] = hdb
+ @tables[file] = ret
end
# let's try to do a visualization
View
1 bud.gemspec
@@ -29,7 +29,6 @@ Gem::Specification.new do |s|
s.add_dependency 'sexp_path'
s.add_dependency 'superators'
s.add_dependency 'syntax'
- s.add_dependency 'tokyocabinet'
s.add_dependency 'uuid'
# Optional dependencies -- if we can't find these libraries, certain features
View
7 docs/cheat.md
@@ -81,6 +81,13 @@ System-provided attributes: `[:line] => []`
Statements with stdio on lhs must use async merge (`<~`).<br>
To capture `$stdin` on rhs, instantiate Bud with `:read_stdin` option.<br>
+### dbm_table ###
+Table collection mapped to a [DBM] (http://en.wikipedia.org/wiki/Dbm) store.<br>
+Default attributes: `[:key] => [:val]`
+
+ dbm_table :t1
+ dbm_table :t2, [:k1, :k2] => [:v1, :v2]
+
### tctable ###
Table collection mapped to a [Tokyo Cabinet](http://fallabs.com/tokyocabinet/) store.<br>
Default attributes: `[:key] => [:val]`
View
3 docs/getstarted.md
@@ -2,9 +2,8 @@
In this document we'll do a hands-on tour of Bud and its Bloom DSL for Ruby. We'll start with some examples, and introduce concepts as we go.
## Installation ##
-Bud depends on two libraries that need to be installed separately:
+Bud depends on one library that needs to be installed separately:
-* [TokyoCabinet](http://fallabs.com/tokyocabinet/) (1.4.47 recommended)
* [GraphViz](http://www.graphviz.org/Download.php) (2.26.3 recommended)
Once that's done, you know the drill!
View
14 docs/visualizations.md
@@ -54,7 +54,7 @@ dataflow.
To enable tracing, we need to set `:trace => true` in the `Bud` constructor, and
optionally provide a `:tag` to differentiate between traces by a human-readable
-name (rather than by `object_id`). I modified the unit test `test/tc_kvs.rb` as
+name (rather than by `object_id`). I modified the unit test `test/DBM_kvs.rb` as
follows:
- v = BestEffortReplicatedKVS.new(@opts.merge(:port => 12345))
@@ -69,19 +69,19 @@ Then I ran the unit test:
$ ruby test/tc_kvs.rb
Loaded suite test/tc_kvs
Started
- .Created directory: TC_BestEffortReplicatedKVS_dist_primary_2160259460_
- Created directory: TC_BestEffortReplicatedKVS_dist_primary_2160259460_/bud_
- Created directory: TC_BestEffortReplicatedKVS_dist_backup_2159579740_
- Created directory: TC_BestEffortReplicatedKVS_dist_backup_2159579740_/bud_
+ .Created directory: DBM_BestEffortReplicatedKVS_dist_primary_2160259460_
+ Created directory: DBM_BestEffortReplicatedKVS_dist_primary_2160259460_/bud_
+ Created directory: DBM_BestEffortReplicatedKVS_dist_backup_2159579740_
+ Created directory: DBM_BestEffortReplicatedKVS_dist_backup_2159579740_/bud_
..
Finished in 4.366793 seconds.
3 tests, 14 assertions, 0 failures, 0 errors
Then I ran the visualization utility:
- $ budvis TC_BestEffortReplicatedKVS_dist_primary_2160259460_/
+ $ budvis DBM_BestEffortReplicatedKVS_dist_primary_2160259460_/
And finally opened the (chronological) first output file:
- $ open -a /Applications/Google\ Chrome.app/ TC_BestEffortReplicatedKVS_dist_primary_2160259460_/tm_0_expanded.svg
+ $ open -a /Applications/Google\ Chrome.app/ DBM_BestEffortReplicatedKVS_dist_primary_2160259460_/tm_0_expanded.svg
View
2 lib/bud/storage/dbm.rb
@@ -1,7 +1,7 @@
require 'dbm'
module Bud
- # Persistent table implementation based on TokyoCabinet.
+ # Persistent table implementation based on ndbm.
class BudDbmTable < BudCollection # :nodoc: all
def initialize(name, bud_instance, given_schema)
dbm_dir = bud_instance.options[:dbm_dir]
View
18 test/tc_wc.rb
@@ -13,8 +13,8 @@ def initialize(pattern)
end
state do
- file_reader :txt, 'text/ulysses.txt'
- # file_reader :txt, 'shaks12.txt'
+ # file_reader :txt, 'text/ulysses.txt'
+ file_reader :txt, 'shaks12.txt'
@neilconway
Bloom Language Development member
neilconway added a note Apr 13, 2011

shaks12.txt is not checked into Git.

@jhellerstein
Bloom Language Development member
jhellerstein added a note Apr 13, 2011

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
scratch :wc, [:word] => [:cnt]
end
@@ -27,8 +27,12 @@ def initialize(pattern)
class TestWC1 < Test::Unit::TestCase
def test_wc1
+ @t = 0
+ @u = 0
program = WordCount1.new(/[Bb]loom/)
- assert_nothing_raised { program.tick }
+ assert_nothing_raised { @t = Time.now ; program.tick; @u = Time.now }
+ puts "wc1: #{(@u-@t).to_f}"
+ require 'ruby-debug'; debugger
assert_equal(23, program.wc[["yes"]].cnt)
end
end
@@ -45,7 +49,8 @@ def initialize(pattern)
end
state do
- file_reader :txt, 'text/ulysses.txt'
+ # file_reader :txt, 'text/ulysses.txt'
+ file_reader :txt, 'shaks12.txt'
scratch :words, [:lineno, :wordno] => [:word]
scratch :wc, [:word] => [:cnt]
end
@@ -64,8 +69,11 @@ def initialize(pattern)
class TestWC2 < Test::Unit::TestCase
def test_wc2
+ @t = 0
+ @u = 0
program = WordCount2.new(/[Bb]loom/)
- assert_nothing_raised { program.tick }
+ assert_nothing_raised { @t = Time.now ; program.tick; @u = Time.now }
+ puts "wc2: #{(@u-@t).to_f}"
assert_equal(23, program.wc[["yes"]].cnt)
end
end
View
5 test/ts_bud.rb
@@ -6,6 +6,7 @@
require 'tc_channel'
require 'tc_collections'
require 'tc_coverage'
+require 'tc_dbm'
require 'tc_delta'
require 'tc_errors'
require 'tc_exists'
@@ -21,9 +22,7 @@
require 'tc_rebl'
require 'tc_schemafree'
require 'tc_semistructured'
-require 'tc_tc'
require 'tc_temp'
require 'tc_terminal'
require 'tc_timer'
-require 'tc_wc1'
-require 'tc_wc2'
+require 'tc_wc'

0 comments on commit 7387e12

Please sign in to comment.
Something went wrong with that request. Please try again.