Skip to content

Commit

Permalink
renamed SimpleSkiplist to Skiplist
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Andreev committed Jun 8, 2008
1 parent ff4c04e commit 9785ab9
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion lib/strokedb/data_structures.rb
@@ -1 +1 @@
require 'data_structures/simple_skiplist'
require 'data_structures/skiplist'
Expand Up @@ -2,7 +2,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../util/class_optimization')

module StrokeDB
class SimpleSkiplist
class Skiplist
include Enumerable

DEFAULT_MAXLEVEL = 32
Expand Down
2 changes: 1 addition & 1 deletion lib/strokedb/stores/memory_storage.rb
Expand Up @@ -58,7 +58,7 @@ def perform_save!(document, timestamp, options = {})
end

def clear!
@container = SimpleSkiplist.new
@container = Skiplist.new
end

def close!
Expand Down
4 changes: 2 additions & 2 deletions lib/strokedb/views/memory_view_storage.rb
Expand Up @@ -2,11 +2,11 @@ module StrokeDB
class MemoryViewStorage < ViewStorage

def initialize(options = {})
@list = SimpleSkiplist.new
@list = Skiplist.new
end

def clear!
@list = SimpleSkiplist.new
@list = Skiplist.new
end

end
Expand Down
4 changes: 2 additions & 2 deletions lib/strokedb/volumes/skiplist_volume.rb
Expand Up @@ -85,10 +85,10 @@ def error(*args); end
end

if File.exists?(@list_path)
@list = SimpleSkiplist.load(File.read(@list_path))
@list = Skiplist.load(File.read(@list_path))
else
info "List file (#{@list_path}) was not found, creating a brand new skiplist."
@list = SimpleSkiplist.new(@params)
@list = Skiplist.new(@params)
end

if File.exists?(@log_path)
Expand Down
2 changes: 1 addition & 1 deletion meta/benchmarks/archive_volume.rb
Expand Up @@ -7,7 +7,7 @@

@path = File.dirname(__FILE__) + "/../../spec/temp/storages/archive_volume"

SimpleSkiplist.optimize!(:C)
Skiplist.optimize!(:C)

[2000].each do |n|

Expand Down
2 changes: 1 addition & 1 deletion meta/benchmarks/big_database.rb
Expand Up @@ -23,7 +23,7 @@
#
# end

SimpleSkiplist.optimize!(:C)
Skiplist.optimize!(:C)

# FileUtils.rm_rf "../../spec/temp/storages/bigstore"
# StrokeDB::Config.build :default => true, :base_path => "../../spec/temp/storages/bigstore"
Expand Down
36 changes: 18 additions & 18 deletions meta/benchmarks/simple_skiplist.rb
Expand Up @@ -7,44 +7,44 @@

len = 2_000
array = (1..len).map{ [rand(len).to_s]*2 }
biglist = SimpleSkiplist.from_a(array)
biglist = Skiplist.from_a(array)
dumped = biglist.marshal_dump

Benchmark.bm(17) do |x|
# First technique: to_a/from_a
GC.start
x.report("SimpleSkiplist#to_a ") do
x.report("Skiplist#to_a ") do
biglist.to_a
biglist.to_a
biglist.to_a
biglist.to_a
biglist.to_a
end
GC.start
x.report("SimpleSkiplist.from_a ") do
SimpleSkiplist.from_a(array)
SimpleSkiplist.from_a(array)
SimpleSkiplist.from_a(array)
SimpleSkiplist.from_a(array)
SimpleSkiplist.from_a(array)
x.report("Skiplist.from_a ") do
Skiplist.from_a(array)
Skiplist.from_a(array)
Skiplist.from_a(array)
Skiplist.from_a(array)
Skiplist.from_a(array)
end

# Another technique: Marshal.dump
GC.start
x.report("SimpleSkiplist#marshal_dump ") do
x.report("Skiplist#marshal_dump ") do
biglist.marshal_dump
biglist.marshal_dump
biglist.marshal_dump
biglist.marshal_dump
biglist.marshal_dump
end
GC.start
x.report("SimpleSkiplist#marshal_load ") do
SimpleSkiplist.allocate.marshal_load(dumped.dup)
SimpleSkiplist.allocate.marshal_load(dumped.dup)
SimpleSkiplist.allocate.marshal_load(dumped.dup)
SimpleSkiplist.allocate.marshal_load(dumped.dup)
SimpleSkiplist.allocate.marshal_load(dumped.dup)
x.report("Skiplist#marshal_load ") do
Skiplist.allocate.marshal_load(dumped.dup)
Skiplist.allocate.marshal_load(dumped.dup)
Skiplist.allocate.marshal_load(dumped.dup)
Skiplist.allocate.marshal_load(dumped.dup)
Skiplist.allocate.marshal_load(dumped.dup)
end
end

Expand All @@ -53,9 +53,9 @@
Benchmark.bm(42) do |x|
langs = [:C] if RUBY_PLATFORM !~ /java/
langs = [:Java] if RUBY_PLATFORM =~ /java/
SimpleSkiplist.with_optimizations(langs) do |lang|
Skiplist.with_optimizations(langs) do |lang|
GC.start
x.report("SimpleSkiplist#find 5000 #{lang}".ljust(32)) do
x.report("Skiplist#find 5000 #{lang}".ljust(32)) do
1000.times do
key = rand(len).to_s
biglist.find(key)
Expand All @@ -66,7 +66,7 @@
end
end
GC.start
x.report("SimpleSkiplist#insert 5000 #{lang}".ljust(32)) do
x.report("Skiplist#insert 5000 #{lang}".ljust(32)) do
1000.times do
key = rand(len).to_s
biglist.insert(key, key)
Expand Down
2 changes: 1 addition & 1 deletion meta/benchmarks/skiplist_volume.rb
Expand Up @@ -38,7 +38,7 @@ def benchmark!(lang)

benchmark!("Ruby")

SimpleSkiplist.optimize!(:C)
Skiplist.optimize!(:C)

benchmark!("C")

Expand Up @@ -18,14 +18,14 @@
end
end

SimpleSkiplist.with_optimizations(OPTIMIZATIONS) do |lang|
Skiplist.with_optimizations(OPTIMIZATIONS) do |lang|

describe "Empty SimpleSkiplist [#{lang}]" do
describe "Empty Skiplist [#{lang}]" do

before(:each) do
@maxlevel = 8
@probability = 0.5
@list = SimpleSkiplist.new(:maxlevel => @maxlevel, :probability => @probability)
@list = Skiplist.new(:maxlevel => @maxlevel, :probability => @probability)
end

it "should be empty" do
Expand All @@ -46,7 +46,7 @@
before(:each) do
@maxlevel = 8
@probability = 0.5
@list = SimpleSkiplist.new(:maxlevel => @maxlevel, :probability => @probability)
@list = Skiplist.new(:maxlevel => @maxlevel, :probability => @probability)
end

it "should insert empty key in place of default head" do
Expand Down Expand Up @@ -100,7 +100,7 @@

describe "Deleting from skiplist" do
before(:each) do
@list = SimpleSkiplist.new
@list = Skiplist.new
@list.insert "1a", "a"
@list.insert "1b", "b"
@list.insert "1c", "c"
Expand All @@ -121,7 +121,7 @@
before(:each) do
@maxlevel = 8
@probability = 0.5
@list = SimpleSkiplist.new(:maxlevel => @maxlevel, :probability => @probability)
@list = Skiplist.new(:maxlevel => @maxlevel, :probability => @probability)
1000.times do
k = rand(2**64).to_s
v = k
Expand Down Expand Up @@ -151,10 +151,10 @@

end

describe "SimpleSkiplist serialization [#{lang}]" do
describe "Skiplist serialization [#{lang}]" do
before(:each) do
@maxlevel = 8
@list = SimpleSkiplist.new(:maxlevel => @maxlevel)
@list = Skiplist.new(:maxlevel => @maxlevel)
@arr = (1..1000).to_a.map{|a| a.to_s}.sort
end
it "should export data to_a correctly" do
Expand All @@ -167,11 +167,11 @@
end
end

describe "SimpleSkiplist#first_key [#{lang}]" do
describe "Skiplist#first_key [#{lang}]" do
before(:each) do
@maxlevel = 8
@probability = 0.5
@list = SimpleSkiplist.new(:maxlevel => @maxlevel, :probability => @probability)
@list = Skiplist.new(:maxlevel => @maxlevel, :probability => @probability)
end
it "should return nil for empty skiplist" do
@list.first_key.should == nil
Expand All @@ -185,11 +185,11 @@
end


describe "SimpleSkiplist#find_nearest [#{lang}]" do
describe "Skiplist#find_nearest [#{lang}]" do
before(:each) do
@maxlevel = 8
@probability = 0.5
@list = SimpleSkiplist.new(:maxlevel => @maxlevel, :probability => @probability)
@list = Skiplist.new(:maxlevel => @maxlevel, :probability => @probability)
end
it "should find nil in empty skiplist" do
@list.find_nearest("a").should == nil
Expand Down Expand Up @@ -219,9 +219,9 @@
end
end

describe "SimpleSkiplist#search [#{lang}]" do
describe "Skiplist#search [#{lang}]" do
before(:each) do
@list = SimpleSkiplist.new
@list = Skiplist.new
@keys = %w[ a aa ab b ba bb pfx1 pfx2 pfx3 x xx xy xyz ]
@values = @keys.map{|v| v + " value"}
@key_values = @keys.map{|v| [v, v]}
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/strokedb/volumes/skiplist_volume_spec.rb
Expand Up @@ -14,7 +14,7 @@
end
end

#SimpleSkiplist.with_optimizations(OPTIMIZATIONS) do |lang|
#Skiplist.with_optimizations(OPTIMIZATIONS) do |lang|
lang = "Ruby {FIXME: with_optimizations is irreversible operation for now}"
describe "Brand new SkiplistVolume [#{lang}]" do
before(:each) do
Expand Down

0 comments on commit 9785ab9

Please sign in to comment.