Parallel data access, both in Haxl and Stitch

This is a continuation of my previous question .

As I understand it from Haxl and Stitch, they use a monad to access data. The monad is actually a tree of data access commands. Children are the teams that node depends on. Siblings are executed simultaneously.

Business logic creates a monad, and then a separate fetch function interprets it.

Now the question is: suppose I perform several data access operations at the same time. I can use an applicative functor (not a monad), which is a list of commands (not a tree).

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

+4
source share
1 answer

I think that when building Fetch values, you can repeat the possibility of repeating the same query even in the same round of queries (when they are β€œbrothers and sisters,” as you say). If you look at the paper, Figure 4 explains the implementation of dataFetch , which is the constructor for Fetch values. It takes into account three possibilities:

  • The request has never been made before.
  • The request was completed before. And it was completed.
  • The request was completed earlier, but it has not yet been completed.

In the latter case, you will notice that the returned value has an empty sequence of BlockedRequest s, because in this case there is another Blocked selection. That way, when the ap function is called with this value, it will not concatenate the same repeat request.

BTW I'm trying to implement Haxl in Scala here .

+2
source

Source: https://habr.com/ru/post/1210215/


All Articles