summaryrefslogtreecommitdiffstats
path: root/source/rainerscript/functions/mo-hashXXmod.rst
blob: 8fc1d774533be64ec59c0fcd9e06d539564189a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
*********
HashXXmod
*********

Purpose
=======

Generates a number which is mod of given string's hash.

hash32mod(literal_string, modulo) / hash32mod(literal_string, modulo, seed)
---------------------------------------------------------------------------

   Generates a number which is calculated on (32 bit hash of the given string % modulo)
    - If modulo is not a valid number, then 0 is returned.
    - If modulo is 0, then 0 is returned.
    - Seed is an optional parameter with default = 0.
    - If seed is not a valid unsigned number, then 0 is returned.


hash64mod(literal_string, modulo) / hash64mod(literal_string, modulo, seed)
---------------------------------------------------------------------------

   Generates a number which is calculated on (64 bit hash of the given string % modulo)
    - If modulo is not a valid number, then 0 is returned.
    - If modulo is 0, then 0 is returned.
    - Seed is an optional parameter with default = 0.
    - If seed is not a valid unsigned number, then 0 is returned.


.. warning::

   - Default hash implementation is non-crypto.
   - To use xxhash enable compile time flag.


Example
=======

.. code-block:: none

  module(load="fmhash")

  if (hash64mod($!msg!request_id, 100) <= 30) then {
   //send out
  }

.. seealso::
  :doc:`Hash based sampling<../../tutorials/hash_sampling>`