@@ -131,37 +131,6 @@ impl FFI_ArrowArray {
131
131
data. buffers ( ) . iter ( ) . map ( |b| Some ( b. clone ( ) ) ) . collect ( )
132
132
} ;
133
133
134
- // Handle buffer offset for offset buffer.
135
- let offset_offset = match data. data_type ( ) {
136
- DataType :: Utf8 | DataType :: Binary => {
137
- // Offset buffer is possible a slice of the buffer.
138
- // If we use slice pointer as exported buffer pointer, it will cause
139
- // the consumer to calculate incorrect length of data buffer (buffer 1).
140
- // We need to get the offset of the offset buffer and fill it in
141
- // the `FFI_ArrowArray` offset field.
142
- Some ( data. buffers ( ) [ 0 ] . ptr_offset ( ) / std:: mem:: size_of :: < i32 > ( ) )
143
- }
144
- DataType :: LargeUtf8 | DataType :: LargeBinary => {
145
- // Offset buffer is possible a slice of the buffer.
146
- // If we use slice pointer as exported buffer pointer, it will cause
147
- // the consumer to calculate incorrect length of data buffer (buffer 1).
148
- // We need to get the offset of the offset buffer and fill it in
149
- // the `FFI_ArrowArray` offset field.
150
- Some ( data. buffers ( ) [ 0 ] . ptr_offset ( ) / std:: mem:: size_of :: < i64 > ( ) )
151
- }
152
- _ => None ,
153
- } ;
154
-
155
- let offset = if let Some ( offset) = offset_offset {
156
- if data. offset ( ) != 0 {
157
- // TODO: Adjust for data offset
158
- panic ! ( "The ArrayData of a slice offset buffer should not have offset" ) ;
159
- }
160
- offset
161
- } else {
162
- data. offset ( )
163
- } ;
164
-
165
134
// `n_buffers` is the number of buffers by the spec.
166
135
let n_buffers = {
167
136
data_layout. buffers . len ( ) + {
@@ -174,25 +143,9 @@ impl FFI_ArrowArray {
174
143
175
144
let buffers_ptr = buffers
176
145
. iter ( )
177
- . enumerate ( )
178
- . flat_map ( |( buffer_idx, maybe_buffer) | match maybe_buffer {
179
- Some ( b) => {
180
- match ( data. data_type ( ) , buffer_idx) {
181
- (
182
- DataType :: Utf8
183
- | DataType :: LargeUtf8
184
- | DataType :: Binary
185
- | DataType :: LargeBinary ,
186
- 1 ,
187
- ) => {
188
- // For offset buffer, take original pointer without offset.
189
- // Buffer offset should be handled by `FFI_ArrowArray` offset field.
190
- Some ( b. data_ptr ( ) . as_ptr ( ) as * const c_void )
191
- }
192
- // For other buffers, note that `raw_data` takes into account the buffer's offset
193
- _ => Some ( b. as_ptr ( ) as * const c_void ) ,
194
- }
195
- }
146
+ . flat_map ( |maybe_buffer| match maybe_buffer {
147
+ // note that `raw_data` takes into account the buffer's offset
148
+ Some ( b) => Some ( b. as_ptr ( ) as * const c_void ) ,
196
149
// This is for null buffer. We only put a null pointer for
197
150
// null buffer if by spec it can contain null mask.
198
151
None if data_layout. can_contain_null_mask => Some ( std:: ptr:: null ( ) ) ,
@@ -233,7 +186,7 @@ impl FFI_ArrowArray {
233
186
Self {
234
187
length : data. len ( ) as i64 ,
235
188
null_count : null_count as i64 ,
236
- offset : offset as i64 ,
189
+ offset : data . offset ( ) as i64 ,
237
190
n_buffers,
238
191
n_children,
239
192
buffers : private_data. buffers_ptr . as_mut_ptr ( ) ,
0 commit comments