Table of Contents

Method CreateFileDataSource

Namespace
LMKit.Data
Assembly
LM-Kit.NET.dll

CreateFileDataSource(string, string, LM, MetadataCollection, bool)

Creates a new file-backed DataSource instance with the specified identifier and language model. This method creates a new file at the given path and opens it with read-write access. The resulting DataSource is initially created in-memory and then associated with the backing file stream, enabling future updates to be synchronized with the file.

public static DataSource CreateFileDataSource(string path, string identifier, LM model, MetadataCollection metadata = null, bool overwrite = false)

Parameters

path string

The file path where the data source will be created. This must be a valid path and the file must not already exist.

identifier string

The unique identifier for the data source.

model LM

The language model associated with the data source.

metadata MetadataCollection

Optional metadata to be associated with the data source.

overwrite bool

If true, an existing file at path will be deleted before creating a new one. If false and the file already exists, no action is taken on the file system and creation will fail in Create(string, string, int, MetadataCollection).

Returns

DataSource

A new DataSource instance that is backed by a file.

Exceptions

ArgumentNullException

Thrown if path is null, empty, or consists solely of white-space characters.

CreateFileDataSource(string, string, int, MetadataCollection, bool)

Creates a new file-backedDataSource instance with the specified identifier and embedding size. This method creates a new file at the given path (deleting any existing file if overwrite is true) and then invokes Create(string, string, int, MetadataCollection) to initialize the in-memory data source and link it to the file.

public static DataSource CreateFileDataSource(string path, string identifier, int embeddingSize, MetadataCollection metadata = null, bool overwrite = false)

Parameters

path string

The file path where the data source will be created. Must be non-null, non-empty, and not consist solely of white-space.

identifier string

The unique identifier for the data source. Used to distinguish this source in logs and lookups.

embeddingSize int

The dimensionality of the vector embeddings stored by this data source. Must match the size expected by downstream searches.

metadata MetadataCollection

Optional MetadataCollection to associate with the data source. Pass null if no metadata is required.

overwrite bool

If true, any existing file at path will be deleted before creation. If false and the file already exists, the file is left untouched and Create(string, string, int, MetadataCollection) will fail if it cannot open the existing file for writing.

Returns

DataSource

A new DataSource instance that is backed by the specified file path.

Exceptions

ArgumentNullException

Thrown if path is null, empty, or consists solely of white-space characters.