Mnesia:总是后缀碎片表碎片?

时间:2017-09-20 10:44:23

标签: erlang mnesia

当我在Mnesia中创建一个碎片表时,除第一个片段的外,所有表碎片都将具有后缀_fragN 。这很容易出错,因为在没有指定正确的访问模块的情况下访问表的任何代码都将出现,因为它会读取和写入第一个片段,但它不会与代码混合使用正确的访问模块,因为他们将在不同的地方寻找元素。

有没有办法告诉Mnesia为所有表格片段使用片段后缀?这可以避免这个问题,因为错误的访问会失败。

例如,如果我创建一个包含四个片段的表:

1> mnesia:start().
ok
2> mnesia:create_table(foo, [{frag_properties, [{node_pool, [node()]}, {n_fragments, 4}]}]). 
{atomic,ok}

然后mnesia:info/0会将片段列为foofoo_frag2foo_frag3foo_frag4

3> mnesia:info().
---> Processes holding locks <--- 
---> Processes waiting for locks <--- 
---> Participant transactions <--- 
---> Coordinator transactions <---
---> Uncertain transactions <--- 
---> Active tables <--- 
foo            : with 0        records occupying 304      words of mem
foo_frag2      : with 0        records occupying 304      words of mem
foo_frag3      : with 0        records occupying 304      words of mem
foo_frag4      : with 0        records occupying 304      words of mem
schema         : with 5        records occupying 950      words of mem
===> System info in version "4.14", debug level = none <===
opt_disc. Directory "/Users/legoscia/Mnesia.nonode@nohost" is NOT used.
use fallback at restart = false
running db nodes   = [nonode@nohost]
stopped db nodes   = [] 
master node tables = []
remote             = []
ram_copies         = [foo,foo_frag2,foo_frag3,foo_frag4,schema]
disc_copies        = []
disc_only_copies   = []
[{nonode@nohost,ram_copies}] = [schema,foo_frag4,foo_frag3,foo_frag2,foo]
3 transactions committed, 0 aborted, 0 restarted, 0 logged to disc
0 held locks, 0 in queue; 0 local transactions, 0 remote
0 transactions waits for other nodes: []

我希望foo代替foo_frag1。这可能吗?

0 个答案:

没有答案