Add fieldsSelector to single element properties API#8990
Add fieldsSelector to single element properties API#8990AbhijeetFasate13 wants to merge 2 commits into
Conversation
- Added fieldsSelector property to SingleElementPropertiesRequestOptions - Implemented filtering logic in getSingleElementProperties method - Added comprehensive test coverage (include/exclude/undefined cases) - Addresses issue iTwin#8966: improves performance for elements with large property sets
|
@grigasp Can you review this? |
grigasp
left a comment
There was a problem hiding this comment.
The issue doesn't state it, but we have the performance problem, when loading properties for many elements, and that's been fixed with #8979.
The single-element case would be a good improvement for consistency, however, as stated in one of the comments, it can't be implemented through descriptor overrides without making the performance worse. The approach I'd take is to:
- Request content like we did before your changes.
- If
fieldsSelectoris provided, clone the content's descriptor and replacefieldswith original descriptor'sselectedFields. - Pass the cloned descriptor to
parserinstead of the original one.
Also, because SingleElementPropertiesRequestOptions is used by both - frontend and backend - PresentationManager.getElementProperties methods, this needs to be implemented on both sides.
| categories: [], | ||
| contentFlags: 0, | ||
| }); | ||
| const selection = fieldsSelector(emptyDescriptor); |
There was a problem hiding this comment.
Empty descriptor is not a valid argument for fieldsSelector callback - it needs to receive a real descriptor with fields so it has something to choose from.
To pass it a valid argument, we'd first have to request a descriptor, then pass it to fieldsSelector, then call getContent. However, splitting the content request into 2 requests would actually make the performance worse for 1 element case.
| /** | ||
| * A callback that allows specifying which fields should be included or excluded in the result based on the given content descriptor. This | ||
| * is useful when requesting properties of elements with a very large number of fields, where it may be desirable to only get a | ||
| * subset of all available fields for performance improvement. | ||
| */ | ||
| fieldsSelector?: (descriptor: Descriptor) => DescriptorFieldsSelector | undefined; |
There was a problem hiding this comment.
SingleElementPropertiesRequestOptions is also used by frontend's PresentationManager.getElementProperties, so would have to implemented there, too.
getElementPropertiesbackend API #8966