|
18 | 18 | import { Data } from '../data'; |
19 | 19 | import { View } from '../vector'; |
20 | 20 | import { getBool, setBool, iterateBits } from '../util/bit'; |
| 21 | +import { FlatType, PrimitiveType, IterableArrayLike } from '../type'; |
21 | 22 | import { Bool, Float16, Date_, Interval, Null, Int32, Timestamp } from '../type'; |
22 | | -import { DataType, FlatType, PrimitiveType, IterableArrayLike } from '../type'; |
23 | 23 |
|
24 | 24 | export class FlatView<T extends FlatType> implements View<T> { |
25 | 25 | public length: number; |
@@ -103,53 +103,6 @@ export class BoolView extends FlatView<Bool> { |
103 | 103 | } |
104 | 104 | } |
105 | 105 |
|
106 | | -export class ValidityView<T extends DataType> implements View<T> { |
107 | | - protected view: View<T>; |
108 | | - protected length: number; |
109 | | - protected offset: number; |
110 | | - protected nullBitmap: Uint8Array; |
111 | | - constructor(data: Data<T>, view: View<T>) { |
112 | | - this.view = view; |
113 | | - this.length = data.length; |
114 | | - this.offset = data.offset; |
115 | | - this.nullBitmap = data.nullBitmap!; |
116 | | - } |
117 | | - public clone(data: Data<T>): this { |
118 | | - return new ValidityView(data, this.view.clone(data)) as this; |
119 | | - } |
120 | | - public toArray(): IterableArrayLike<T['TValue'] | null> { |
121 | | - return [...this]; |
122 | | - } |
123 | | - public indexOf(search: T['TValue']) { |
124 | | - let index = 0; |
125 | | - for (let value of this) { |
126 | | - if (value === search) { return index; } |
127 | | - ++index; |
128 | | - } |
129 | | - |
130 | | - return -1; |
131 | | - } |
132 | | - public isValid(index: number): boolean { |
133 | | - const nullBitIndex = this.offset + index; |
134 | | - return getBool(null, index, this.nullBitmap[nullBitIndex >> 3], nullBitIndex % 8); |
135 | | - } |
136 | | - public get(index: number): T['TValue'] | null { |
137 | | - const nullBitIndex = this.offset + index; |
138 | | - return this.getNullable(this.view, index, this.nullBitmap[nullBitIndex >> 3], nullBitIndex % 8); |
139 | | - } |
140 | | - public set(index: number, value: T['TValue'] | null): void { |
141 | | - if (setBool(this.nullBitmap, this.offset + index, value != null)) { |
142 | | - this.view.set(index, value); |
143 | | - } |
144 | | - } |
145 | | - public [Symbol.iterator](): IterableIterator<T['TValue'] | null> { |
146 | | - return iterateBits<T['TValue'] | null>(this.nullBitmap, this.offset, this.length, this.view, this.getNullable); |
147 | | - } |
148 | | - protected getNullable(view: View<T>, index: number, byte: number, bit: number) { |
149 | | - return getBool(view, index, byte, bit) ? view.get(index) : null; |
150 | | - } |
151 | | -} |
152 | | - |
153 | 106 | export class PrimitiveView<T extends PrimitiveType> extends FlatView<T> { |
154 | 107 | public size: number; |
155 | 108 | public ArrayType: T['ArrayType']; |
|
0 commit comments