Skip to content
This repository
Browse code

make dbm the default store for visualization

  • Loading branch information...
commit 7387e12e98944185459ed4abfcc6f482b3ec3948 1 parent 56adcb1
Joe Hellerstein jhellerstein authored
18 bin/budvis
... ... @@ -1,11 +1,10 @@
1 1 #!/usr/bin/env ruby
2 2 require 'rubygems'
3   -require 'tokyocabinet'
  3 +require 'dbm'
4 4 require 'bud'
5 5 require 'bud/graphs'
6   -include TokyoCabinet
7 6
8   -BUD_TC_DIR = "#{ARGV[0]}/bud_"
  7 +BUD_DBM_DIR = "#{ARGV[0]}/bud_"
9 8
10 9 class VizHelper
11 10 include Bud
@@ -123,9 +122,9 @@ end
123 122
124 123 def usage
125 124 puts "Usage:"
126   - puts "Running a Bud program with option :trace => true will cause a TC directory TC_dir to be created (Class_ObjectId_Port)"
127   - puts "> budvis TC_dir"
128   - 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"
  125 + puts "Running a Bud program with option :trace => true will cause a DBM directory DVM_dir to be created (Class_ObjectId_Port)"
  126 + puts "> budvis DBM_dir"
  127 + 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"
129 128 puts "e.g."
130 129 puts "> ruby test/tc_carts.rb"
131 130 puts "> budvis BCS_2159661360_"
@@ -137,13 +136,12 @@ usage unless ARGV[0]
137 136
138 137 @tables = {}
139 138
140   -Dir.new(BUD_TC_DIR).entries.each do |file|
  139 +Dir.new(BUD_DBM_DIR).entries.each do |file|
141 140 next if file =~ /^\./
142 141 puts "FILE is #{file}"
143   - hdb = TokyoCabinet::HDB.new
144   - ret = hdb.open("#{BUD_TC_DIR}/#{file}", HDB::OREADER)
  142 + ret = DBM.open("#{BUD_DBM_DIR}/#{file}", DBM::O_RDONLY)
145 143 raise "db not found" unless ret
146   - @tables[file] = hdb
  144 + @tables[file] = ret
147 145 end
148 146
149 147 # let's try to do a visualization
1  bud.gemspec
@@ -29,7 +29,6 @@ Gem::Specification.new do |s|
29 29 s.add_dependency 'sexp_path'
30 30 s.add_dependency 'superators'
31 31 s.add_dependency 'syntax'
32   - s.add_dependency 'tokyocabinet'
33 32 s.add_dependency 'uuid'
34 33
35 34 # Optional dependencies -- if we can't find these libraries, certain features
7 docs/cheat.md
Source Rendered
@@ -81,6 +81,13 @@ System-provided attributes: `[:line] => []`
81 81 Statements with stdio on lhs must use async merge (`<~`).<br>
82 82 To capture `$stdin` on rhs, instantiate Bud with `:read_stdin` option.<br>
83 83
  84 +### dbm_table ###
  85 +Table collection mapped to a [DBM] (http://en.wikipedia.org/wiki/Dbm) store.<br>
  86 +Default attributes: `[:key] => [:val]`
  87 +
  88 + dbm_table :t1
  89 + dbm_table :t2, [:k1, :k2] => [:v1, :v2]
  90 +
84 91 ### tctable ###
85 92 Table collection mapped to a [Tokyo Cabinet](http://fallabs.com/tokyocabinet/) store.<br>
86 93 Default attributes: `[:key] => [:val]`
3  docs/getstarted.md
Source Rendered
@@ -2,9 +2,8 @@
2 2 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.
3 3
4 4 ## Installation ##
5   -Bud depends on two libraries that need to be installed separately:
  5 +Bud depends on one library that needs to be installed separately:
6 6
7   -* [TokyoCabinet](http://fallabs.com/tokyocabinet/) (1.4.47 recommended)
8 7 * [GraphViz](http://www.graphviz.org/Download.php) (2.26.3 recommended)
9 8
10 9 Once that's done, you know the drill!
14 docs/visualizations.md
Source Rendered
@@ -54,7 +54,7 @@ dataflow.
54 54
55 55 To enable tracing, we need to set `:trace => true` in the `Bud` constructor, and
56 56 optionally provide a `:tag` to differentiate between traces by a human-readable
57   -name (rather than by `object_id`). I modified the unit test `test/tc_kvs.rb` as
  57 +name (rather than by `object_id`). I modified the unit test `test/DBM_kvs.rb` as
58 58 follows:
59 59
60 60 - v = BestEffortReplicatedKVS.new(@opts.merge(:port => 12345))
@@ -69,10 +69,10 @@ Then I ran the unit test:
69 69 $ ruby test/tc_kvs.rb
70 70 Loaded suite test/tc_kvs
71 71 Started
72   - .Created directory: TC_BestEffortReplicatedKVS_dist_primary_2160259460_
73   - Created directory: TC_BestEffortReplicatedKVS_dist_primary_2160259460_/bud_
74   - Created directory: TC_BestEffortReplicatedKVS_dist_backup_2159579740_
75   - Created directory: TC_BestEffortReplicatedKVS_dist_backup_2159579740_/bud_
  72 + .Created directory: DBM_BestEffortReplicatedKVS_dist_primary_2160259460_
  73 + Created directory: DBM_BestEffortReplicatedKVS_dist_primary_2160259460_/bud_
  74 + Created directory: DBM_BestEffortReplicatedKVS_dist_backup_2159579740_
  75 + Created directory: DBM_BestEffortReplicatedKVS_dist_backup_2159579740_/bud_
76 76 ..
77 77 Finished in 4.366793 seconds.
78 78
@@ -80,8 +80,8 @@ Then I ran the unit test:
80 80
81 81 Then I ran the visualization utility:
82 82
83   - $ budvis TC_BestEffortReplicatedKVS_dist_primary_2160259460_/
  83 + $ budvis DBM_BestEffortReplicatedKVS_dist_primary_2160259460_/
84 84
85 85 And finally opened the (chronological) first output file:
86 86
87   - $ open -a /Applications/Google\ Chrome.app/ TC_BestEffortReplicatedKVS_dist_primary_2160259460_/tm_0_expanded.svg
  87 + $ open -a /Applications/Google\ Chrome.app/ DBM_BestEffortReplicatedKVS_dist_primary_2160259460_/tm_0_expanded.svg
2  lib/bud/storage/dbm.rb
... ... @@ -1,7 +1,7 @@
1 1 require 'dbm'
2 2
3 3 module Bud
4   - # Persistent table implementation based on TokyoCabinet.
  4 + # Persistent table implementation based on ndbm.
5 5 class BudDbmTable < BudCollection # :nodoc: all
6 6 def initialize(name, bud_instance, given_schema)
7 7 dbm_dir = bud_instance.options[:dbm_dir]
18 test/tc_wc.rb
@@ -13,8 +13,8 @@ def initialize(pattern)
13 13 end
14 14
15 15 state do
16   - file_reader :txt, 'text/ulysses.txt'
17   - # file_reader :txt, 'shaks12.txt'
  16 + # file_reader :txt, 'text/ulysses.txt'
  17 + file_reader :txt, 'shaks12.txt'
18 18 scratch :wc, [:word] => [:cnt]
19 19 end
20 20
@@ -27,8 +27,12 @@ def initialize(pattern)
27 27
28 28 class TestWC1 < Test::Unit::TestCase
29 29 def test_wc1
  30 + @t = 0
  31 + @u = 0
30 32 program = WordCount1.new(/[Bb]loom/)
31   - assert_nothing_raised { program.tick }
  33 + assert_nothing_raised { @t = Time.now ; program.tick; @u = Time.now }
  34 + puts "wc1: #{(@u-@t).to_f}"
  35 + require 'ruby-debug'; debugger
32 36 assert_equal(23, program.wc[["yes"]].cnt)
33 37 end
34 38 end
@@ -45,7 +49,8 @@ def initialize(pattern)
45 49 end
46 50
47 51 state do
48   - file_reader :txt, 'text/ulysses.txt'
  52 + # file_reader :txt, 'text/ulysses.txt'
  53 + file_reader :txt, 'shaks12.txt'
49 54 scratch :words, [:lineno, :wordno] => [:word]
50 55 scratch :wc, [:word] => [:cnt]
51 56 end
@@ -64,8 +69,11 @@ def initialize(pattern)
64 69
65 70 class TestWC2 < Test::Unit::TestCase
66 71 def test_wc2
  72 + @t = 0
  73 + @u = 0
67 74 program = WordCount2.new(/[Bb]loom/)
68   - assert_nothing_raised { program.tick }
  75 + assert_nothing_raised { @t = Time.now ; program.tick; @u = Time.now }
  76 + puts "wc2: #{(@u-@t).to_f}"
69 77 assert_equal(23, program.wc[["yes"]].cnt)
70 78 end
71 79 end
5 test/ts_bud.rb
@@ -6,6 +6,7 @@
6 6 require 'tc_channel'
7 7 require 'tc_collections'
8 8 require 'tc_coverage'
  9 +require 'tc_dbm'
9 10 require 'tc_delta'
10 11 require 'tc_errors'
11 12 require 'tc_exists'
@@ -21,9 +22,7 @@
21 22 require 'tc_rebl'
22 23 require 'tc_schemafree'
23 24 require 'tc_semistructured'
24   -require 'tc_tc'
25 25 require 'tc_temp'
26 26 require 'tc_terminal'
27 27 require 'tc_timer'
28   -require 'tc_wc1'
29   -require 'tc_wc2'
  28 +require 'tc_wc'

0 comments on commit 7387e12

Neil Conway

shaks12.txt is not checked into Git.

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