@@ -70,14 +70,18 @@ public struct ArrowArrayBoolean: ArrowArrayProtocol {
7070}
7171
7272/// An Arrow array of fixed-width types.
73- struct ArrowArrayFixed < T> : ArrowArrayProtocol where T: Numeric {
74- typealias ItemType = T
73+ struct ArrowArrayFixed < Element, ValueBuffer> : ArrowArrayProtocol
74+ where
75+ Element: Numeric ,
76+ ValueBuffer: FixedWidthBufferProtocol < Element >
77+ {
78+ typealias ItemType = Element
7579 let offset : Int
7680 let length : Int
7781 let nullBuffer : NullBuffer
78- let valueBuffer : FixedWidthBuffer < T >
82+ let valueBuffer : ValueBuffer
7983
80- subscript( index: Int ) -> T ? {
84+ subscript( index: Int ) -> Element ? {
8185 precondition ( index >= 0 && index < length, " Invalid index. " )
8286 let offsetIndex = self . offset + index
8387 if !self . nullBuffer. isSet ( offsetIndex) {
@@ -86,7 +90,7 @@ struct ArrowArrayFixed<T>: ArrowArrayProtocol where T: Numeric {
8690 return valueBuffer [ offsetIndex]
8791 }
8892
89- func slice( offset: Int , length: Int ) -> ArrowArrayFixed < T > {
93+ func slice( offset: Int , length: Int ) -> Self {
9094 . init(
9195 offset: offset,
9296 length: length,
@@ -97,22 +101,26 @@ struct ArrowArrayFixed<T>: ArrowArrayProtocol where T: Numeric {
97101}
98102
99103/// An Arrow array of variable-length types.
100- public struct ArrowArrayVariable < T> : ArrowArrayProtocol
101- where T: VariableLength {
102- public typealias ItemType = T
104+ public struct ArrowArrayVariable < Element, OffsetsBuffer, ValueBuffer> :
105+ ArrowArrayProtocol
106+ where
107+ Element: VariableLength ,
108+ OffsetsBuffer: FixedWidthBufferProtocol < Int32 > ,
109+ ValueBuffer: VariableLengthBufferProtocol < Element >
110+ {
111+ public typealias ItemType = Element
103112 public let offset : Int
104113 public let length : Int
105114 let nullBuffer : NullBuffer
106- let offsetsBuffer : any FixedWidthBufferProtocol < Int32 >
107- let valueBuffer : any VariableLengthBufferProtocol < T >
115+ let offsetsBuffer : OffsetsBuffer
116+ let valueBuffer : ValueBuffer
108117
109118 public init (
110119 offset: Int ,
111120 length: Int ,
112121 nullBuffer: NullBuffer ,
113- offsetsBuffer:
114- any FixedWidthBufferProtocol < Int32 > ,
115- valueBuffer: any VariableLengthBufferProtocol < T >
122+ offsetsBuffer: OffsetsBuffer ,
123+ valueBuffer: ValueBuffer
116124 ) {
117125 self . offset = offset
118126 self . length = length
@@ -121,7 +129,7 @@ where T: VariableLength {
121129 self . valueBuffer = valueBuffer
122130 }
123131
124- public subscript( index: Int ) -> T ? {
132+ public subscript( index: Int ) -> Element ? {
125133
126134 let offsetIndex = self . offset + index
127135
@@ -147,14 +155,14 @@ where T: VariableLength {
147155 }
148156}
149157
150- public typealias ArrowArrayUtf8 = ArrowArrayVariable < String >
151- public typealias ArrowArrayBinary = ArrowArrayVariable < Data >
152-
153158/// An Arrow array of `Date`s with a resolution of 1 day.
154- struct ArrowArrayDate32 : ArrowArrayProtocol {
159+ struct ArrowArrayDate32 < ValueBuffer> : ArrowArrayProtocol
160+ where
161+ ValueBuffer: FixedWidthBufferProtocol < Int32 >
162+ {
155163 typealias ItemType = Date
156164
157- let array : ArrowArrayFixed < Date32 >
165+ let array : ArrowArrayFixed < Date32 , ValueBuffer >
158166
159167 var offset : Int {
160168 array. offset
@@ -182,10 +190,13 @@ struct ArrowArrayDate32: ArrowArrayProtocol {
182190}
183191
184192/// An Arrow array of `Date`s with a resolution of 1 second.
185- struct ArrowArrayDate64 : ArrowArrayProtocol {
193+ struct ArrowArrayDate64 < ValueBuffer> : ArrowArrayProtocol
194+ where
195+ ValueBuffer: FixedWidthBufferProtocol < Int64 >
196+ {
186197 typealias ItemType = Date
187198
188- let array : ArrowArrayFixed < Date64 >
199+ let array : ArrowArrayFixed < Date64 , ValueBuffer >
189200
190201 var offset : Int {
191202 array. offset
@@ -212,17 +223,20 @@ struct ArrowArrayDate64: ArrowArrayProtocol {
212223 }
213224}
214225
215- struct ArrowListArray < T> : ArrowArrayProtocol where T: ArrowArrayProtocol {
216-
217- typealias ItemType = T
226+ /// An Arrow list array which may be nested arbitrarily.
227+ struct ArrowListArray < Element> : ArrowArrayProtocol
228+ where
229+ Element: ArrowArrayProtocol
230+ {
231+ typealias ItemType = Element
218232
219233 let offset : Int
220234 let length : Int
221235 let nullBuffer : NullBuffer
222236 let offsetsBuffer : FixedWidthBuffer < Int32 >
223- let values : T
237+ let values : Element
224238
225- subscript( index: Int ) -> T ? {
239+ subscript( index: Int ) -> Element ? {
226240 precondition ( index >= 0 && index < length, " Invalid index. " )
227241 let offsetIndex = self . offset + index
228242 if !self . nullBuffer. isSet ( offsetIndex) {
0 commit comments