fix: Editing issues when key columns are not first columns#2053
fix: Editing issues when key columns are not first columns#2053AkshatJawne merged 8 commits intodeephaven:mainfrom
Conversation
| column <= range.endColumn; | ||
| column += 1 | ||
| ) { | ||
| if (this.inputTable.keyColumns.includes(this.columns[column])) { |
There was a problem hiding this comment.
Doing a .includes could be expensive if we have a lot of keyColumns. (It's unlikely, but we want to ensure our operations scale to thousands of columns anyway).
Also, looking at the implementation of JsInputTable.getKeyColumns (which is what is called each time we call this.inputTable.keyColumns) reveals that it's iterating through all keys each time, while also creating a new array each time: https://github.com/deephaven/deephaven-core/blob/2da295f9294031c9329b7db6a98c33bd64c3d6d6/web/client-api/src/main/java/io/deephaven/web/client/api/input/JsInputTable.java#L78
Also while reviewing this, I noticed that the isKeyColumn method is incorrect (it's checking the index against the keyColumns.length as well); as well as the isDeletable, pendingDataErrors, getCachedPendingErrors checks. We should fix these at the same time (and basically anywhere that is just checking keyColumns.length).
So I'm going to expand the scope of this ticket a little bit. Here's a few things to do:
- Add a method
get keyColumnSetandgetCachedKeyColumnSet, that just returns aSetwith the key column names (not the actual column). Should be memoized by passing intable.columnsandinputTable.keys(those are both stable arrays, and will not bust the memoization cache). Key lookup in a set will be much faster than doing a.includes(O(1) vs. O(n)). This would be similar to theget columnMap()/getMemoizedColumnMapfunctions (though returning aSetinstead of aMap). isKeyColumnshould use the set to check if the column is part of the set, e.g.this.keyColumnSet.has(this.columns[x].name)- Everywhere we're currently looking at
keyColumns.lengthwe should probably be using theisKeyColumnmethod to check instead. - File a ticket against deephaven-core to have
JsInputTable.getKeyColumnsreturn a frozen/stable array, similar to JsTable.getColumns. Maybe this is something you'll want to tackle as well (Java code if you're interested, I don't think you've poked the JS API yet), but it isn't strictly necessary for this ticket given the above.
There was a problem hiding this comment.
Sounds good, will start work on implementation. In terms of working with Java code, I would love to do so, so would be very grateful for the opportunity.
|
Investigating unit test failures |
|
Have to add check in |
Resolves #2036
Changes Implemented:
Changed check for key columns within range to no longer check whether the start of the range is > # of key columns and end of range is > # of key columns , but rather, iterate through and check if any of the columns are key columns
The check priorly was making it so that the key columns are always the first columns, which was causing issues with editing columns if they were not