18
18
import { Data } from '../data' ;
19
19
import { View } from '../vector' ;
20
20
import { getBool , setBool , iterateBits } from '../util/bit' ;
21
- import { Bool , Float16 , Date_ , Interval , Null , Int32 } from '../type' ;
21
+ import { Bool , Float16 , Date_ , Interval , Null , Int32 , Timestamp } from '../type' ;
22
22
import { DataType , FlatType , PrimitiveType , IterableArrayLike } from '../type' ;
23
23
24
24
export class FlatView < T extends FlatType > implements View < T > {
25
- // @ts -ignore
26
25
public length : number ;
27
- // @ts -ignore
28
26
public values : T [ 'TArray' ] ;
29
27
constructor ( data : Data < T > ) {
30
28
this . length = data . length ;
@@ -51,7 +49,6 @@ export class FlatView<T extends FlatType> implements View<T> {
51
49
}
52
50
53
51
export class NullView implements View < Null > {
54
- // @ts -ignore
55
52
public length : number ;
56
53
constructor ( data : Data < Null > ) {
57
54
this . length = data . length ;
@@ -75,7 +72,6 @@ export class NullView implements View<Null> {
75
72
}
76
73
77
74
export class BoolView extends FlatView < Bool > {
78
- // @ts -ignore
79
75
protected offset : number ;
80
76
constructor ( data : Data < Bool > ) {
81
77
super ( data ) ;
@@ -96,11 +92,8 @@ export class BoolView extends FlatView<Bool> {
96
92
97
93
export class ValidityView < T extends DataType > implements View < T > {
98
94
protected view : View < T > ;
99
- // @ts -ignore
100
95
protected length : number ;
101
- // @ts -ignore
102
96
protected offset : number ;
103
- // @ts -ignore
104
97
protected nullBitmap : Uint8Array ;
105
98
constructor ( data : Data < T > , view : View < T > ) {
106
99
this . view = view ;
@@ -136,9 +129,7 @@ export class ValidityView<T extends DataType> implements View<T> {
136
129
}
137
130
138
131
export class PrimitiveView < T extends PrimitiveType > extends FlatView < T > {
139
- // @ts -ignore
140
132
public size : number ;
141
- // @ts -ignore
142
133
public ArrayType : T [ 'ArrayType' ] ;
143
134
constructor ( data : Data < T > , size ?: number ) {
144
135
super ( data ) ;
@@ -216,6 +207,59 @@ export class DateMillisecondView extends FixedSizeView<Date_> {
216
207
}
217
208
}
218
209
210
+ export class TimestampDayView extends PrimitiveView < Timestamp > {
211
+ public toArray ( ) { return [ ...this ] ; }
212
+ protected getValue ( values : Int32Array , index : number , size : number ) : number {
213
+ return epochDaysToMs ( values , index * size ) ;
214
+ }
215
+ protected setValue ( values : Int32Array , index : number , size : number , epochMs : number ) : void {
216
+ values [ index * size ] = ( epochMs / 86400000 ) | 0 ;
217
+ }
218
+ }
219
+
220
+ export class TimestampSecondView extends PrimitiveView < Timestamp > {
221
+ public toArray ( ) { return [ ...this ] ; }
222
+ protected getValue ( values : Int32Array , index : number , size : number ) : number {
223
+ return epochSecondsToMs ( values , index * size ) ;
224
+ }
225
+ protected setValue ( values : Int32Array , index : number , size : number , epochMs : number ) : void {
226
+ values [ index * size ] = ( epochMs / 1000 ) | 0 ;
227
+ }
228
+ }
229
+
230
+ export class TimestampMillisecondView extends PrimitiveView < Timestamp > {
231
+ public toArray ( ) { return [ ...this ] ; }
232
+ protected getValue ( values : Int32Array , index : number , size : number ) : number {
233
+ return epochMillisecondsLongToMs ( values , index * size ) ;
234
+ }
235
+ protected setValue ( values : Int32Array , index : number , size : number , epochMs : number ) : void {
236
+ values [ index * size ] = ( epochMs % 4294967296 ) | 0 ;
237
+ values [ index * size + size ] = ( epochMs / 4294967296 ) | 0 ;
238
+ }
239
+ }
240
+
241
+ export class TimestampMicrosecondView extends PrimitiveView < Timestamp > {
242
+ public toArray ( ) { return [ ...this ] ; }
243
+ protected getValue ( values : Int32Array , index : number , size : number ) : number {
244
+ return epochMicrosecondsLongToMs ( values , index * size ) ;
245
+ }
246
+ protected setValue ( values : Int32Array , index : number , size : number , epochMs : number ) : void {
247
+ values [ index * size ] = ( ( epochMs / 1000 ) % 4294967296 ) | 0 ;
248
+ values [ index * size + size ] = ( ( epochMs / 1000 ) / 4294967296 ) | 0 ;
249
+ }
250
+ }
251
+
252
+ export class TimestampNanosecondView extends PrimitiveView < Timestamp > {
253
+ public toArray ( ) { return [ ...this ] ; }
254
+ protected getValue ( values : Int32Array , index : number , size : number ) : number {
255
+ return epochNanosecondsLongToMs ( values , index * size ) ;
256
+ }
257
+ protected setValue ( values : Int32Array , index : number , size : number , epochMs : number ) : void {
258
+ values [ index * size ] = ( ( epochMs / 1000000 ) % 4294967296 ) | 0 ;
259
+ values [ index * size + size ] = ( ( epochMs / 1000000 ) / 4294967296 ) | 0 ;
260
+ }
261
+ }
262
+
219
263
export class IntervalYearMonthView extends PrimitiveView < Interval > {
220
264
public toArray ( ) { return [ ...this ] ; }
221
265
protected getValue ( values : Int32Array , index : number , size : number ) : Int32Array {
0 commit comments