Permalink
Browse files

renamed SimpleSkiplist to Skiplist

  • Loading branch information...
1 parent ff4c04e commit 9785ab9c6245d9c23e95a0a1f04bb8c300984323 Oleg Andreev committed Jun 8, 2008
@@ -1 +1 @@
-require 'data_structures/simple_skiplist'
+require 'data_structures/skiplist'
@@ -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
@@ -58,7 +58,7 @@ def perform_save!(document, timestamp, options = {})
end
def clear!
- @container = SimpleSkiplist.new
+ @container = Skiplist.new
end
def close!
@@ -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
@@ -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)
@@ -7,7 +7,7 @@
@path = File.dirname(__FILE__) + "/../../spec/temp/storages/archive_volume"
-SimpleSkiplist.optimize!(:C)
+Skiplist.optimize!(:C)
[2000].each do |n|
@@ -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"
@@ -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
@@ -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)
@@ -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)
@@ -38,7 +38,7 @@ def benchmark!(lang)
benchmark!("Ruby")
-SimpleSkiplist.optimize!(:C)
+Skiplist.optimize!(:C)
benchmark!("C")
@@ -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
@@ -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
@@ -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"
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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]}
@@ -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

0 comments on commit 9785ab9

Please sign in to comment.