/var/log/messages

Jul 8, 2018 - 2 minute read - Comments - recommendation

Tinkerpop Gremlin Aggregate

以下のドキュメント確認しつつ機械翻訳なナニを作成したので控えを。

The aggregate()-step (sideEffect) is used to aggregate all the objects at a particular point of traversal into a Collection. The step uses eager evaluation in that no objects continue on until all previous objects have been fully aggregated (as opposed to store()which lazily fills a collection). The eager evaluation nature is crucial in situations where everything at a particular point is required for future computation. An example is provided below.

aggregate() - step(sideEffect) は、特定のトラバーサルポイントにあるすべてのオブジェクトをCollectionに集約するために使用されます。 このステップでは、すべての以前のオブジェクトが完全に集約されるまでオブジェクトが継続しないという熱心な評価が使用されます(store() とは対照的に、コレクションを遅延して埋め込みます)。 熱心な評価の性質は、特定のポイントのすべてが将来の計算に必要とされる状況では重要です。 以下に例を示します。

    gremlin> g.V(1).out('created') //1\
    ==>v[3]
    gremlin> g.V(1).out('created').aggregate('x') //2\
    ==>v[3]
    gremlin> g.V(1).out('created').aggregate('x').in('created') //3\
    ==>v[1]
    ==>v[4]
    ==>v[6]
    gremlin> g.V(1).out('created').aggregate('x').in('created').out('created') //4\
    ==>v[3]
    ==>v[5]
    ==>v[3]
    ==>v[3]
    gremlin> g.V(1).out('created').aggregate('x').in('created').out('created').
                    where(without('x')).values('name') //5\
    ==>ripple
  1. What has marko created?
  2. Aggregate all his creations.
  3. Who are marko’s collaborators?
  4. What have marko’s collaborators created?
  5. What have marko’s collaborators created that he hasn’t created?

In recommendation systems, the above pattern is used:

“What has userA liked? Who else has liked those things? What have they liked that userA hasn’t already liked?”

「ユーザーAが好きなのは誰ですか?それ以外のユーザーは誰ですか?ユーザーAはまだ好きではないと思ったことは何ですか?」

Finally, aggregate()-step can be modulated via by()-projection.

最後に、aggregate() - stepはby() - 投影によって調整することができます。

    gremlin> g.V().out('knows').aggregate('x').cap('x')
    ==>[v[2],v[4]]
    gremlin> g.V().out('knows').aggregate('x').by('name').cap('x')
    ==>[vadas,josh]

Your Account Has Been Flagged Recommendation

comments powered by Disqus