tarun11Mavani commented on code in PR #18368:
URL: https://github.com/apache/pinot/pull/18368#discussion_r3199714796
##########
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/datasource/MapDataSource.java:
##########
@@ -32,9 +32,22 @@ public interface MapDataSource extends DataSource {
/**
* Get the Data Source representation of a single key within this map column.
+ * Only call after confirming the key exists via {@link
#containsKey(String)}.
*/
DataSource getKeyDataSource(String key);
+ /**
+ * Returns true if {@code key} is present in this MAP column for at least
one document in
+ * this segment. Call this before {@link #getKeyDataSource(String)} to avoid
undefined
+ * behaviour on absent keys.
+ *
+ * <p>The default implementation delegates to {@link #getKeyDataSources()},
which may be
+ * expensive for large key sets. Implementations should override for O(1)
performance.
+ */
+ default boolean containsKey(String key) {
Review Comment:
replied above.
> For https://github.com/nullable: I'd prefer to keep the current non-null
contract backed by NullDataSource. The callers in ProjectionBlock and
ItemTransformFunction dereference the result immediately without a null-check —
NullDataSource lets them do that safely by returning the column's default value
for every doc.
>
> If we switch to https://github.com/nullable, those two callers need
null-guards, and so does any future caller. NullDataSource gives the same
semantic (absent key → null/default for all rows) without pushing null-handling
into every call site.
> Happy to revisit this if you strognly feel we should add
https://github.com/nullable.
>
> Let me know your thoughts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]