Skip to content

Commit

Permalink
Fix etl partitioning (#4)
Browse files Browse the repository at this point in the history
* Remove unnecessary |hash

* Provide rama topology diagram for the project
  • Loading branch information
skydread1 authored Jul 12, 2024
1 parent 85f5c2e commit a985d54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ This repo aims at providing an implementation of `rama-space` using the Clojure

It provides more tests than the original examples.

To have an overview of the different topologies involved, I made the following diagram:

![Rama Topology Diagram](docs/diagram.png)

The diagram above highlight the `stream`, `microbatch` and `query` topologies involved in the project.

It also shows depot partitioning, ETL partitioning and branching.

## Get clj-kondo congig

```sh
Expand Down
Binary file added docs/diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 4 additions & 8 deletions src/rama_space/module.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns rama-space.module
(:use [com.rpl.rama]
[com.rpl.rama.path])
[com.rpl.rama.path]
[com.rpl.rama.ops])
(:require [com.rpl.rama.path :as path]
[com.rpl.rama.aggs :as aggs]
[com.rpl.rama.ops :as ops]
Expand All @@ -27,7 +28,7 @@
(declare-depot setup *user-registrations-depot (hash-by :user-id))
(declare-depot setup *profile-edits-depot (hash-by :user-id))
(declare-depot setup *friend-requests-depot (hash-by :user-id))
(declare-depot setup *friendship-depot (hash-by :user-id))
(declare-depot setup *friendship-depot (hash-by :user-id-1))
(declare-depot setup *posts-depot (hash-by :to-user-id))
(declare-depot setup *profile-views-depot (hash-by :to-user-id))
;; The .declarePState call declares the PState it uses.
Expand Down Expand Up @@ -72,15 +73,13 @@
(source> *friend-requests-depot :> {:keys [*action *user-id *to-user-id]})
(<<switch *action
(case> :request)
(|hash *user-id)
(+compound $$outgoing-friend-requests
{*user-id (aggs/+set-agg *to-user-id)})
(|hash *to-user-id)
(+compound $$incoming-friend-requests
{*to-user-id (aggs/+set-agg *user-id)})

(case> :cancel)
(|hash *user-id)
(+compound $$outgoing-friend-requests
{*user-id (aggs/+set-remove-agg *to-user-id)})
(|hash *to-user-id)
Expand All @@ -90,7 +89,6 @@
(source> *friendship-depot :> {:keys [*action *user-id-1 *user-id-2]})
(anchor> <change-friendship>) ;; create new branch
;;---------- clear incoming/outgoing friend requests
(|hash *user-id-1)
(+compound $$incoming-friend-requests
{*user-id-1 (aggs/+set-remove-agg *user-id-2)})
(+compound $$outgoing-friend-requests
Expand All @@ -104,15 +102,13 @@
;;---------- add/remove friendships
(<<switch *action
(case> :add)
(|hash *user-id-1)
(+compound $$friends
{*user-id-1 (aggs/+set-agg *user-id-2)})
(|hash *user-id-2)
(+compound $$friends
{*user-id-2 (aggs/+set-agg *user-id-1)})

(case> :remove)
(|hash *user-id-1)
(+compound $$friends
{*user-id-1 (aggs/+set-remove-agg *user-id-2)})
(|hash *user-id-2)
Expand Down Expand Up @@ -153,5 +149,5 @@
:content *content
:display-name *display-name
:profile-pic *profile-pic} :> *resolved-post)
(|origin)
(|origin) ;; partition back to the "origin", which is the initial task ID of the query
(+compound {*post-id (aggs/+last *resolved-post)} :> *result-map))))

0 comments on commit a985d54

Please sign in to comment.