[erlang-bugs] gb_trees:from_orddict loses data?

Jimmy Ruska <>
Fri Aug 10 19:17:25 CEST 2012

I was benchmarking different things and I came across this weird behavior.

1> gb_trees:lookup(6619,gb_trees:from_orddict([ {N,N} || N <- [6619,1]])).

2> gb_trees:lookup(6619,gb_trees:from_orddict([ {N,N} || N <- [1,6619,2]])).

3> gb_trees:from_orddict([ {N,N} || N <- [6619,1]]).

It's supposed to be {Size, {Key, Val, Smaller, Bigger}} but the value
that's bigger is in the smaller part. It's still in there but it doesn't
find it.

If I insert manually it's no problem. The Tree is structured differently.

4> gb_trees:lookup(6619,lists:foldl(fun(N,T) -> gb_trees:enter(N,N,T)

5> lists:foldr(fun(N,T) -> gb_trees:enter(N,N,T)

The number 6619 has no relevance, switch in any number.

6> gb_trees:lookup(2,gb_trees:from_orddict([{2, 2}, {1, 1}])).

It also doesn't matter how many elements are in the list.

- Jimmy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20120810/e386c2e2/attachment.html>

More information about the erlang-bugs mailing list