1/* 2 * Copyright 2019-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// This file contains messages for representing the internal state and common 17// properties of aggregation algorithms, in a minimized and Lite Proto version 18// for Android. 19// 20// Messages defined in this file are often stored on disk, so reader libraries 21// should be able to parse all historic versions of the serialized data, and to 22// merge data with different serialization formats. 23 24syntax = "proto2"; 25 26package zetasketch.android; 27 28option cc_enable_arenas = true; 29option optimize_for = LITE_RUNTIME; 30 31// Enumeration of all supported aggregation algorithms. Values should 32// start from 100. 33enum AggregatorType { 34 reserved 0, 100 to 112, 114 to 140; 35 36 // Computes approximate quantiles using the KLL algorithm. 37 KLL_QUANTILES = 113; 38} 39 40// Never instantiated, just for scoping an enum and associated options. 41message DefaultOpsType { 42 // Each value corresponds to a C++ type T. 43 enum Id { 44 UNKNOWN = 0; 45 46 // SerializeToString uses varint encoding of the 2s complement. 47 INT64 = 4; 48 49 reserved 1 to 3, 5 to 20; 50 } 51} 52 53// Serialized state of an aggregator. 54message AggregatorStateProto { 55 // The type (= algorithm + implementation) of the aggregator. 56 optional AggregatorType type = 1; 57 58 optional int64 num_values = 2; 59 60 // Version of the encoded internal state. On a per-aggregator basis, this 61 // field is set to indicate that the format of the aggregator encoding has 62 // changed such that the library has to decide how to decode. 63 optional int32 encoding_version = 3 [default = 1]; 64 65 // Specifies the value type for the aggregation, e.g. INT64. 66 // 67 // For anything which is not a custom type, this will be a value of the 68 // DefaultOpsType.Id enum. 69 optional int32 value_type = 4; 70 71 // An AggregatorStateProto message object has exactly one extension field set, 72 // which holds the algorithm-specific state for the aggregator. 73 74 extensions 100 to 112, 114 to 140; 75 76 extensions 113 to 113; // reserved for KLL_QUANTILES. 77}