并发数据访问,如Haxl和缝合 [英] Concurrent data access as in Haxl and Stitch

查看:218
本文介绍了并发数据访问,如Haxl和缝合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我之前问题的后续行动。



我从 Haxl 针迹,他们使用monad用于数据访问。 monad实际上是一个的数据访问命令。子节点是节点所依赖的命令。同时执行同级。



业务逻辑创建monad,然后单独的函数 fetch 解释它。 / p>

现在,问题:假设我同时执行几个数据访问操作。我可以使用一个应用函数(而不是monad),它只是一个命令列表()(不是树)。



感觉?如果列表包含重复命令,该怎么办?

解决方案

c> Fetch 值避免重复相同查询的可能性,即使在同一轮查询中(当他们是兄弟时)。如果你看看论文,图4解释了 dataFetch 的实现,它是 Fetch 值的构造函数。它有三种可能性:


  1. 请求从未在
  2. 之前发出


  3. b

    在最后一种情况下,您会注意到返回的值具有 BlockedRequest 的空序列,因为在这种情况下一些其他 / code> fetch有它。这样,当使用此值调用 ap 函数时,它不会连接相同的重复请求。



    BTW我一直在尝试在Scala中实现Haxl 这里


    This is a follow-up to my previous question.

    As I understand from Haxl and Stitch they use a monad for data access. The monad is actually a tree of data access commands. The children are the commands the node depends on. The siblings are executed concurrently.

    The business logic creates the monad and then a separate function fetch interprets it.

    Now, the question: Suppose I am performing a few data access operations concurrently. I can use an applicative functor (not a monad), which is just a list of commands (not a tree).

    Does it make sense ? What if the list contains duplicate commands ?

    解决方案

    I think by construction of the Fetch values the possibility of repeating the same query is avoided, even in the same round of queries (when they are "siblings" as you say). If you look at the paper, the figure 4 explains the implementation of dataFetch, which is the constructor of Fetch values. It accounts for three possibilities:

    1. The request has never been made before
    2. The request has been made before AND it has been completed
    3. The request has been made before but it has not been completed yet

    In the last case you will notice that the value returned has an empty sequence of BlockedRequests, because in this case some other Blocked fetch has it. This way, when the ap function is called with this value it won't concatenate the same repeated request.

    BTW I have been trying to implement Haxl in Scala here.

    这篇关于并发数据访问,如Haxl和缝合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆