• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright 2021 Google LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// Serialized state and result stats of the KLL quantiles aggregator. Mimimized
18// Lite Proto version for Android.
19
20syntax = "proto2";
21
22package zetasketch.android;
23
24import "aggregator.proto";
25
26option optimize_for = LITE_RUNTIME;
27
28// State proto: 'Sketch' of aggregation from which results can be extracted or
29// which can be re-aggregated/merged with other sketches.
30message KllQuantilesStateProto {
31    message Compactor {
32        // Used for values which cannot be serialized in a packed format.
33        message NonPackableValues {
34            // Each value is encoded as one field.
35            repeated bytes values = 1;
36        }
37
38        oneof compactor_values {
39            // Used for values for which can be serialized in a packed format and
40            // which are not difference encoded (see below). All values are stored in
41            // one field in a packed representation.
42            bytes packed_values = 1;
43
44            // Optionally used for values of integral types stored in a packed
45            // 'difference' encoding (also called 'delta' or 'incremental' encoding):
46            // The values are sorted by their natural order before encoding, and
47            // instead of the n values, the smallest value and the n-1 deltas to the
48            // next higher values are stored as (packed) varints.
49            bytes diff_encoded_packed_values = 2;
50
51            // Used for all other types.
52            NonPackableValues other_values = 3;
53        }
54    }
55
56    message Sampler {
57        optional bytes sampled_item = 1;
58        // How many stream items the sampled item stands for.
59        optional int64 sampled_weight = 2;
60        // Binary logarithm of the sampler capacity (out of how many items are we
61        // sampling one).
62        optional int32 log_capacity = 3;
63    }
64
65    // Size of the top-most compactor.
66    optional int32 k = 1;
67    // Inverse of the approximation precision parameter epsilon.
68    optional int64 inv_eps = 2;
69    // items type is stored in AggregatorStateProto.value_type.
70    // num_items is stored in AggregatorStateProto.num_values.
71
72    // (Exact) minimum value of the input data.
73    optional bytes min = 3;
74    // (Exact) maximum value of the input data.
75    optional bytes max = 4;
76
77    // Stack of compactors, starting with the lowest level (weight 1, closest to
78    // stream).  Weights associated with each compactor are stored implicitly
79    // through the order of compactors: compactor i has weight 2^i (with
80    // zero-based indexing).
81    repeated Compactor compactors = 5;
82    optional Sampler sampler = 6;
83}
84
85extend zetasketch.android.AggregatorStateProto {
86    // This field id should match AggregatorType.KLL_QUANTILES.
87    optional KllQuantilesStateProto kll_quantiles_state = 113;
88}
89