Skip to content

Add fieldsSelector to single element properties API#8990

Open
AbhijeetFasate13 wants to merge 2 commits into
iTwin:masterfrom
AbhijeetFasate13:abhijeetfasate/property-filter-getelementproperties
Open

Add fieldsSelector to single element properties API#8990
AbhijeetFasate13 wants to merge 2 commits into
iTwin:masterfrom
AbhijeetFasate13:abhijeetfasate/property-filter-getelementproperties

Conversation

@AbhijeetFasate13
Copy link
Copy Markdown

- 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
@AbhijeetFasate13 AbhijeetFasate13 requested a review from a team as a code owner February 16, 2026 09:42
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 16, 2026

CLA assistant check
All committers have signed the CLA.

@AbhijeetFasate13
Copy link
Copy Markdown
Author

@grigasp Can you review this?

Copy link
Copy Markdown
Member

@grigasp grigasp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Request content like we did before your changes.
  2. If fieldsSelector is provided, clone the content's descriptor and replace fields with original descriptor's selectedFields.
  3. Pass the cloned descriptor to parser instead 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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +204 to +209
/**
* 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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SingleElementPropertiesRequestOptions is also used by frontend's PresentationManager.getElementProperties, so would have to implemented there, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants