Save the distance metric to disk, to be reloaded with load_distance_metric_raw() and friends.
An implementation of this method should create a DISTANCE file inside dir that contains the distance metric's name. This should be an ASCII file with no newlines, where the metric name should follow the <library>::<distance> format, e.g., knncolle::Euclidean. This will be used by load_distance_metric_raw() to determine the exact loader function to call.
Other than the DISTANCE file, each implementation may create any number of additional files of any format in dir. We recommend that the name of each file/directory immediately starts with an upper case letter and is in all-capitals. This allows applications to add more custom files without the risk of conflicts, e.g., by naming them without an upper-case letter.
An implementation of this method is not required to use portable file formats. load_distance_metric_raw() is only expected to work on the same system (i.e., architecture, compiler, compilation settings) that was used for the save() call. Any additional portability is at the discretion of the implementation, e.g., it is common to assume IEEE floating-point and two's-complement integers.
An implementation of this method is not required to create files that are readable by different versions of the implementation. Thus, the files created by this method are generally unsuitable for archival storage. However, implementations are recommended to at least provide enough information to throw an exception if an incompatible version of load_distance_metric_raw() is used.
If a subclass does not implement this method, an error is thrown by default.
- Parameters
-
| dir | Path to a directory in which to save the index. This should already exist. |