def get(self):
        """Return a table with ``batch_size`` number of rows.

        :return: An instance of an Arrow table with exactly ``batch_size`` rows.
        """

        assert not self.empty()

        # head_idx points to the next row in the buffer[0] batch to be consumed.
        # Accumulate selices/full batches until result_rows reaches desired batch_size.

        # Pop left of the deque once exhausted all rows there.
        result = []
        result_rows = 0
        while result_rows < self._batch_size and self._cumulative_len > 0:
            head = self._buffer[0]
            piece = head[self._head_idx:self._head_idx + self._batch_size - result_rows]
            self._head_idx += piece.num_rows
            result_rows += piece.num_rows
            result.append(piece)

            if head.num_rows == self._head_idx:
                self._head_idx = 0
                self._buffer.popleft()
                self._cumulative_len -= head.num_rows

        return pa.Table.from_batches(result)
Return a table with ``batch_size`` number of rows.

        :return: An instance of an Arrow table with exactly ``batch_size`` rows.
        
petastorm/pyarrow_helpers/batching_table_queue.py