1// Copyright 2019 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto2"; 16 17package icing.lib; 18 19import "icing/proto/scoring.proto"; 20 21option java_package = "com.google.android.icing.proto"; 22option java_multiple_files = true; 23option objc_class_prefix = "ICNG"; 24 25// Stats of the top-level function IcingSearchEngine::Initialize(). 26// Next tag: 14 27message InitializeStatsProto { 28 // Overall time used for the function call. 29 optional int32 latency_ms = 1; 30 31 // The cause of IcingSearchEngine recovering from a previous bad state during 32 // initialization. 33 enum RecoveryCause { 34 // No recovery happened. 35 NONE = 0; 36 37 // Data loss in ground truth. 38 DATA_LOSS = 1; 39 40 // Data in index is inconsistent with ground truth. 41 INCONSISTENT_WITH_GROUND_TRUTH = 2; 42 43 // Changes were made to the schema, but possibly not fully applied to the 44 // document store and the index - requiring a recovery. 45 SCHEMA_CHANGES_OUT_OF_SYNC = 3; 46 47 // Random I/O errors. 48 IO_ERROR = 4; 49 50 // The document log is using legacy format. 51 LEGACY_DOCUMENT_LOG_FORMAT = 5; 52 53 // The current code version is different from existing data version. 54 VERSION_CHANGED = 6; 55 } 56 57 // Possible recovery causes for document store: 58 // - DATA_LOSS 59 // - SCHEMA_CHANGES_OUT_OF_SYNC 60 // - IO_ERROR 61 optional RecoveryCause document_store_recovery_cause = 2; 62 63 // Possible recovery causes for index: 64 // - INCONSISTENT_WITH_GROUND_TRUTH 65 // - SCHEMA_CHANGES_OUT_OF_SYNC 66 // - IO_ERROR 67 optional RecoveryCause index_restoration_cause = 3; 68 69 // Possible recovery causes for index: 70 // - IO_ERROR 71 optional RecoveryCause schema_store_recovery_cause = 4; 72 73 // Time used to recover the document store. 74 optional int32 document_store_recovery_latency_ms = 5; 75 76 // Time used to restore the index. 77 optional int32 index_restoration_latency_ms = 6; 78 79 // Time used to restore the index. 80 optional int32 schema_store_recovery_latency_ms = 7; 81 82 // Status regarding how much data is lost during the initialization. 83 enum DocumentStoreDataStatus { 84 // Document store is successfully initialized or fully recovered. 85 NO_DATA_LOSS = 0; 86 87 // Ground truth data is partially lost. 88 PARTIAL_LOSS = 1; 89 90 // Ground truth data is completely lost. 91 COMPLETE_LOSS = 2; 92 } 93 optional DocumentStoreDataStatus document_store_data_status = 8; 94 95 // Number of documents currently in document store. Those may 96 // include alive, deleted, and expired documents. 97 optional int32 num_documents = 9; 98 99 // Number of schema types currently in schema store. 100 optional int32 num_schema_types = 10; 101 102 // Number of consecutive initialization failures that immediately preceded 103 // this initialization. 104 optional int32 num_previous_init_failures = 11; 105 106 // Possible recovery causes for integer index: 107 // - INCONSISTENT_WITH_GROUND_TRUTH 108 // - SCHEMA_CHANGES_OUT_OF_SYNC 109 // - IO_ERROR 110 optional RecoveryCause integer_index_restoration_cause = 12; 111 112 // Possible recovery causes for qualified id join index: 113 // - INCONSISTENT_WITH_GROUND_TRUTH 114 // - SCHEMA_CHANGES_OUT_OF_SYNC 115 // - IO_ERROR 116 optional RecoveryCause qualified_id_join_index_restoration_cause = 13; 117} 118 119// Stats of the top-level function IcingSearchEngine::Put(). 120// Next tag: 10 121message PutDocumentStatsProto { 122 // Overall time used for the function call. 123 optional int32 latency_ms = 1; 124 125 // Time used to store the document. 126 optional int32 document_store_latency_ms = 2; 127 128 // Time used to index the document. 129 optional int32 index_latency_ms = 3; 130 131 // Time used to merge the indices. 132 optional int32 index_merge_latency_ms = 4; 133 134 // Document size in bytes. 135 optional int32 document_size = 5; 136 137 message TokenizationStats { 138 // Number of tokens added to the index. 139 optional int32 num_tokens_indexed = 1; 140 141 reserved 2; 142 } 143 optional TokenizationStats tokenization_stats = 6; 144 145 // Time used to index all indexable string terms in the document. It does not 146 // include the time to merge indices. 147 optional int32 term_index_latency_ms = 7; 148 149 // Time used to index all indexable integers in the document. 150 optional int32 integer_index_latency_ms = 8; 151 152 // Time used to index all qualified id join strings in the document. 153 optional int32 qualified_id_join_index_latency_ms = 9; 154} 155 156// Stats of the top-level function IcingSearchEngine::Search() and 157// IcingSearchEngine::GetNextPage(). 158// Next tag: 23 159message QueryStatsProto { 160 // The UTF-8 length of the query string 161 optional int32 query_length = 16; 162 163 // Number of terms in the query string. 164 optional int32 num_terms = 1; 165 166 // Number of namespaces filtered. 167 optional int32 num_namespaces_filtered = 2; 168 169 // Number of schema types filtered. 170 optional int32 num_schema_types_filtered = 3; 171 172 // Strategy of scoring and ranking. 173 optional ScoringSpecProto.RankingStrategy.Code ranking_strategy = 4; 174 175 // Whether the function call is querying the first page. If it’s 176 // not, Icing will fetch the results from cache so that some steps 177 // may be skipped. 178 optional bool is_first_page = 5; 179 180 // The requested number of results in one page. 181 optional int32 requested_page_size = 6; 182 183 // The actual number of results returned in the current page. 184 optional int32 num_results_returned_current_page = 7; 185 186 // Number of documents scored. 187 optional int32 num_documents_scored = 8; 188 189 // How many of the results in the page returned were snippeted. 190 optional int32 num_results_with_snippets = 15; 191 192 // Overall time used for the function call. 193 optional int32 latency_ms = 10; 194 195 // Time used to parse the query, including 2 parts: tokenizing and 196 // transforming tokens into an iterator tree. 197 optional int32 parse_query_latency_ms = 11; 198 199 // Time used to score the raw results. 200 optional int32 scoring_latency_ms = 12; 201 202 // Time used to rank the scored results. 203 optional int32 ranking_latency_ms = 13; 204 205 // Time used to fetch the document protos. Note that it includes the 206 // time to snippet if ‘has_snippets’ is true. 207 optional int32 document_retrieval_latency_ms = 14; 208 209 // Time passed while waiting to acquire the lock before query execution. 210 optional int32 lock_acquisition_latency_ms = 17; 211 212 // Timestamp taken just before sending proto across the JNI boundary from 213 // native to java side. 214 optional int64 native_to_java_start_timestamp_ms = 18; 215 216 // Time used to send protos across the JNI boundary from java to native side. 217 optional int32 java_to_native_jni_latency_ms = 19; 218 219 // Time used to send protos across the JNI boundary from native to java side. 220 optional int32 native_to_java_jni_latency_ms = 20; 221 222 // The native latency due to the join operation. 223 optional int32 join_latency_ms = 21; 224 225 // Number of documents scored. 226 optional int32 num_joined_results_returned_current_page = 22; 227 228 reserved 9; 229} 230 231// Stats of the top-level functions IcingSearchEngine::Delete, 232// IcingSearchEngine::DeleteByNamespace, IcingSearchEngine::DeleteBySchemaType. 233// Next tag: 4 234message DeleteStatsProto { 235 // Overall time used for the function call. 236 optional int32 latency_ms = 1; 237 238 message DeleteType { 239 enum Code { 240 // Default. Should never be used. 241 UNKNOWN = 0; 242 243 // Delete one document. 244 SINGLE = 1; 245 246 // Delete by query. This value is deprecated. 247 // IcingSearchEngine::DeleteByQuery will return a DeleteByQueryStatsProto 248 // rather than a DeleteStatsProto. 249 DEPRECATED_QUERY = 2 [deprecated = true]; 250 251 // Delete by namespace. 252 NAMESPACE = 3; 253 254 // Delete by schema type. 255 SCHEMA_TYPE = 4; 256 } 257 } 258 optional DeleteType.Code delete_type = 2; 259 260 // Number of documents deleted by this call. 261 optional int32 num_documents_deleted = 3; 262} 263 264// Stats of the top-level functions IcingSearchEngine::DeleteByQuery. 265// Next tag: 9 266message DeleteByQueryStatsProto { 267 // Overall time used for the function call. 268 optional int32 latency_ms = 1; 269 270 // Number of documents deleted by this call. 271 optional int32 num_documents_deleted = 2; 272 273 // The UTF-8 length of the query string 274 optional int32 query_length = 3; 275 276 // Number of terms in the query string. 277 optional int32 num_terms = 4; 278 279 // Number of namespaces filtered. 280 optional int32 num_namespaces_filtered = 5; 281 282 // Number of schema types filtered. 283 optional int32 num_schema_types_filtered = 6; 284 285 // Time used to parse the query, including 2 parts: tokenizing and 286 // transforming tokens into an iterator tree. 287 optional int32 parse_query_latency_ms = 7; 288 289 // Time used to delete each document. 290 optional int32 document_removal_latency_ms = 8; 291} 292