class_docstr: Shuffles and writes Examples to Arrow files.
class_docstr_tok: ["Shuffles","and","writes","Examples","to","Arrow","files","."]
docstr: Write stored examples from the write-pool of examples. It makes a table out of the examples and write it.
docstr_tok: ["Write","stored","examples","from","the","write-pool","of","examples",".","It","makes","a","table","out","of","the","examples","and","write","it","."]
code: def write_examples_on_file(self):
      """Write stored examples from the write-pool of examples. It makes a table out of the examples and write it."""
      if not self.current_examples:
          return
  
      # order the columns properly
      cols = (
          [
              col
              for col in self.schema.names
              if col in self.current_examples[0][0]
          ]
          + [
              col
              for col in self.current_examples[0][0].keys()
              if col not in self.schema.names
          ]
          if self.schema
          else self.current_examples[0][0].keys()
      )
      batch_examples = {}
      for col in cols:
          # We use row[0][col] since current_examples contains (example, key) tuples.
          # Morever, examples could be Arrow arrays of 1 element.
          # This can happen in `.map()` when we want to re-write the same Arrow data
          if all(
              isinstance(row[0][col], (pa.Array, pa.ChunkedArray))
              for row in self.current_examples
          ):
              arrays = [row[0][col] for row in self.current_examples]
              batch_examples[col] = array_concat(arrays)
          else:
              batch_examples[col] = [
                  row[0][col].to_pylist()[0]
                  if isinstance(
                      row[0][col], (pa.Array, pa.ChunkedArray)
                  )
                  else row[0][col]
                  for row in self.current_examples
              ]
      self.write_batch(batch_examples=batch_examples)
      self.current_examples = []
  
imports: import errno
  import json
  import os
  import sys
  from pathlib import Path
  from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
  import fsspec
  import numpy
  import pyarrow
  import pyarrow.parquet
  from .None import config
  from .features import Features, Image, Value
  from .features.features import FeatureType, _ArrayXDExtensionType, cast_to_python_objects, generate_from_arrow_type, get_nested_type, list_of_np_array_to_pyarrow_listarray, numpy_to_pyarrow_listarray, to_pyarrow_listarray
  from .filesystems import is_remote_filesystem
  from .info import DatasetInfo
  from .keyhash import DuplicatedKeysError, KeyHasher
  from .table import array_cast, array_concat, cast_array_to_feature, embed_table_storage, table_cast
  from .utils import logging
  from .utils import tqdm
  from .utils.file_utils import hash_url_to_filename
  from .utils.py_utils import asdict, first_non_null_value
label_desc: Use image node_id 9 for calling the ArrowWriter obj's underlying member method code with example usage: obj.write_examples_on_file() without return types