1 // Copyright (C) 2024 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 15 #ifndef ICING_FEATURE_FLAGS_H_ 16 #define ICING_FEATURE_FLAGS_H_ 17 18 namespace icing { 19 namespace lib { 20 21 class FeatureFlags { 22 public: FeatureFlags(bool allow_circular_schema_definitions,bool enable_scorable_properties,bool enable_embedding_quantization,bool enable_repeated_field_joins,bool enable_embedding_backup_generation,bool enable_schema_database,bool release_backup_schema_file_if_overlay_present)23 explicit FeatureFlags(bool allow_circular_schema_definitions, 24 bool enable_scorable_properties, 25 bool enable_embedding_quantization, 26 bool enable_repeated_field_joins, 27 bool enable_embedding_backup_generation, 28 bool enable_schema_database, 29 bool release_backup_schema_file_if_overlay_present) 30 : allow_circular_schema_definitions_(allow_circular_schema_definitions), 31 enable_scorable_properties_(enable_scorable_properties), 32 enable_embedding_quantization_(enable_embedding_quantization), 33 enable_repeated_field_joins_(enable_repeated_field_joins), 34 enable_embedding_backup_generation_(enable_embedding_backup_generation), 35 enable_schema_database_(enable_schema_database), 36 release_backup_schema_file_if_overlay_present_( 37 release_backup_schema_file_if_overlay_present) {} 38 allow_circular_schema_definitions()39 bool allow_circular_schema_definitions() const { 40 return allow_circular_schema_definitions_; 41 } 42 enable_scorable_properties()43 bool enable_scorable_properties() const { 44 return enable_scorable_properties_; 45 } 46 enable_embedding_quantization()47 bool enable_embedding_quantization() const { 48 return enable_embedding_quantization_; 49 } 50 enable_repeated_field_joins()51 bool enable_repeated_field_joins() const { 52 return enable_repeated_field_joins_; 53 } 54 enable_embedding_backup_generation()55 bool enable_embedding_backup_generation() const { 56 return enable_embedding_backup_generation_; 57 } 58 enable_schema_database()59 bool enable_schema_database() const { return enable_schema_database_; } 60 release_backup_schema_file_if_overlay_present()61 bool release_backup_schema_file_if_overlay_present() const { 62 return release_backup_schema_file_if_overlay_present_; 63 } 64 65 private: 66 // Whether to allow circular references in the schema definition. This was 67 // added in the Android U timeline and is not a trunk-stable flag. 68 bool allow_circular_schema_definitions_; 69 70 bool enable_scorable_properties_; 71 72 // Whether to enable quantization for embedding vectors. If false, all 73 // embedding vectors will not be quantized. Otherwise, quantization will be 74 // controlled by the quantization type specified in the schema. 75 bool enable_embedding_quantization_; 76 77 bool enable_repeated_field_joins_; 78 79 // Controls code that runs in backup schema producer to remove embedding 80 // properties. 81 bool enable_embedding_backup_generation_; 82 83 bool enable_schema_database_; 84 85 bool release_backup_schema_file_if_overlay_present_; 86 }; 87 88 } // namespace lib 89 } // namespace icing 90 91 #endif // ICING_FEATURE_FLAGS_H_ 92