diff options
author | Tim Barron <tjbarron@google.com> | 2023-03-14 09:57:47 -0700 |
---|---|---|
committer | Tim Barron <tjbarron@google.com> | 2023-03-14 09:57:47 -0700 |
commit | c1e7edff54723138756063ee4b7948c1ee91277e (patch) | |
tree | b2a55e543a6c9396631feaab459bfd671a8bc400 /icing/schema/schema-util.h | |
parent | 140aaee3e7b269f02599310e42d6172090ce02d2 (diff) | |
parent | d5c81ae0c41ae9c1aefb3601f3836570b9f686c7 (diff) | |
download | icing-c1e7edff54723138756063ee4b7948c1ee91277e.tar.gz |
Merge remote-tracking branch 'goog/upstream-master' into androidx-platform-dev
* goog/upstream-master:
Update Icing from upstream.
Update Icing from upstream.
Descriptions:
========================================================================
Cache an instance of UBreakIterator to reduce unnecessary creations.
========================================================================
Cap number of individual IntegerIndexStorages that IntegerIndex creates.
========================================================================
Change error in trimRightMostNode from Unimplemented to InvalidArgument.
========================================================================
Add detection for new language features of List Filters Query Language.
========================================================================
Add option to control threshold to rebuild index during optimize by flag
========================================================================
Add option to control use of namespace id to build urimapper by flag.
========================================================================
Enforce schema validation for joinable config.
========================================================================
Adopt bucket splitting for IntegerIndexStorage.
========================================================================
Implement bucket splitting function.
========================================================================
Add Icing initialization unit tests for QualifiedIdTypeJoinableIndex.
========================================================================
Add Icing schema change unit tests for QualifiedIdTypeJoinableIndex.
========================================================================
Add Icing optimization unit tests for QualifiedIdTypeJoinableIndex.
========================================================================
Integrate QualifiedIdTypeJoinableIndex into IcingSearchEngine.
========================================================================
Implement QualifiedIdJoinablePropertyIndexingHandler.
========================================================================
Change QualifiedIdTypeJoinableIndex to store raw qualified id string.
========================================================================
Pass info about unnormalized query terms through lexer/parser/visitor.
========================================================================
Integrate Advanced Query w/ Suggest, make ADVANCED_QUERY default parser.
======================================================================
Bug: 208654892
Bug: 263890397
Bug: 259743562
Bug: 272145329
Bug: 227356108
Change-Id: I44de5853bb6c55b42800ae34d8071016be6c87cd
Diffstat (limited to 'icing/schema/schema-util.h')
-rw-r--r-- | icing/schema/schema-util.h | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/icing/schema/schema-util.h b/icing/schema/schema-util.h index e5747bb..47bb76b 100644 --- a/icing/schema/schema-util.h +++ b/icing/schema/schema-util.h @@ -34,9 +34,19 @@ class SchemaUtil { std::unordered_map<std::string, const SchemaTypeConfigProto>; // If A -> B is indicated in the map, then type A must be built before - // building type B, i.e. B depends on A. - using DependentMap = std::unordered_map<std::string_view, - std::unordered_set<std::string_view>>; + // building type B, i.e. B has a property of type A. Also include all + // PropertyConfigProto (with DOCUMENT data_type) pointers which directly + // connects type A and B. IOW, this vector of PropertyConfigProto* are "direct + // edges" connecting A and B directly. It will be an empty vector if A and B + // are not "directly" connected, but instead via another intermediate level of + // schema type. For example, the actual dependency is A -> C -> B, so there + // will be A -> C and C -> B with valid PropertyConfigProto* respectively in + // this map, but we will also expand transitive dependents: add A -> B into + // dependent map with empty vector of "edges". + using DependentMap = std::unordered_map< + std::string_view, + std::unordered_map<std::string_view, + std::vector<const PropertyConfigProto*>>>; struct SchemaDelta { // Which schema types were present in the old schema, but were deleted from @@ -113,6 +123,11 @@ class SchemaUtil { // itself, thus creating an infinite loop. // 13. Two SchemaTypeConfigProtos cannot have properties that reference each // other's schema_type, thus creating an infinite loop. + // 14. PropertyConfigProtos.joinable_config must be valid. See + // ValidateJoinableConfig for more details. + // 15. Any PropertyConfigProtos with nested DOCUMENT data type must not have + // REPEATED cardinality if they reference a schema type containing + // joinable property. // // TODO(b/171996137): Clarify 12 and 13 are only for indexed properties, once // document properties can be opted out of indexing. @@ -121,7 +136,7 @@ class SchemaUtil { // On success, a dependent map from each types to their dependent types // that depend on it directly or indirectly. // ALREADY_EXISTS for case 1 and 2 - // INVALID_ARGUMENT for 3-13 + // INVALID_ARGUMENT for 3-15 static libtextclassifier3::StatusOr<DependentMap> Validate( const SchemaProto& schema); @@ -145,6 +160,8 @@ class SchemaUtil { // `SchemaDelta.schema_types_deleted` // 3. A schema type's new definition would mean any existing data of the old // definition is now incompatible. + // 4. The derived join index would be incompatible. This is held in + // `SchemaDelta.join_incompatible`. // // For case 1, the two schemas would result in an incompatible index if: // 1.1. The new SchemaProto has a different set of indexed properties than @@ -167,6 +184,11 @@ class SchemaUtil { // scale defined as: // LEAST <REPEATED - OPTIONAL - REQUIRED> MOST // + // For case 4, the two schemas would result in an incompatible join if: + // 4.1. A SchematypeConfig exists in the new SchemaProto that has a + // different set of joinable properties than it did in the old + // SchemaProto. + // // A property is defined by the combination of the // SchemaTypeConfig.schema_type and the PropertyConfigProto.property_name. // @@ -227,6 +249,22 @@ class SchemaUtil { const StringIndexingConfig& config, PropertyConfigProto::DataType::Code data_type, std::string_view schema_type, std::string_view property_name); + + // Checks that the 'joinable_config' satisfies the following rules: + // 1. If the data type matches joinable value type + // a. Only STRING data types can use QUALIFIED_ID joinable value type + // 2. Only QUALIFIED_ID joinable value type can have delete propagation + // enabled + // 3. Any joinable property should have non-REPEATED cardinality + // + // Returns: + // INVALID_ARGUMENT if any of the rules are not followed + // OK on success + static libtextclassifier3::Status ValidateJoinableConfig( + const JoinableConfig& config, + PropertyConfigProto::DataType::Code data_type, + PropertyConfigProto::Cardinality::Code cardinality, + std::string_view schema_type, std::string_view property_name); }; } // namespace lib |