* add duckdb-ui-client & other ts pkgs * workflow fixes * fix working dir * no sparse checkout; specify package.json path * path to pnpm-lock.yaml * add check & build test * workflow step descriptions * use comments & names * one more naming tweak
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { DuckDBData } from '@duckdb/data-reader';
|
|
import { DuckDBType } from '@duckdb/data-types';
|
|
import { DuckDBValue } from '@duckdb/data-values';
|
|
import { duckDBTypeFromTypeIdAndInfo } from '../../conversion/functions/duckDBTypeFromTypeIdAndInfo.js';
|
|
import { duckDBValueFromVector } from '../../conversion/functions/duckDBValueFromVector.js';
|
|
import { ColumnNamesAndTypes } from '../../serialization/types/ColumnNamesAndTypes.js';
|
|
import { DataChunk } from '../../serialization/types/DataChunk.js';
|
|
|
|
export class DuckDBDataChunk extends DuckDBData {
|
|
constructor(
|
|
private columnNamesAndTypes: ColumnNamesAndTypes,
|
|
private chunk: DataChunk,
|
|
) {
|
|
super();
|
|
}
|
|
|
|
get columnCount() {
|
|
return this.columnNamesAndTypes.names.length;
|
|
}
|
|
|
|
get rowCount() {
|
|
return this.chunk.rowCount;
|
|
}
|
|
|
|
columnName(columnIndex: number): string {
|
|
return this.columnNamesAndTypes.names[columnIndex];
|
|
}
|
|
|
|
columnType(columnIndex: number): DuckDBType {
|
|
return duckDBTypeFromTypeIdAndInfo(
|
|
this.columnNamesAndTypes.types[columnIndex],
|
|
);
|
|
}
|
|
|
|
value(columnIndex: number, rowIndex: number): DuckDBValue {
|
|
return duckDBValueFromVector(
|
|
this.columnNamesAndTypes.types[columnIndex],
|
|
this.chunk.vectors[columnIndex],
|
|
rowIndex,
|
|
);
|
|
}
|
|
}
|