Skip to content

Commit

Permalink
revert mapColumns to default behavior. engineers are now responsible …
Browse files Browse the repository at this point in the history
…for handling dict encoded arrays in the callback (#454)

Co-authored-by: atarashansky <atarashansky@CZIMACOS3990.hsd1.ma.comcast.net>
  • Loading branch information
atarashansky and atarashansky authored Sep 20, 2022
1 parent 9fd9d37 commit 92c5237
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions client/src/util/dataframe/dataframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,26 +959,12 @@ class Dataframe {
callback MUST not modify the column, but instead return a mutated copy.
*/
const columns = this.__columns.map((colData, colIdx) => {
let data: DataframeValueArray;
// mapColumns will mutate dictionary encoded arrays into standard value arrays.
// This ensures that users will always be dealing with values in the callback.
// TODO: memoize this function to avoid repeated work.
if (isDictEncodedTypedArray(colData)) {
data = new Array(colData.length);
for (let i = 0; i < data.length; i += 1) {
data[i] = colData.vat(i);
}
} else {
data = colData;
}
return callback(
data,
const columns = this.__columns.map((colData, colIdx) => callback(
colData,
colIdx,
this.colIndex.getLabel(colIdx) as LabelType,
this
);
});
));
const columnsAccessor: (DataframeColumn | null)[] = columns.map((c, idx) =>
this.__columns[idx] === c ? this.__columnsAccessor[idx] : null
);
Expand Down

0 comments on commit 92c5237

Please sign in to comment.