Skip to content

Commit a9b4275

Browse files
committed
doc: add comments about utf8 compatibility for quantiels sketches
1 parent 14c20a6 commit a9b4275

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

kll/include/kll_sketch.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ namespace kll_constants {
4646
* and nearly optimal accuracy per retained item.
4747
* See <a href="https://arxiv.org/abs/1603.05346v2">Optimal Quantile Approximation in Streams</a>.
4848
*
49+
* Sketch that may retain string values.
50+
* For sketches containing strings, cross-language portability depends on
51+
* using compatible string encodings. This class does not by itself enforce
52+
* UTF-8 validity for all string inputs.
53+
*
4954
* <p>This is a stochastic streaming sketch that enables near real-time analysis of the
5055
* approximate distribution of items from a very large stream in a single pass, requiring only
5156
* that the items are comparable.
@@ -56,7 +61,7 @@ namespace kll_constants {
5661
* <p>As of May 2020, this implementation produces serialized sketches which are binary-compatible
5762
* with the equivalent Java implementation only when template parameter T = float
5863
* (32-bit single precision values).
59-
*
64+
*
6065
* <p>Given an input stream of <i>N</i> items, the <i>natural rank</i> of any specific
6166
* item is defined as its index <i>(1 to N)</i> in inclusive mode
6267
* or <i>(0 to N-1)</i> in exclusive mode
@@ -225,13 +230,17 @@ class kll_sketch {
225230

226231
/**
227232
* Updates this sketch with the given data item.
233+
* If cross-language portability is required, callers should ensure that
234+
* the input string uses a compatible encoding (valid UTF-8).
228235
* @param item from a stream of items
229236
*/
230237
template<typename FwdT>
231238
void update(FwdT&& item);
232239

233240
/**
234241
* Merges another sketch into this one.
242+
* If sketches contain strings, callers are responsible for ensuring that
243+
* both sketches were built using compatible string encodings.
235244
* @param other sketch to merge into this one
236245
*/
237246
template<typename FwdSk>

quantiles/include/quantiles_sketch.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ namespace quantiles_constants {
4747
* The analysis is obtained using get_rank() and get_quantile() functions,
4848
* the Probability Mass Function from get_PMF() and the Cumulative Distribution Function from get_CDF().
4949
*
50+
* Sketch that may retain string values.
51+
* For sketches containing strings, cross-language portability depends on
52+
* using compatible string encodings. This class does not by itself enforce
53+
* UTF-8 validity for all string inputs.
54+
*
5055
* <p>Consider a large stream of one million values such as packet sizes coming into a network node.
5156
* The natural rank of any specific size value is its index in the hypothetical sorted
5257
* array of values.
@@ -206,13 +211,17 @@ class quantiles_sketch {
206211

207212
/**
208213
* Updates this sketch with the given data item.
214+
* If cross-language portability is required, callers should ensure that
215+
* the input string uses a compatible encoding (valid UTF-8).
209216
* @param item from a stream of items
210217
*/
211218
template<typename FwdT>
212219
void update(FwdT&& item);
213220

214221
/**
215222
* Merges another sketch into this one.
223+
* If sketches contain strings, callers are responsible for ensuring that
224+
* both sketches were built using compatible string encodings.
216225
* @param other sketch to merge into this one
217226
*/
218227
template<typename FwdSk>

req/include/req_sketch.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ namespace datasketches {
3535
* "Relative Error Streaming Quantiles" by Graham Cormode, Zohar Karnin, Edo Liberty,
3636
* Justin Thaler, Pavel Veselý, and loosely derived from a Python prototype written by Pavel Veselý.
3737
*
38+
* Sketch that may retain string values.
39+
* For sketches containing strings, cross-language portability depends on
40+
* using compatible string encodings. This class does not by itself enforce
41+
* UTF-8 validity for all string inputs.
42+
*
3843
* <p>Reference: https://arxiv.org/abs/2004.01668</p>
3944
*
4045
* <p>This implementation differs from the algorithm described in the paper in the following:</p>
@@ -179,13 +184,17 @@ class req_sketch {
179184

180185
/**
181186
* Updates this sketch with the given data item.
187+
* If cross-language portability is required, callers should ensure that
188+
* the input string uses a compatible encoding (valid UTF-8).
182189
* @param item from a stream of items
183190
*/
184191
template<typename FwdT>
185192
void update(FwdT&& item);
186193

187194
/**
188195
* Merges another sketch into this one.
196+
* If sketches contain strings, callers are responsible for ensuring that
197+
* both sketches were built using compatible string encodings.
189198
* @param other sketch to merge into this one
190199
*/
191200
template<typename FwdSk>

0 commit comments

Comments
 (0)