@@ -148,20 +148,6 @@ def fast_slice(self, offset=0, length=None) -> pa.Table:
148148 return pa .Table .from_batches (batches , schema = self ._schema )
149149
150150
151- class _RecordBatchReader :
152- def __init__ (self , table : "Table" , max_chunksize : Optional [int ] = None ):
153- self .table = table
154- self .max_chunksize = max_chunksize
155-
156- def __iter__ (self ):
157- for batch in self .table ._batches :
158- if self .max_chunksize is None or len (batch ) <= self .max_chunksize :
159- yield batch
160- else :
161- for offset in range (0 , len (batch ), self .max_chunksize ):
162- yield batch .slice (offset , self .max_chunksize )
163-
164-
165151class Table (IndexedTableMixin ):
166152 """
167153 Wraps a pyarrow Table by using composition.
@@ -359,10 +345,8 @@ def to_reader(self, max_chunksize: Optional[int] = None):
359345 on the chunk layout of individual columns.
360346
361347 Returns:
362- `pyarrow.RecordBatchReader` if pyarrow>=8.0.0, otherwise a `pyarrow.RecordBatch` iterable
348+ `pyarrow.RecordBatchReader`
363349 """
364- if config .PYARROW_VERSION .major < 8 :
365- return _RecordBatchReader (self , max_chunksize = max_chunksize )
366350 return self .table .to_reader (max_chunksize = max_chunksize )
367351
368352 def field (self , * args , ** kwargs ):
@@ -816,11 +800,7 @@ def from_pylist(cls, mapping, *args, **kwargs):
816800 Returns:
817801 `datasets.table.Table`
818802 """
819- try :
820- return cls (pa .Table .from_pylist (mapping , * args , ** kwargs ))
821- except AttributeError : # pyarrow <7 does not have from_pylist, so we convert and use from_pydict
822- mapping = {k : [r .get (k ) for r in mapping ] for k in mapping [0 ]} if mapping else {}
823- return cls (pa .Table .from_pydict (mapping , * args , ** kwargs ))
803+ return cls (pa .Table .from_pylist (mapping , * args , ** kwargs ))
824804
825805 @classmethod
826806 def from_batches (cls , * args , ** kwargs ):
0 commit comments