Skip to content

Hashed

Name - Description Default Type
<input> The value passed to the first shard in the hashed sequence. Any
<output> The hash of the output of the last shard in the hashed sequence. Any
Shards The shards to execute in the hashed flow. None Shard[Shard]

Hashes the output of a shard or of a sequence of shards.

Details

(Hashed) takes a single shard or a sequence of shards and hashes the output of the last shard (or the only shard) in this sequence. So this shard can be used to group together certain shards when you want their final output to be hashed.

(Hashed) uses (->) to group multiple shards. The input to (Hashed) becomes input to the first shard in the hashed sequence and the output of this shard becomes the input for the next shard in the hashed sequence (following the regular Shards data flow pattern).

Note

(Hashed) has an alias (|#) which is more convenient to use. |# also removes the need to use (->) as, unlike (Hashed), it doesn't require the parameter shards to be grouped together.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
;; Hashed sequence of shards (using keyword `Hashed`)
(int 5)
(Log "input to Hashed shards sequence") ;; => 5
(Hashed
  (->
    (Math.Multiply 2)                   ;; shard1
    (Log "output from shard1")          ;; => 10
    (Math.Multiply 2)                   ;; shard2
    (Log "output from shard2")          ;; => 20
    (Math.Multiply 2)                   ;; shard3
    (Log "output from shard3")          ;; => 40
    ))
(Log "last shard output, hashed")       ;; => {Hash: (1005568994776713365, 558560013916990142), Result: 40}
[info] [shards/General/Hashed/1.edn] input to Hashed shards sequence: 5
[info] [shards/General/Hashed/1.edn] output from shard1: 10
[info] [shards/General/Hashed/1.edn] output from shard2: 20
[info] [shards/General/Hashed/1.edn] output from shard3: 40
[info] [shards/General/Hashed/1.edn] last shard output, hashed: {Hash: (-7797085721143305500 -2376950229069188278) Result: 40}

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
;; Hashed sequence of shards (using alias `|#`)
(int 5)
(Log "input to Hashed shards sequence") ;; => 5
(|#
   (Math.Multiply 2)                   ;; shard1
   (Log "output from shard1")          ;; => 10
   (Math.Multiply 2)                   ;; shard2
   (Log "output from shard2")          ;; => 20
   (Math.Multiply 2)                   ;; shard3
   (Log "output from shard3")          ;; => 40
   )
(Log "last shard output, hashed")       ;; => {Hash: (1005568994776713365, 558560013916990142), Result: 40}
[info] [shards/General/Hashed/2.edn] input to Hashed shards sequence: 5
[info] [shards/General/Hashed/2.edn] output from shard1: 10
[info] [shards/General/Hashed/2.edn] output from shard2: 20
[info] [shards/General/Hashed/2.edn] output from shard3: 40
[info] [shards/General/Hashed/2.edn] last shard output, hashed: {Hash: (-7797085721143305500 -2376950229069188278) Result: 40}