gpt4 book ai didi

select - Erlang Mnesia 是否在 ordered_set 上选择以 Erlang Term 顺序给出列表?

转载 作者:行者123 更新时间:2023-12-04 03:39:01 25 4
gpt4 key购买 nike

在文档中,我不清楚我是否需​​要按 next 或 foldl 的顺序进行迭代(有人提到 foldr 的顺序与 ordered_set 相反,因此推测 foldl 的顺序相同)或如果我可以使用 select 并依赖它被订购(假设 ordered_set 表)

最佳答案

can I use select and rely upon it being ordered (assuming ordered_set table)

ets:select/2 :

For tables of type ordered_set, objects are visited in the same order as in a first/next traversal. This means that the matchspecification is executed against objects with keys in the first/nextorder and the corresponding result list is in the order of thatexecution.

ets:first/1 :

Returns the first key Key in table Tab. For an ordered_set table, thefirst key in Erlang term order is returned.

Table Traversal :

Traversals using match and select functions may not need to scanthe entire table depending on how the key is specified. A matchpattern with a fully bound key (without any match variables) willoptimize the operation to a single key lookup without any tabletraversal at all. For ordered_set a partially bound key will limit thetraversal to only scan a subset of the table based on term order.

ordered_set 类型的表以随机顺序返回搜索结果对我来说毫无意义。

关于select - Erlang Mnesia 是否在 ordered_set 上选择以 Erlang Term 顺序给出列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66387373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com