@@ -60,42 +60,38 @@ export type kUnknownNullCount = -1;
6060export const kUnknownNullCount = - 1 ;
6161
6262export class BaseData < T extends DataType = DataType > implements VectorLike {
63- protected _type : T ;
64- protected _length : number ;
65- protected _offset : number ;
63+ public type : T ;
64+ public length : number ;
65+ public offset : number ;
6666 // @ts -ignore
67- protected _childData : Data < any > [ ] ;
67+ public childData : Data < any > [ ] ;
6868 protected _nullCount : number | kUnknownNullCount ;
6969 protected /* [VectorType.OFFSET]:*/ 0 ?: Int32Array ;
7070 protected /* [VectorType.DATA]:*/ 1 ?: T [ 'TArray' ] ;
7171 protected /*[VectorType.VALIDITY]:*/ 2 ?: Uint8Array ;
7272 protected /* [VectorType.TYPE]:*/ 3 ?: Int8Array ;
7373 constructor ( type : T , length : number , offset ?: number , nullCount ?: number ) {
74- this . _type = type ;
75- this . _length = Math . floor ( Math . max ( length || 0 , 0 ) ) ;
76- this . _offset = Math . floor ( Math . max ( offset || 0 , 0 ) ) ;
74+ this . type = type ;
75+ this . length = Math . floor ( Math . max ( length || 0 , 0 ) ) ;
76+ this . offset = Math . floor ( Math . max ( offset || 0 , 0 ) ) ;
7777 this . _nullCount = Math . floor ( Math . max ( nullCount || 0 , - 1 ) ) ;
7878 }
79- public get type ( ) { return this . _type ; }
80- public get length ( ) { return this . _length ; }
81- public get offset ( ) { return this . _offset ; }
82- public get typeId ( ) { return this . _type . TType ; }
83- public get childData ( ) { return this . _childData ; }
79+ public get typeId ( ) { return this . type . TType ; }
8480 public get nullBitmap ( ) { return this [ VectorType . VALIDITY ] ; }
8581 public get nullCount ( ) {
8682 let nullCount = this . _nullCount ;
8783 let nullBitmap : Uint8Array | undefined ;
8884 if ( nullCount === - 1 && ( nullBitmap = this [ VectorType . VALIDITY ] ) ) {
89- this . _nullCount = nullCount = this . _length - popcnt_bit_range ( nullBitmap , this . _offset , this . _offset + this . _length ) ;
85+ this . _nullCount = nullCount = this . length - popcnt_bit_range ( nullBitmap , this . offset , this . offset + this . length ) ;
9086 }
9187 return nullCount ;
9288 }
93- public clone < R extends T > ( type : R , length = this . _length , offset = this . _offset , nullCount = this . _nullCount ) {
89+ public clone < R extends T > ( type : R , length = this . length , offset = this . offset , nullCount = this . _nullCount ) {
9490 return new BaseData ( type , length , offset , nullCount ) ;
9591 }
9692 public slice ( offset : number , length : number ) {
9793 return length <= 0 ? this : this . sliceInternal ( this . clone (
98- this . _type , length , this . _offset + offset , + ( this . _nullCount === 0 ) - 1
94+ this . type , length , this . offset + offset , + ( this . _nullCount === 0 ) - 1
9995 ) as any , offset , length ) ;
10096 }
10197 protected sliceInternal ( clone : this, offset : number , length : number ) {
@@ -125,8 +121,8 @@ export class FlatData<T extends FlatType> extends BaseData<T> {
125121 this [ VectorType . DATA ] = toTypedArray ( this . ArrayType , data ) ;
126122 this [ VectorType . VALIDITY ] = toTypedArray ( Uint8Array , nullBitmap ) ;
127123 }
128- public get ArrayType ( ) : T [ 'ArrayType' ] { return this . _type . ArrayType ; }
129- public clone < R extends T > ( type : R , length = this . _length , offset = this . _offset , nullCount = this . _nullCount ) {
124+ public get ArrayType ( ) : T [ 'ArrayType' ] { return this . type . ArrayType ; }
125+ public clone < R extends T > ( type : R , length = this . length , offset = this . offset , nullCount = this . _nullCount ) {
130126 return new ( this . constructor as any ) ( type , length , this [ VectorType . VALIDITY ] , this [ VectorType . DATA ] , offset , nullCount ) as FlatData < R > ;
131127 }
132128}
@@ -145,7 +141,7 @@ export class FlatListData<T extends FlatListType> extends FlatData<T> {
145141 super ( type , length , nullBitmap , data , offset , nullCount ) ;
146142 this [ VectorType . OFFSET ] = toTypedArray ( Int32Array , valueOffsets ) ;
147143 }
148- public clone < R extends T > ( type : R , length = this . _length , offset = this . _offset , nullCount = this . _nullCount ) {
144+ public clone < R extends T > ( type : R , length = this . length , offset = this . offset , nullCount = this . _nullCount ) {
149145 return new FlatListData ( type , length , this [ VectorType . VALIDITY ] , this [ VectorType . OFFSET ] , this [ VectorType . DATA ] , offset , nullCount ) ;
150146 }
151147}
@@ -159,19 +155,19 @@ export class DictionaryData<T extends DataType> extends BaseData<Dictionary<T>>
159155 super ( type , indicies . length , ( indicies as any ) . _nullCount ) ;
160156 this . _indicies = indicies ;
161157 this . _dictionary = dictionary ;
158+ this . length = this . _indicies . length ;
162159 }
163- public get length ( ) { return this . _indicies . length ; }
164160 public get nullCount ( ) { return this . _indicies . nullCount ; }
165- public clone < R extends Dictionary < T > > ( type : R , length = this . _length , offset = this . _offset ) {
161+ public clone < R extends Dictionary < T > > ( type : R , length = this . length , offset = this . offset ) {
166162 const data = this . _dictionary . data . clone ( type . dictionary as any ) ;
167163 return new DictionaryData < R > (
168- this . _type as any ,
164+ this . type as any ,
169165 this . _dictionary . clone ( data ) as any ,
170- this . _indicies . slice ( offset - this . _offset , length )
166+ this . _indicies . slice ( offset - this . offset , length )
171167 ) as any ;
172168 }
173169 protected sliceInternal ( clone : this, _offset : number , _length : number ) {
174- clone . _length = clone . _indicies . length ;
170+ clone . length = clone . _indicies . length ;
175171 clone . _nullCount = ( clone . _indicies as any ) . _nullCount ;
176172 return clone ;
177173 }
@@ -181,15 +177,15 @@ export class NestedData<T extends NestedType = NestedType> extends BaseData<T> {
181177 public /*[VectorType.VALIDITY]:*/ 2 : Uint8Array ;
182178 constructor ( type : T , length : number , nullBitmap : Uint8Array | null | undefined , childData : Data < any > [ ] , offset ?: number , nullCount ?: number ) {
183179 super ( type , length , offset , nullCount ) ;
184- this . _childData = childData ;
180+ this . childData = childData ;
185181 this [ VectorType . VALIDITY ] = toTypedArray ( Uint8Array , nullBitmap ) ;
186182 }
187- public clone < R extends T > ( type : R , length = this . _length , offset = this . _offset , nullCount = this . _nullCount ) {
188- return new NestedData < R > ( type , length , this [ VectorType . VALIDITY ] , this . _childData , offset , nullCount ) ;
183+ public clone < R extends T > ( type : R , length = this . length , offset = this . offset , nullCount = this . _nullCount ) {
184+ return new NestedData < R > ( type , length , this [ VectorType . VALIDITY ] , this . childData , offset , nullCount ) ;
189185 }
190186 protected sliceInternal ( clone : this, offset : number , length : number ) {
191187 if ( ! this [ VectorType . OFFSET ] ) {
192- clone . _childData = this . _childData . map ( ( child ) => child . slice ( offset , length ) ) ;
188+ clone . childData = this . childData . map ( ( child ) => child . slice ( offset , length ) ) ;
193189 }
194190 return super . sliceInternal ( clone , offset , length ) ;
195191 }
@@ -212,7 +208,7 @@ export class ListData<T extends ListType> extends SingleNestedData<T> {
212208 super ( type , length , nullBitmap , valueChildData , offset , nullCount ) ;
213209 this [ VectorType . OFFSET ] = toTypedArray ( Int32Array , valueOffsets ) ;
214210 }
215- public clone < R extends T > ( type : R , length = this . _length , offset = this . _offset , nullCount = this . _nullCount ) {
211+ public clone < R extends T > ( type : R , length = this . length , offset = this . offset , nullCount = this . _nullCount ) {
216212 return new ListData < R > ( type , length , this [ VectorType . VALIDITY ] , this [ VectorType . OFFSET ] , this . _valuesData as any , offset , nullCount ) ;
217213 }
218214}
@@ -224,22 +220,22 @@ export class UnionData<T extends (DenseUnion | SparseUnion) = any> extends Neste
224220 super ( type , length , nullBitmap , childData , offset , nullCount ) ;
225221 this [ VectorType . TYPE ] = toTypedArray ( Int8Array , typeIds ) ;
226222 }
227- public clone < R extends T > ( type : R , length = this . _length , offset = this . _offset , nullCount = this . _nullCount ) {
228- return new UnionData < R > ( type , length , this [ VectorType . VALIDITY ] , this [ VectorType . TYPE ] , this . _childData , offset , nullCount ) ;
223+ public clone < R extends T > ( type : R , length = this . length , offset = this . offset , nullCount = this . _nullCount ) {
224+ return new UnionData < R > ( type , length , this [ VectorType . VALIDITY ] , this [ VectorType . TYPE ] , this . childData , offset , nullCount ) ;
229225 }
230226}
231227
232228export class SparseUnionData extends UnionData < SparseUnion > {
233229 constructor ( type : SparseUnion , length : number , nullBitmap : Uint8Array | null | undefined , typeIds : Iterable < number > , childData : Data < any > [ ] , offset ?: number , nullCount ?: number ) {
234230 super ( type , length , nullBitmap , typeIds , childData , offset , nullCount ) ;
235231 }
236- public clone < R extends SparseUnion > ( type : R , length = this . _length , offset = this . _offset , nullCount = this . _nullCount ) {
232+ public clone < R extends SparseUnion > ( type : R , length = this . length , offset = this . offset , nullCount = this . _nullCount ) {
237233 return new SparseUnionData (
238234 type ,
239235 length ,
240236 this [ VectorType . VALIDITY ] ,
241237 this [ VectorType . TYPE ] ,
242- this . _childData ,
238+ this . childData ,
243239 offset , nullCount
244240 ) as any as UnionData < R > ;
245241 }
@@ -252,50 +248,52 @@ export class DenseUnionData extends UnionData<DenseUnion> {
252248 super ( type , length , nullBitmap , typeIds , childData , offset , nullCount ) ;
253249 this [ VectorType . OFFSET ] = toTypedArray ( Int32Array , valueOffsets ) ;
254250 }
255- public clone < R extends DenseUnion > ( type : R , length = this . _length , offset = this . _offset , nullCount = this . _nullCount ) {
251+ public clone < R extends DenseUnion > ( type : R , length = this . length , offset = this . offset , nullCount = this . _nullCount ) {
256252 return new DenseUnionData (
257253 type ,
258254 length ,
259255 this [ VectorType . VALIDITY ] ,
260256 this [ VectorType . TYPE ] ,
261257 this [ VectorType . OFFSET ] ,
262- this . _childData ,
258+ this . childData ,
263259 offset , nullCount
264260 ) as any as UnionData < R > ;
265261 }
266262}
267263
268264export class ChunkedData < T extends DataType > extends BaseData < T > {
269- protected _childVectors : Vector < T > [ ] ;
270- protected _childOffsets : Uint32Array ;
271- public get childVectors ( ) { return this . _childVectors ; }
272- public get childOffsets ( ) { return this . _childOffsets ; }
273- public get childData ( ) {
274- return this . _childData || (
275- this . _childData = this . _childVectors . map ( ( { data } ) => data ) ) ;
276- }
277- constructor ( type : T , length : number , childVectors : Vector < T > [ ] , offset ?: number , nullCount ?: number , childOffsets ?: Uint32Array ) {
265+ // @ts -ignore
266+ protected _chunkData : Data < T > [ ] ;
267+ protected _chunkVectors : Vector < T > [ ] ;
268+ protected _chunkOffsets : Uint32Array ;
269+ public get chunkVectors ( ) { return this . _chunkVectors ; }
270+ public get chunkOffsets ( ) { return this . _chunkOffsets ; }
271+ public get chunkData ( ) {
272+ return this . _chunkData || (
273+ this . _chunkData = this . _chunkVectors . map ( ( { data } ) => data ) ) ;
274+ }
275+ constructor ( type : T , length : number , chunkVectors : Vector < T > [ ] , offset ?: number , nullCount ?: number , chunkOffsets ?: Uint32Array ) {
278276 super ( type , length , offset , nullCount ) ;
279- this . _childVectors = childVectors ;
280- this . _childOffsets = childOffsets || ChunkedData . computeOffsets ( childVectors ) ;
277+ this . _chunkVectors = chunkVectors ;
278+ this . _chunkOffsets = chunkOffsets || ChunkedData . computeOffsets ( chunkVectors ) ;
281279 }
282280 public get nullCount ( ) {
283281 let nullCount = this . _nullCount ;
284282 if ( nullCount === - 1 ) {
285- this . _nullCount = nullCount = this . _childVectors . reduce ( ( x , c ) => x + c . nullCount , 0 ) ;
283+ this . _nullCount = nullCount = this . _chunkVectors . reduce ( ( x , c ) => x + c . nullCount , 0 ) ;
286284 }
287285 return nullCount ;
288286 }
289- public clone < R extends T > ( type : R , length = this . _length , offset = this . _offset , nullCount = this . _nullCount ) {
287+ public clone < R extends T > ( type : R , length = this . length , offset = this . offset , nullCount = this . _nullCount ) {
290288 return new ChunkedData < R > (
291289 type , length ,
292- this . _childVectors . map ( ( vec ) => vec . clone ( vec . data . clone ( type ) ) ) as any ,
293- offset , nullCount , this . _childOffsets
290+ this . _chunkVectors . map ( ( vec ) => vec . clone ( vec . data . clone ( type ) ) ) as any ,
291+ offset , nullCount , this . _chunkOffsets
294292 ) ;
295293 }
296294 protected sliceInternal ( clone : this, offset : number , length : number ) {
297- const chunks = this . _childVectors ;
298- const offsets = this . _childOffsets ;
295+ const chunks = this . _chunkVectors ;
296+ const offsets = this . _chunkOffsets ;
299297 const chunkSlices : Vector < T > [ ] = [ ] ;
300298 for ( let childIndex = - 1 , numChildren = chunks . length ; ++ childIndex < numChildren ; ) {
301299 const child = chunks [ childIndex ] ;
@@ -315,8 +313,8 @@ export class ChunkedData<T extends DataType> extends BaseData<T> {
315313 const end = begin + Math . min ( childLength - begin , ( offset + length ) - childOffset ) ;
316314 chunkSlices . push ( child . slice ( begin , end ) ) ;
317315 }
318- clone . _childVectors = chunkSlices ;
319- clone . _childOffsets = ChunkedData . computeOffsets ( chunkSlices ) ;
316+ clone . _chunkVectors = chunkSlices ;
317+ clone . _chunkOffsets = ChunkedData . computeOffsets ( chunkSlices ) ;
320318 return clone ;
321319 }
322320 static computeOffsets < T extends DataType > ( childVectors : Vector < T > [ ] ) {
0 commit comments