Erlang 17 recommend to use map replace record,but

2019-04-11 05:02发布

问题:

In joe's "Big changes to Erlang" http://joearms.github.io/2014/02/01/big-changes-to-erlang.html

"we wanted maps to be a replacement for records and to be as efficient as records, and its not blindingly obvious how to do so."

How to make transform records to maps in mnesia?

回答1:

Mnesia uses ETS (and dets) internally and these are based on tuples as the base data structure. While they can contain maps at the top-level it must be tuples. As records are tuples records can also be at the top-level. Redesigning ets/dets/mnesia to use maps would be a major effort.

As maps access is done dynamically while records statically it is probably not possible to get maps as fast as records.



标签: map erlang