diff options
author | Jiayu Hu <hujiayu@google.com> | 2023-12-01 16:38:12 -0800 |
---|---|---|
committer | Jiayu Hu <hujiayu@google.com> | 2023-12-01 16:40:46 -0800 |
commit | 77a3d7acfd36b403ebec87d7cbc7cf6486b71941 (patch) | |
tree | 0d83b3880be27e055a77217411e8c3bb327cf5d9 /icing/util/document-validator.cc | |
parent | ea81bd0613730609fcf3c6ffa7d2e52bcc10a9ac (diff) | |
parent | 680dbbd97ed411c19591e4c35616f0b418a56dc9 (diff) | |
download | icing-77a3d7acfd36b403ebec87d7cbc7cf6486b71941.tar.gz |
Merge remote-tracking branch 'aosp/upstream-master' into androidx-main
* aosp/upstream-master:
Update Icing from upstream.
Update Icing from upstream.
Update Icing from upstream.
Descriptions:
========================================================================
Fix the build error in aosp/2856025
========================================================================
[Icing][version 3] Bump kVersion to 3
========================================================================
Make lite index magic dependent on `IcingSearchEngineOptions::build_property_existence_metadata_hits`
========================================================================
Add a flag in IcingSearchEngineOptions to control whether to build property existence metadata hits
========================================================================
Support `hasProperty(property_path)` in the advanced query language
========================================================================
Add PropertyExistenceIndexingHandler to index property existence metadata hit
========================================================================
[JoinIndex Improvement][11/x] Add IcingSearchEngine initialization unit test for switching join index
========================================================================
[JoinIndex Improvement][10/x] Change/Add IcingSearchEngine unit tests
========================================================================
[JoinIndex Improvement][9/x] Integrate QualifiedIdJoinIndexImplV2 with IcingSearchEngine
========================================================================
[JoinIndex Improvement][8/x] Integrate QualifiedIdJoinIndexImplV2 with JoinProcessor
========================================================================
[JoinIndex Improvement][8/x] Integrate QualifiedIdJoinIndexImplV2 with QualifiedIdJoinIndexingHandler
========================================================================
[JoinIndex Improvement][7/x] Create QualifiedIdJoinIndex interface
========================================================================
[JoinIndex Improvement][6.1/x] Unit test (Optimize)
========================================================================
[JoinIndex Improvement][6.0/x] Unit test (General, Put, GetIterator)
========================================================================
[JoinIndex Improvement][5.3/x] Implement Optimize
========================================================================
Remove accents from Greek letters in normalizer
========================================================================
Make arm emulator tests build-only.
========================================================================
[JoinIndex Improvement][5.2/x] Implement GetIterator
========================================================================
[JoinIndex Improvement][5.1/x] Implement Put
========================================================================
[JoinIndex Improvement][5.0/x] Branch QualifiedIdJoinIndex to QualifiedIdJoinIndexImplV2
========================================================================
[JoinIndex Improvement][4/x] Implement PostingListJoinDataAccessor
========================================================================
[JoinIndex Improvement][3/x] Implement PostingListJoinDataSerializer and DocumentIdToJoinInfo data type
========================================================================
[JoinIndex Improvement][2/x] Create NamespaceFingerprintIdentifier
========================================================================
[JoinIndex Improvement][1/x] Implement namespace_id_old_to_new in Compaction
========================================================================
Update test to also handle ICU 74 segmentation rules.
========================================================================
[Icing][Expand QueryStats][3/x] Add new fields into QueryStats (1)
========================================================================
[Icing][Expand QueryStats][2/x] Refactor QueryStatsProto
========================================================================
[Icing][Expand QueryStats][1/x] Publish DocHitInfoIterator CallStats
========================================================================
Add additional property filter tests
========================================================================
Deprecate hit_intersect_section_ids_mask in DocHitInfoIterator
========================================================================
Change default requires_full_emulation to False for portable_cc_test (third_party/icing/testing)
========================================================================
Cleanup Set requires_full_emulation to True for selective tests
========================================================================
Fix monkey test failures
========================================================================
Complete monkey test logic to change schema during monkey test runtime
========================================================================
Refactor monkey test to prepare for schema update
========================================================================
Fix the schema bug found by monkey test with seed 2551429844
========================================================================
Move set query stats to the very top of InternalSearch()
========================================================================
Apply section restriction only on leaf nodes
========================================================================
[6/n] Fix callsites in Icing that forgot to check libtextclassifier3::Status (Advanced query parser)
========================================================================
[5/n] Fix callsites in Icing that forgot to check libtextclassifier3::Status (PersistentHashMap)
========================================================================
[4/n] Fix callsites in Icing that forgot to check libtextclassifier3::Status (PostingListIntegerIndexSerializer)
========================================================================
[3/n] Fix callsites in Icing that forgot to check libtextclassifier3::Status (PostingListHitSerializer)
========================================================================
[2/n] Fix callsites in Icing that forgot to check libtextclassifier3::Status (Posting list storage)
========================================================================
[1/n] Fix callsites in Icing that forgot to check libtextclassifier3::Status (Non-functional changes)
========================================================================
Decouple section restriction data from iterators
========================================================================
Fix the crash when a schema type gets more indexable properties than allowed
========================================================================
Add a checker to verify the property data type matches the schema.
========================================================================
Change global std::string in i18n-utils to constexpr std::string_view.
========================================================================
Adjust LiteIndex sort at indexing check conditions.
========================================================================
Add @UsedByNative annotations to native* methods in IcingSearchEngineImpl.
========================================================================
Bug: 305098009
Bug: 307508735
Bug: 291130542
Bug: 275121148
Bug: 303239901
Bug: 301116242
Bug: 299321977
Bug: 300135897
Bug: 297549761
Bug: 309826655
Bug: 296349369
Bug: 302192690
Bug: 302609704
Bug: 301566713
Bug: 296938196
NO_IFTTT="False Alarm: The path is only valid in G3. kVersion is changed to 3, and schema is compatible with version 1."
Change-Id: I1d50cf70261c8977e52047c8051e8d143f62ba2c
Diffstat (limited to 'icing/util/document-validator.cc')
-rw-r--r-- | icing/util/document-validator.cc | 67 |
1 files changed, 54 insertions, 13 deletions
diff --git a/icing/util/document-validator.cc b/icing/util/document-validator.cc index 9d5fea7..ebdb0d7 100644 --- a/icing/util/document-validator.cc +++ b/icing/util/document-validator.cc @@ -104,24 +104,65 @@ libtextclassifier3::Status DocumentValidator::Validate( } const PropertyConfigProto& property_config = *property_iter->second; - // Get the property value size according to data type. + // Validate the property data type and get the property value size according + // to data type. int value_size = 0; - if (property_config.data_type() == PropertyConfigProto::DataType::STRING) { + if (property.string_values_size() > 0) { + if (property_config.data_type() != + PropertyConfigProto::DataType::STRING) { + return absl_ports::InvalidArgumentError(absl_ports::StrCat( + "The data type of property name '", property.name(), + "' is not STRING for key: (", document.namespace_(), ", ", + document.uri(), ").")); + } value_size = property.string_values_size(); - } else if (property_config.data_type() == - PropertyConfigProto::DataType::INT64) { + } + if (property.int64_values_size() > 0) { + if (property_config.data_type() != PropertyConfigProto::DataType::INT64) { + return absl_ports::InvalidArgumentError(absl_ports::StrCat( + "The data type of property name '", property.name(), + "' is not INT64 for key: (", document.namespace_(), ", ", + document.uri(), ").")); + } value_size = property.int64_values_size(); - } else if (property_config.data_type() == - PropertyConfigProto::DataType::DOUBLE) { + } + if (property.double_values_size() > 0) { + if (property_config.data_type() != + PropertyConfigProto::DataType::DOUBLE) { + return absl_ports::InvalidArgumentError(absl_ports::StrCat( + "The data type of property name '", property.name(), + "' is not DOUBLE for key: (", document.namespace_(), ", ", + document.uri(), ").")); + } value_size = property.double_values_size(); - } else if (property_config.data_type() == - PropertyConfigProto::DataType::BOOLEAN) { + } + if (property.boolean_values_size() > 0) { + if (property_config.data_type() != + PropertyConfigProto::DataType::BOOLEAN) { + return absl_ports::InvalidArgumentError(absl_ports::StrCat( + "The data type of property name '", property.name(), + "' is not BOOLEAN for key: (", document.namespace_(), ", ", + document.uri(), ").")); + } value_size = property.boolean_values_size(); - } else if (property_config.data_type() == - PropertyConfigProto::DataType::BYTES) { + } + if (property.bytes_values_size() > 0) { + if (property_config.data_type() != PropertyConfigProto::DataType::BYTES) { + return absl_ports::InvalidArgumentError(absl_ports::StrCat( + "The data type of property name '", property.name(), + "' is not BYTES for key: (", document.namespace_(), ", ", + document.uri(), ").")); + } value_size = property.bytes_values_size(); - } else if (property_config.data_type() == - PropertyConfigProto::DataType::DOCUMENT) { + } + if (property.document_values_size() > 0) { + if (property_config.data_type() != + PropertyConfigProto::DataType::DOCUMENT) { + return absl_ports::InvalidArgumentError(absl_ports::StrCat( + "The data type of property name '", property.name(), + "' is not DOCUMENT for key: (", document.namespace_(), ", ", + document.uri(), ").")); + } value_size = property.document_values_size(); } @@ -172,7 +213,7 @@ libtextclassifier3::Status DocumentValidator::Validate( } } if (num_required_properties_actual < - parsed_property_configs.num_required_properties) { + parsed_property_configs.required_properties.size()) { return absl_ports::InvalidArgumentError( absl_ports::StrCat("One or more required fields missing for key: (", document.namespace_(), ", ", document.uri(), ").")); |