Table of Contents

Method Upsert

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

Upsert(string, float[], MetadataCollection, CancellationToken)

Inserts a single embedding vector into the specified section, creating the section if it does not already exist. Wraps the provided float[] payload in a DataSource.VectorEntry and delegates to the core Upsert implementation.

public Section Upsert(string sectionIdentifier, float[] vector, MetadataCollection metadata = null, CancellationToken cancellationToken = default)

Parameters

sectionIdentifier string

The unique identifier of the section into which to insert the vector. If the section does not exist, it will be created.

vector float[]

The embedding vector to insert. Must not be null and its length must equal EmbeddingSize.

metadata MetadataCollection

Optional metadata to associate with the newly created TextPartition.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the operation to complete.

Returns

Section

The Section into which the vector was inserted (either existing or newly created).

Exceptions

ArgumentNullException

Thrown if vector is null or has incorrect dimensionality.

Upsert(string, IEnumerable<float[]>, MetadataCollection, CancellationToken)

Inserts multiple embedding vectors into the specified section in a single operation, creating the section if necessary. Delegates to the core Upsert implementation after wrapping each float[] in a DataSource.VectorEntry.

public Section Upsert(string sectionIdentifier, IEnumerable<float[]> vectors, MetadataCollection metadata = null, CancellationToken cancellationToken = default)

Parameters

sectionIdentifier string

The unique identifier of the section into which to insert the vectors. If the section does not exist, it will be created.

vectors IEnumerable<float[]>

A non-empty collection of embedding vectors to insert. Each vector must not be null and must have length equal to EmbeddingSize.

metadata MetadataCollection

Optional metadata to associate with each newly created TextPartition.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the operation to complete.

Returns

Section

The Section into which the vectors were inserted (either existing or newly created).

Exceptions

ArgumentNullException

Thrown if vectors is null, empty, contains null entries, or if any vector has incorrect dimensionality.

Upsert(string, IEnumerable<VectorEntry>, MetadataCollection, CancellationToken)

Inserts a sequence of vector entries into the specified section, creating it if necessary. Wraps each DataSource.VectorEntry’s payload in a TextPartition and stores its embedding.

public Section Upsert(string sectionIdentifier, IEnumerable<DataSource.VectorEntry> vectors, MetadataCollection metadata = null, CancellationToken cancellationToken = default)

Parameters

sectionIdentifier string

The unique identifier of the section into which to insert the vectors. If the section does not exist, it will be created.

vectors IEnumerable<DataSource.VectorEntry>

A collection of DataSource.VectorEntry instances to insert. Must not be null or empty, and each entry’s DataSource.VectorEntry count must equal EmbeddingSize.

metadata MetadataCollection

Optional metadata to associate with each newly created TextPartition.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the operation to complete.

Returns

Section

The Section into which the vectors were inserted (either existing or newly created).

Exceptions

ArgumentNullException

Thrown if vectors is null or contains no elements, or if any element is null, or if any vector’s dimension does not match EmbeddingSize.