xref: /spdk/include/spdk/zipf.h (revision a6dbe3721eb3b5990707fc3e378c95e505dd8ab5)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright (C) 2021 Intel Corporation.
3  *   All rights reserved.
4  */
5 
6 /** \file
7  * Zipf random number distribution
8  */
9 
10 #ifndef SPDK_ZIPF_H
11 #define SPDK_ZIPF_H
12 
13 #include "spdk/stdinc.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 struct spdk_zipf;
20 
21 /**
22  * Create a zipf random number generator.
23  *
24  * Numbers from [0, range) will be returned by the generator when
25  * calling \ref spdk_zipf_generate.
26  *
27  * \param range Range of values for the zipf distribution.
28  * \param theta Theta distribution parameter.
29  * \param seed Seed value for the random number generator.
30  *
31  * \return a pointer to the new zipf generator.
32  */
33 struct spdk_zipf *spdk_zipf_create(uint64_t range, double theta, uint32_t seed);
34 
35 /**
36  * Free a zipf generator and set the pointer to NULL.
37  *
38  * \param zipfp Zipf generator to free.
39  */
40 void spdk_zipf_free(struct spdk_zipf **zipfp);
41 
42 /**
43  * Generate a value from the zipf generator.
44  *
45  * \param zipf Zipf generator to generate the value from.
46  *
47  * \return value in the range [0, range)
48  */
49 uint64_t spdk_zipf_generate(struct spdk_zipf *zipf);
50 
51 #ifdef __cplusplus
52 }
53 #endif
54 
55 #endif
56