@@ -948,7 +948,7 @@ export class AbstractSeries<T extends DataType = any> {
948948 * For dictionary columns, the keys column component is copied and not trimmed if the gather
949949 * results in abandoned key elements.
950950 *
951- * @param selection A Series of 8/16/32-bit signed or unsigned integer indices to gather.
951+ * @param indices A Series of 8/16/32-bit signed or unsigned integer indices to gather.
952952 * @param nullify_out_of_bounds If `true`, coerce rows that corresponds to out-of-bounds indices
953953 * in the selection to null. If `false`, skips all bounds checking for selection values. Pass
954954 * false if you are certain that the selection contains only valid indices for better
@@ -970,11 +970,11 @@ export class AbstractSeries<T extends DataType = any> {
970970 * c.gather(selection) // Bool8Series [true, true]
971971 * ```
972972 */
973- gather < R extends IndexType > ( selection : Series < R > ,
974- nullify_out_of_bounds = false ,
975- memoryResource ?: MemoryResource ) : Series < T > {
976- return this . __construct (
977- this . _col . gather ( selection . _col , nullify_out_of_bounds , memoryResource ) ) ;
973+ gather ( indices : Series < IndexType > | number [ ] ,
974+ nullify_out_of_bounds = false ,
975+ memoryResource ?: MemoryResource ) : Series < T > {
976+ const map = Array . isArray ( indices ) ? Series . new ( indices ) . cast ( new Uint32 ) : indices ;
977+ return this . __construct ( this . _col . gather ( map . _col , nullify_out_of_bounds , memoryResource ) ) ;
978978 }
979979
980980 /**
@@ -1109,7 +1109,7 @@ export class AbstractSeries<T extends DataType = any> {
11091109 * ```
11101110 */
11111111 scatter ( value : T [ 'scalarType' ] ,
1112- indices : Series < Int32 > | number [ ] ,
1112+ indices : Series < IndexType > | number [ ] ,
11131113 check_bounds ?: boolean ,
11141114 memoryResource ?: MemoryResource ) : Series < T > ;
11151115 /**
@@ -1135,24 +1135,24 @@ export class AbstractSeries<T extends DataType = any> {
11351135 * ```
11361136 */
11371137 scatter ( values : Series < T > ,
1138- indices : Series < Int32 > | number [ ] ,
1138+ indices : Series < IndexType > | number [ ] ,
11391139 check_bounds ?: boolean ,
11401140 memoryResource ?: MemoryResource ) : Series < T > ;
11411141
11421142 scatter ( source : Series < T > | T [ 'scalarType' ] ,
1143- indices : Series < Int32 > | number [ ] ,
1143+ indices : Series < IndexType > | number [ ] ,
11441144 check_bounds = false ,
11451145 memoryResource ?: MemoryResource ) : Series < T > {
11461146 const dst = new Table ( { columns : [ this . _col ] } ) ;
1147- const idx = Series . new ( indices ) . cast ( new Int32 ) . _col ;
1147+ const map = Array . isArray ( indices ) ? Series . new ( indices ) . cast ( new Uint32 ) : indices ;
11481148 if ( source instanceof Series ) {
11491149 const src = new Table ( { columns : [ source . cast ( this . type ) . _col ] } ) ;
11501150 return this . __construct (
1151- dst . scatterTable ( src , idx , check_bounds , memoryResource ) . getColumnByIndex ( 0 ) ) ;
1151+ dst . scatterTable ( src , map . _col , check_bounds , memoryResource ) . getColumnByIndex ( 0 ) ) ;
11521152 }
11531153 const src = [ new Scalar ( { type : this . type , value : source } ) ] ;
11541154 return this . __construct (
1155- dst . scatterScalar ( src , idx , check_bounds , memoryResource ) . getColumnByIndex ( 0 ) ) ;
1155+ dst . scatterScalar ( src , map . _col , check_bounds , memoryResource ) . getColumnByIndex ( 0 ) ) ;
11561156 }
11571157
11581158 /**
@@ -1668,7 +1668,6 @@ function asColumn<T extends DataType>(value: any) {
16681668 if ( Array . isArray ( data ) ) {
16691669 return fromArrow < T > ( arrow . Vector . from ( {
16701670 highWaterMark : Infinity ,
1671- nullValues : [ undefined , null , NaN ] ,
16721671 type : value . type ?? inferType ( data ) ,
16731672 // Slice `offset` from the Array before converting so
16741673 // we don't write unnecessary values with the Arrow builders.
@@ -1677,12 +1676,14 @@ function asColumn<T extends DataType>(value: any) {
16771676 }
16781677
16791678 // If `data.buffer` is a ArrayBuffer, copy it to a DeviceBuffer
1680- if ( data . buffer instanceof ArrayBuffer ) {
1679+ if ( ArrayBuffer . isView ( value ) || ( data . buffer instanceof ArrayBuffer ) ) {
1680+ if ( typeof data . length === 'number' ) { value . length = data . length ; }
16811681 data = new DeviceBuffer ( typeof offset !== 'number' ? data : data . subarray ( offset ) ) ;
16821682 offset = 0 ;
16831683 }
16841684 // If `data.buffer` is a DeviceBuffer, propagate its `byteOffset` to ColumnProps
16851685 else if ( data . buffer instanceof DeviceBuffer ) {
1686+ if ( typeof data . length === 'number' ) { value . length = data . length ; }
16861687 offset =
16871688 ( typeof offset !== 'number' ? 0 : offset ) + ( data . byteOffset / data . BYTES_PER_ELEMENT ) ;
16881689 }
0 commit comments