jina.types.arrays.mixins.io.common module

class jina.types.arrays.mixins.io.common.CommonIOMixin[source]

Bases: object

The common IO helper function for arrays.

save(file, file_format='json')[source]

Save array elements into a JSON, a binary file or a CSV file.

Parameters
  • file (Union[str, TextIO, BinaryIO]) – File or filename to which the data is saved.

  • file_format (str) – json or binary or csv. JSON and CSV files are human-readable, but binary format gives much smaller size and faster save/load speed. Note that, CSV file has very limited compatability, complex DocumentArray with nested structure can not be restored from a CSV file.

Return type

None

classmethod load(file, file_format='json')[source]

Load array elements from a JSON or a binary file, or a CSV file.

Parameters
  • file (Union[str, TextIO, BinaryIO]) – File or filename to which the data is saved.

  • file_format (str) – json or binary or csv. JSON and CSV files are human-readable, but binary format gives much smaller size and faster save/load speed. CSV file has very limited compatability, complex DocumentArray with nested structure can not be restored from a CSV file.

Return type

T

Returns

the loaded DocumentArray object