1
1
use std:: collections:: HashSet ;
2
- use std:: sync:: { Arc , LazyLock } ;
2
+ use std:: sync:: Arc ;
3
3
4
4
use arrow_array:: cast:: AsArray ;
5
5
use arrow_array:: types:: Int64Type ;
@@ -14,7 +14,6 @@ use delta_kernel::engine::arrow_data::ArrowEngineData;
14
14
use delta_kernel:: engine:: arrow_expression:: ProvidesColumnByName ;
15
15
use delta_kernel:: engine_data:: { GetData , RowVisitor } ;
16
16
use delta_kernel:: expressions:: { Scalar , StructData } ;
17
- use delta_kernel:: scan:: scan_row_schema;
18
17
19
18
use crate :: kernel:: scalars:: ScalarExt ;
20
19
use crate :: { DeltaResult , DeltaTableError } ;
@@ -202,23 +201,6 @@ impl LogicalFileView {
202
201
}
203
202
}
204
203
205
- impl Iterator for LogicalFileView {
206
- type Item = LogicalFileView ;
207
-
208
- fn next ( & mut self ) -> Option < Self :: Item > {
209
- if self . index < self . files . num_rows ( ) {
210
- let file = LogicalFileView {
211
- files : self . files . clone ( ) ,
212
- index : self . index ,
213
- } ;
214
- self . index += 1 ;
215
- Some ( file)
216
- } else {
217
- None
218
- }
219
- }
220
- }
221
-
222
204
pub struct LogicalFileViewIterator < I >
223
205
where
224
206
I : IntoIterator < Item = Result < RecordBatch , DeltaTableError > > ,
@@ -244,43 +226,43 @@ where
244
226
}
245
227
}
246
228
247
- // impl<I> Iterator for LogicalFileViewIterator<I>
248
- // where
249
- // I: IntoIterator<Item = DeltaResult<RecordBatch>>,
250
- // {
251
- // type Item = DeltaResult<LogicalFileView>;
252
- //
253
- // fn next(&mut self) -> Option<Self::Item> {
254
- // if let Some(batch) = &self.batch {
255
- // if self.current < batch.num_rows() {
256
- // let item = LogicalFileView {
257
- // files: batch.clone(),
258
- // index: self.current,
259
- // };
260
- // self.current += 1;
261
- // return Some(Ok(item));
262
- // }
263
- // }
264
- // match self.inner.next() {
265
- // Some(Ok(batch)) => {
266
- // if validate_logical_file(&batch).is_err() {
267
- // return Some(Err(DeltaTableError::generic(
268
- // "Invalid logical file data encountered.",
269
- // )));
270
- // }
271
- // self.batch = Some(batch);
272
- // self.current = 0;
273
- // self.next()
274
- // }
275
- // Some(Err(e)) => Some(Err(e)),
276
- // None => None,
277
- // }
278
- // }
279
- //
280
- // fn size_hint(&self) -> (usize, Option<usize>) {
281
- // self.inner.size_hint()
282
- // }
283
- // }
229
+ impl < I > Iterator for LogicalFileViewIterator < I >
230
+ where
231
+ I : IntoIterator < Item = DeltaResult < RecordBatch > > ,
232
+ {
233
+ type Item = DeltaResult < LogicalFileView > ;
234
+
235
+ fn next ( & mut self ) -> Option < Self :: Item > {
236
+ if let Some ( batch) = & self . batch {
237
+ if self . current < batch. num_rows ( ) {
238
+ let item = LogicalFileView {
239
+ files : batch. clone ( ) ,
240
+ index : self . current ,
241
+ } ;
242
+ self . current += 1 ;
243
+ return Some ( Ok ( item) ) ;
244
+ }
245
+ }
246
+ match self . inner . next ( ) {
247
+ Some ( Ok ( batch) ) => {
248
+ if validate_logical_file ( & batch) . is_err ( ) {
249
+ return Some ( Err ( DeltaTableError :: generic (
250
+ "Invalid logical file data encountered." ,
251
+ ) ) ) ;
252
+ }
253
+ self . batch = Some ( batch) ;
254
+ self . current = 0 ;
255
+ self . next ( )
256
+ }
257
+ Some ( Err ( e) ) => Some ( Err ( e) ) ,
258
+ None => None ,
259
+ }
260
+ }
261
+
262
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
263
+ self . inner . size_hint ( )
264
+ }
265
+ }
284
266
285
267
pub struct AddViewIterator < I >
286
268
where
@@ -353,6 +335,15 @@ pub(crate) fn validate_add(batch: &RecordBatch) -> DeltaResult<()> {
353
335
Ok ( ( ) )
354
336
}
355
337
338
+ fn validate_logical_file ( batch : & RecordBatch ) -> DeltaResult < ( ) > {
339
+ validate_column :: < StringArray > ( batch, & [ "path" ] ) ?;
340
+ validate_column :: < Int64Array > ( batch, & [ "size" ] ) ?;
341
+ validate_column :: < Int64Array > ( batch, & [ "modificationTime" ] ) ?;
342
+ // validate_column::<StructArray>(batch, &["deletionVector"])?;
343
+ // validate_column::<StructArray>(batch, &["fileConstantValues"])?;
344
+ Ok ( ( ) )
345
+ }
346
+
356
347
fn validate_column < ' a , T : Array + ' static > (
357
348
actions : & ' a RecordBatch ,
358
349
col : & ' a [ impl AsRef < str > ] ,
0 commit comments