-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New+Optional memorydb interface to support batch memories upset (#441)
- Loading branch information
Showing
3 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
service/Abstractions/MemoryStorage/IMemoryDbBatchUpsert.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.Collections.Generic; | ||
using System.Threading; | ||
|
||
namespace Microsoft.KernelMemory.MemoryStorage; | ||
|
||
/// <summary> | ||
/// Interface for memory DB adapters supporting batch upsert. | ||
/// The interface is not mandatory and not implemented by all connectors. | ||
/// Handlers/Clients should check if the interface is available and leverage it to optimize throughput. | ||
/// </summary> | ||
public interface IMemoryDbBatchUpsert | ||
{ | ||
/// <summary> | ||
/// Insert/Update a list of vectors + payload. | ||
/// </summary> | ||
/// <param name="index">Index/Collection name</param> | ||
/// <param name="records">Vectors + payload to save</param> | ||
/// <param name="cancellationToken">Task cancellation token</param> | ||
/// <returns>Record IDs</returns> | ||
/// <exception cref="IndexNotFound">Error returned if the index where to write doesn't exist</exception> | ||
IAsyncEnumerable<string> BatchUpsertAsync( | ||
string index, | ||
IEnumerable<MemoryRecord> records, | ||
CancellationToken cancellationToken = default); | ||
} |