Eshell V6.1 (abort with ^G)
1> Filename = "./test.data".
"./test.data"
2> Tab = ets:new(testets, [named_table, orderd_set]).
** exception error: bad argument
in function ets:new/2
called as ets:new(testets,[named_table,orderd_set])
3> Tab = ets:new(testets, [named_table, ordered_set]).
testets
4> [ets:insert(Tab, {N, erlang:now()})|| N <-lists:seq(1,10)].
[true,true,true,true,true,true,true,true,true,true]
5> ets:tab2file(Tab,Filename,[{extended_info,[md5sum]}]).
ok
6> ets:file2tab(Filename).
{error,cannot_create_table}
7> ets:file2tab(Filename).
{error,cannot_create_table}
8> ets:first(testets).
1
9> ets:foldl(fun({Key,Value}, Acc) -> Acc + Key end, 0, Tab).
55
10> ets:fun2ms(fun({K,V}) when K >5 -> V end).
[{{'$1','$2'},[{'>','$1',5}],['$2']}]
11> M = ets:fun2ms(fun({K,V}) when K >5 -> V end).
[{{'$1','$2'},[{'>','$1',5}],['$2']}]
12> ets:select(Tab, M).
[{1420,348926,18429},
{1420,348926,18445},
{1420,348926,18470},
{1420,348926,18487},
{1420,348926,18508}]
13> ets:i().
id name type size mem owner
----------------------------------------------------------------------------
13 code set 279 10167 code_server
4110 code_names set 52 6335 code_server
8207 shell_records ordered_set 0 89 <0.27.0>
ac_tab ac_tab set 6 835 application_controller
disk_log_names disk_log_names set 0 299 disk_log_server
disk_log_pids disk_log_pids set 0 299 disk_log_server
file_io_servers file_io_servers set 0 299 file_server_2
global_locks global_locks set 0 299 global_name_server
global_names global_names set 0 299 global_name_server
global_names_ext global_names_ext set 0 299 global_name_server
global_pid_ids global_pid_ids bag 0 299 global_name_server
global_pid_names global_pid_names bag 0 299 global_name_server
inet_cache inet_cache bag 0 299 inet_db
inet_db inet_db set 29 596 inet_db
inet_hosts_byaddr inet_hosts_byaddr bag 0 299 inet_db
inet_hosts_byname inet_hosts_byname bag 0 299 inet_db
inet_hosts_file_byaddr inet_hosts_file_byaddr bag 0 299 inet_db
inet_hosts_file_byname inet_hosts_file_byname bag 0 299 inet_db
testets testets ordered_set 10 209 <0.36.0>
ok
14> ets:i(testets).
<1 > {1,{1420,348926,18324}}
<2 > {2,{1420,348926,18356}}
<3 > {3,{1420,348926,18372}}
<4 > {4,{1420,348926,18388}}
<5 > {5,{1420,348926,18412}}
<6 > {6,{1420,348926,18429}}
<7 > {7,{1420,348926,18445}}
<8 > {8,{1420,348926,18470}}
<9 > {9,{1420,348926,18487}}
<10 > {10,{1420,348926,18508}}
EOT (q)uit (p)Digits (k)ill /Regexp -->
EOT (q)uit (p)Digits (k)ill /Regexp -->q
ok
15> ets:info(testets).
[{compressed,false},
{memory,209},
{owner,<0.36.0>},
{heir,none},
{name,testets},
{size,10},
{node,nonode@nohost},
{named_table,true},
{type,ordered_set},
{keypos,1},
{protection,protected}]
16> ets:info(testets, heir).
none
17> ets:info(testets, nothing).
** exception error: bad argument
in function ets:info/2
called as ets:info(testets,nothing)
18> ets:insert(testets,{a,1}).
** exception error: bad argument
in function ets:insert/2
called as ets:insert(testets,{a,1})
19> ets:info(testets, heir).
undefined
20> 20> ets:new(testets,[set,named_table]).
testets
21> [ets:insert(testets, {N, erlang:now()}) || N <- lists:seq(1,10)].
[true,true,true,true,true,true,true,true,true,true]
22> ets:insert(testets, {a, 11}).
true
23> ets:insert(testets, {b, 21}).
true
24> ets:lookup(testets,b).
[{b,21}]
25> ets:lookup(testets, b, 2).
** exception error: undefined function ets:lookup/3
26> ets:lookup_element(testets, b, 2).
** exception error: bad argument
in function ets:lookup_element/3
called as ets:lookup_element(testets,b,2)
27> ets:new(testets,[set,named_table]).
testets
28> [ets:insert(testets, {N, erlang:now()}) || N <- lists:seq(1,10)].
[true,true,true,true,true,true,true,true,true,true]
29> ets:lookup_element(testets, b, 2).
** exception error: bad argument
in function ets:lookup_element/3
called as ets:lookup_element(testets,b,2)
30> ets:new(testets,[set,named_table]).
testets
31> [ets:insert(testets, {N, erlang:now()}) || N <- lists:seq(1,10)].
[true,true,true,true,true,true,true,true,true,true]
32> ets:lookup_element(testets, 1, 2).
{1420,350648,883014}
转载于:https://www.cnblogs.com/ShankYan/p/4371244.html