Sha256: c437eb309ee7213f9089722e2df28a992f6bcda020c5ba3449c40f0096698d62

Contents?: true

Size: 774 Bytes

Versions: 2

Compression:

Stored size: 774 Bytes

Contents

#!/usr/bin/ruby -I../src

require 'bdb1'
module ZeroC
  def bdb1_fetch_value(a)
    a.sub(/\0$/, '')
  end
  def bdb1_store_value(a)
    a + "\0"
  end
  alias bdb1_fetch_key bdb1_fetch_value
  alias bdb1_store_key bdb1_store_value
end

module BDB1
  class A < Btree
    include ZeroC
  end
end

$option = {"set_pagesize" => 1024, "set_cachesize" => 32 * 1024}

db = BDB1::A.open "basic", "w", $option
File.foreach("wordtest") do |line|
  line.chomp!
  db[line] = line.reverse
end
db.each do |k, v|
  if k != v.reverse || /\0/ =~ k || /\0/ =~ v
    print "ERROR : #{k.inspect} -- #{v.inspect}\n"
  end
end
db.close

db = BDB1::Btree.open "basic", $option
db.each do |k, v|
  if k[-1].to_i != 0 || v[-1].to_i != 0
    print "ERROR : #{k.inspect} -- #{v.inspect}\n"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bdb1-0.2.5 examples/zeroc.rb
bdb1-0.2.4 examples/zeroc.rb