Add ordered_set conversion
Can we go from an ets table to a skiplist
This commit is contained in:
parent
34a25bdb88
commit
bbdb35ae03
1 changed files with 17 additions and 1 deletions
|
@ -20,6 +20,8 @@
|
||||||
from_list/2,
|
from_list/2,
|
||||||
from_sortedlist/1,
|
from_sortedlist/1,
|
||||||
from_sortedlist/2,
|
from_sortedlist/2,
|
||||||
|
from_orderedset/1,
|
||||||
|
from_orderedset/2,
|
||||||
to_list/1,
|
to_list/1,
|
||||||
enter/3,
|
enter/3,
|
||||||
enter/4,
|
enter/4,
|
||||||
|
@ -71,6 +73,12 @@ enter_nolookup(Key, Value, SkipList) ->
|
||||||
element(2, SkipList),
|
element(2, SkipList),
|
||||||
?SKIP_WIDTH, ?LIST_HEIGHT)}.
|
?SKIP_WIDTH, ?LIST_HEIGHT)}.
|
||||||
|
|
||||||
|
from_orderedset(Table) ->
|
||||||
|
from_orderedset(Table, false).
|
||||||
|
|
||||||
|
from_orderedset(Table, Bloom) ->
|
||||||
|
from_sortedlist(ets:tab2list(Table), Bloom).
|
||||||
|
|
||||||
from_list(UnsortedKVL) ->
|
from_list(UnsortedKVL) ->
|
||||||
from_list(UnsortedKVL, false).
|
from_list(UnsortedKVL, false).
|
||||||
|
|
||||||
|
@ -406,6 +414,14 @@ skiplist_tester(Bloom) ->
|
||||||
N = 4000,
|
N = 4000,
|
||||||
KL = generate_randomkeys(1, N, 1, N div 5),
|
KL = generate_randomkeys(1, N, 1, N div 5),
|
||||||
|
|
||||||
|
OS = ets:new(test, [ordered_set, private]),
|
||||||
|
ets:insert(OS, KL),
|
||||||
|
SWaETS = os:timestamp(),
|
||||||
|
SkipList = from_orderedset(OS, Bloom),
|
||||||
|
io:format(user, "Generating skip list with ~w keys in ~w microseconds " ++
|
||||||
|
"from ordered set~n",
|
||||||
|
[N, timer:now_diff(os:timestamp(), SWaETS)]),
|
||||||
|
|
||||||
SWaGSL = os:timestamp(),
|
SWaGSL = os:timestamp(),
|
||||||
SkipList = from_list(lists:reverse(KL), Bloom),
|
SkipList = from_list(lists:reverse(KL), Bloom),
|
||||||
io:format(user, "Generating skip list with ~w keys in ~w microseconds~n" ++
|
io:format(user, "Generating skip list with ~w keys in ~w microseconds~n" ++
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue