tech.v3.datatype.mmap-writer

Provides the ability to efficiently write binary data to a file with an automatic conversion to a native-buffer using mmap.

Endianness can be provided and strings are automatically saved as UTF-8.

mmap-writer

(mmap-writer fpath {:keys [endianness resource-type mmap-file-options open-options file-channel delete-on-close?], :or {resource-type :auto, endianness (dtype-proto/platform-endianness), open-options :append}, :as _options})(mmap-writer fpath)

Create a new data writer that has a conversion to a mmaped native buffer upon ->buffer or ->reader. Object metadata is passed to the mmap-file method so users can specify how the new file should interact with the resource system.

Binary data will be encoded to bytes using the endianness provided in the options. Strings are encoded to UTF-8 but may not be zero terminated!!.

Options:

  • :file-channel - Provide your own file channel. Else one is created via fpath and open-options.
  • :endianness - defaults to platform endianness, either :little-endian or :big-endian.
  • :open-options - defaults to :overwrite - either :overwrite or :append.
  • :resource-type - defaults to :auto, one of the tech.v3.resource/track track-type options.
  • :mmap-file-options - options to pass to mmap-file.
  • :delete-on-close? - defaults to false - When true, the file is deleted upon close.

path

(path mmap-writer)

Get the path used for a particular mmap-writer

temp-mmap-writer

(temp-mmap-writer {:keys [temp-dir suffix delete-on-close?], :or {temp-dir (System/getProperty "java.io.tmpdir"), suffix "", delete-on-close? true}, :as options})(temp-mmap-writer)

Create a temporary mmap writer.

Options -- See options for mmap-writer. In addition:

  • :delete-on-close - defaults to true.
  • :temp-dir - Temporary directory. Defaults to the system property "java.io.tmpdir".
  • :suffix - Suffix to use to create the file. Defaults to nothing.