Method UpsertAsync
UpsertAsync(string, float[], MetadataCollection, CancellationToken)
Asynchronously 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 UpsertAsync implementation.
public Task<Section> UpsertAsync(string sectionIdentifier, float[] vector, MetadataCollection metadata = null, CancellationToken cancellationToken = default)
Parameters
sectionIdentifier
stringThe 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
MetadataCollectionOptional metadata to associate with the newly created TextPartition.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the operation to complete.
Returns
- Task<Section>
A Task<TResult> that, when complete, yields the Section into which the vector was inserted.
Exceptions
- ArgumentNullException
Thrown if
vector
isnull
or has incorrect dimensionality.
UpsertAsync(string, IEnumerable<float[]>, MetadataCollection, CancellationToken)
Asynchronously inserts multiple embedding vectors into the specified section in a single operation, creating the section if necessary. Delegates to the core UpsertAsync implementation after wrapping each float[] in a DataSource.VectorEntry.
public Task<Section> UpsertAsync(string sectionIdentifier, IEnumerable<float[]> vectors, MetadataCollection metadata = null, CancellationToken cancellationToken = default)
Parameters
sectionIdentifier
stringThe 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
MetadataCollectionOptional metadata to associate with each newly created TextPartition.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the operation to complete.
Returns
- Task<Section>
A Task<TResult> that, when complete, yields the Section into which the vectors were inserted.
Exceptions
- ArgumentNullException
Thrown if
vectors
isnull
, empty, containsnull
entries, or if any vector has incorrect dimensionality.
UpsertAsync(string, VectorEntry, MetadataCollection, CancellationToken)
Asynchronously inserts a single vector entry into the specified section, creating the section if it does not already exist. Wraps the DataSource.VectorEntry’s payload in a TextPartition and stores its embedding.
public Task<Section> UpsertAsync(string sectionIdentifier, DataSource.VectorEntry vector, MetadataCollection metadata = null, CancellationToken cancellationToken = default)
Parameters
sectionIdentifier
stringThe unique identifier of the section into which to insert the vector. If the section does not exist, it will be created.
vector
DataSource.VectorEntryThe DataSource.VectorEntry to insert. Must not be
null
, and its DataSource.VectorEntry count must equal EmbeddingSize.metadata
MetadataCollectionOptional metadata to associate with the newly created TextPartition.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the operation to complete.
Returns
- Task<Section>
A Task<TResult> that, when complete, yields the Section into which the vector was inserted.
Exceptions
- ArgumentNullException
Thrown if
vector
isnull
or if its dimensionality does not match EmbeddingSize.
UpsertAsync(string, IEnumerable<VectorEntry>, MetadataCollection, CancellationToken)
Inserts a sequence of vector entries into the specified section, creating the section if it does not already exist. Each DataSource.VectorEntry’s payload is wrapped in a TextPartition and its embedding stored.
public Task<Section> UpsertAsync(string sectionIdentifier, IEnumerable<DataSource.VectorEntry> vectors, MetadataCollection metadata = null, CancellationToken cancellationToken = default)
Parameters
sectionIdentifier
stringThe unique identifier of the section into which to insert the vectors. If the section doesn’t 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 must match EmbeddingSize.metadata
MetadataCollectionOptional metadata to associate with the newly created TextPartition instances.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the operation to complete.
Returns
- Task<Section>
A Task<TResult> that, when complete, yields the Section into which the vectors were inserted.
Exceptions
- ArgumentNullException
Thrown if
vectors
isnull
or contains no elements, or if any element ofvectors
isnull
, or if any vector’s dimensionality does not equal EmbeddingSize.