Method CreateFileDataSource
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
stringThe file path where the data source will be created. This must be a valid path and the file must not already exist.
identifier
stringThe unique identifier for the data source.
model
LMThe language model associated with the data source.
metadata
MetadataCollectionOptional metadata to be associated with the data source.
overwrite
boolIf
true
, an existing file atpath
will be deleted before creating a new one. Iffalse
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
stringThe file path where the data source will be created. Must be non-null, non-empty, and not consist solely of white-space.
identifier
stringThe unique identifier for the data source. Used to distinguish this source in logs and lookups.
embeddingSize
intThe dimensionality of the vector embeddings stored by this data source. Must match the size expected by downstream searches.
metadata
MetadataCollectionOptional MetadataCollection to associate with the data source. Pass
null
if no metadata is required.overwrite
boolIf
true
, any existing file atpath
will be deleted before creation. Iffalse
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
isnull
, empty, or consists solely of white-space characters.