[erlang-questions] ets:next/2 behavior - set vs. ordered_set

Joseph Wayne Norton <>
Mon Sep 12 17:46:24 CEST 2011


I'm currently developing a disk based clone of the ets application.   During testing with QuickCheck and Proper, I stumbled upon a difference between set and ordered_set for the real ets:next/2 operation.

The last command exits with badarg rather than '$end_of_table' as I would expect.

Can someone comment on this behavior?  Is this a bug?  Is this a documentation bug?

thanks,



18> ets:new(ordered_set,[ordered_set,public,named_table,{keypos,2}]).
ordered_set
19> ets:first(ordered_set).
'$end_of_table'
20> ets:next(ordered_set,0).
'$end_of_table'
21> 

21> ets:new(set,[set,public,named_table,{keypos,2}]).
set
22> ets:first(set).
'$end_of_table'
23> ets:next(set,0).
** exception error: bad argument
     in function  ets:next/2
        called as ets:next(set,0)
24> 




$ erl -v
Erlang R14B03 (erts-5.8.4) [source] [64-bit] [rq:1] [async-threads:0] [kernel-poll:false]

Eshell V5.8.4  (abort with ^G)



       next(Tab, Key1) -> Key2 | '$end_of_table'

              Types  Tab = tid() | atom()
                     Key1 = Key2 = term()

              Returns the next key Key2 , following the key Key1 in the table Tab . If the table is of
              the ordered_set type, the next key in Erlang term order is returned. If the table is  of
              any  other  type,  the  next key according to the table's internal order is returned. If
              there is no next key, '$end_of_table' is returned.



Joseph Wayne Norton







More information about the erlang-questions mailing list