DataFrame: Add optional unique row id definition as frame.meta.uniqueRowIdFields (#80428)
* Define an unique id for a row in dataframe * Update comment * Rename attribute * Add comment about plugin sdk * Fix comment
This commit is contained in:
@@ -13,5 +13,6 @@ export {
|
||||
isTimeSeriesFrame,
|
||||
isTimeSeriesFrames,
|
||||
isTimeSeriesField,
|
||||
getRowUniqueId,
|
||||
} from './utils';
|
||||
export { StreamingDataFrame, StreamingFrameAction, type StreamingFrameOptions, closestIdx } from './StreamingDataFrame';
|
||||
|
||||
@@ -86,3 +86,15 @@ export function anySeriesWithTimeField(data: DataFrame[]) {
|
||||
export function hasTimeField(data: DataFrame): boolean {
|
||||
return data.fields.some((field) => field.type === FieldType.time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row id based on the meta.uniqueRowIdFields attribute.
|
||||
* @param dataFrame
|
||||
* @param rowIndex
|
||||
*/
|
||||
export function getRowUniqueId(dataFrame: DataFrame, rowIndex: number) {
|
||||
if (dataFrame.meta?.uniqueRowIdFields === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return dataFrame.meta.uniqueRowIdFields.map((fieldIndex) => dataFrame.fields[fieldIndex].values[rowIndex]).join('-');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user