From 165e5a5ef10e411aa0f135ffbd44440c667706cc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Aug 2026 10:08:29 +0000 Subject: [PATCH 1/3] Rename CosmosNoSql provider to AzureCosmosDB Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com> --- CommunityToolkit.AI.slnx | 6 +- MEVD/MEVD.slnf | 6 +- .../AssemblyInfo.cs | 0 .../AzureCosmosDB.csproj} | 4 +- .../ByteArrayJsonConverter.cs | 2 +- .../ClientWrapper.cs | 2 +- .../CosmosDBCollection.cs} | 76 +++++----- .../CosmosDBCollectionOptions.cs} | 16 +-- .../CosmosDBCollectionQueryBuilder.cs} | 10 +- .../CosmosDBConstants.cs} | 4 +- .../CosmosDBDynamicCollection.cs} | 26 ++-- .../CosmosDBDynamicMapper.cs} | 10 +- .../CosmosDBFilterTranslator.cs} | 6 +- .../CosmosDBKey.cs} | 56 ++++---- .../CosmosDBMapper.cs} | 10 +- .../CosmosDBModelBuilder.cs} | 12 +- .../CosmosDBServiceCollectionExtensions.cs} | 136 +++++++++--------- .../CosmosDBVectorStore.cs} | 28 ++-- .../CosmosDBVectorStoreOptions.cs} | 12 +- .../ErrorHandlingFeedIterator.cs | 2 +- .../ICosmosDBMapper.cs} | 4 +- .../{CosmosNoSql => AzureCosmosDB}/README.md | 14 +- .../AzureCosmosDB.ConformanceTests.csproj} | 4 +- .../CosmosDBBasicModelTests.cs | 27 ++++ .../CosmosDBCollectionManagementTests.cs} | 8 +- .../CosmosDBDataTypeTests.cs} | 10 +- .../CosmosDBDependencyInjectionTests.cs} | 16 +-- .../CosmosDBDistanceFunctionTests.cs} | 12 +- .../CosmosDBDynamicModelTests.cs} | 12 +- .../CosmosDBEmbeddingGenerationTests.cs | 92 ++++++++++++ .../CosmosDBEmbeddingTypeTests.cs} | 12 +- .../CosmosDBFilterTests.cs} | 10 +- .../CosmosDBHybridSearchTests.cs} | 18 +-- .../CosmosDBIndexKindTests.cs | 30 ++++ .../CosmosDBKeyTypeTests.cs} | 10 +- .../CosmosDBMultiVectorModelTests.cs} | 10 +- .../CosmosDBNoDataModelTests.cs | 20 +++ .../CosmosDBNoVectorModelTests.cs | 20 +++ .../CosmosDBTestSuiteImplementationTests.cs} | 4 +- .../CosmosDBConformanceTestHelpers.cs} | 4 +- .../Support/CosmosDBFixture.cs} | 6 +- .../Support/CosmosDBTestEnvironment.cs} | 6 +- .../Support/CosmosDBTestStore.cs} | 20 +-- .../AzureCosmosDB.UnitTests.csproj} | 6 +- .../CosmosDBOptionsTests.cs} | 10 +- .../CosmosNoSqlBasicModelTests.cs | 27 ---- .../CosmosNoSqlEmbeddingGenerationTests.cs | 92 ------------ .../CosmosNoSqlIndexKindTests.cs | 30 ---- .../CosmosNoSqlNoDataModelTests.cs | 20 --- .../CosmosNoSqlNoVectorModelTests.cs | 20 --- README.md | 8 +- 51 files changed, 503 insertions(+), 503 deletions(-) rename MEVD/src/{CosmosNoSql => AzureCosmosDB}/AssemblyInfo.cs (100%) rename MEVD/src/{CosmosNoSql/CosmosNoSql.csproj => AzureCosmosDB/AzureCosmosDB.csproj} (86%) rename MEVD/src/{CosmosNoSql => AzureCosmosDB}/ByteArrayJsonConverter.cs (98%) rename MEVD/src/{CosmosNoSql => AzureCosmosDB}/ClientWrapper.cs (94%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlCollection.cs => AzureCosmosDB/CosmosDBCollection.cs} (92%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlCollectionOptions.cs => AzureCosmosDB/CosmosDBCollectionOptions.cs} (81%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlCollectionQueryBuilder.cs => AzureCosmosDB/CosmosDBCollectionQueryBuilder.cs} (96%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlConstants.cs => AzureCosmosDB/CosmosDBConstants.cs} (86%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlDynamicCollection.cs => AzureCosmosDB/CosmosDBDynamicCollection.cs} (76%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlDynamicMapper.cs => AzureCosmosDB/CosmosDBDynamicMapper.cs} (94%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlFilterTranslator.cs => AzureCosmosDB/CosmosDBFilterTranslator.cs} (98%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlKey.cs => AzureCosmosDB/CosmosDBKey.cs} (70%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlMapper.cs => AzureCosmosDB/CosmosDBMapper.cs} (94%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlModelBuilder.cs => AzureCosmosDB/CosmosDBModelBuilder.cs} (88%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlServiceCollectionExtensions.cs => AzureCosmosDB/CosmosDBServiceCollectionExtensions.cs} (67%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlVectorStore.cs => AzureCosmosDB/CosmosDBVectorStore.cs} (86%) rename MEVD/src/{CosmosNoSql/CosmosNoSqlVectorStoreOptions.cs => AzureCosmosDB/CosmosDBVectorStoreOptions.cs} (69%) rename MEVD/src/{CosmosNoSql => AzureCosmosDB}/ErrorHandlingFeedIterator.cs (97%) rename MEVD/src/{CosmosNoSql/ICosmosNoSQLMapper.cs => AzureCosmosDB/ICosmosDBMapper.cs} (87%) rename MEVD/src/{CosmosNoSql => AzureCosmosDB}/README.md (74%) rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSql.ConformanceTests.csproj => AzureCosmosDB.ConformanceTests/AzureCosmosDB.ConformanceTests.csproj} (83%) create mode 100644 MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBBasicModelTests.cs rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSqlCollectionManagementTests.cs => AzureCosmosDB.ConformanceTests/CosmosDBCollectionManagementTests.cs} (57%) rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSqlDataTypeTests.cs => AzureCosmosDB.ConformanceTests/CosmosDBDataTypeTests.cs} (70%) rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSqlDependencyInjectionTests.cs => AzureCosmosDB.ConformanceTests/CosmosDBDependencyInjectionTests.cs} (52%) rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSqlDistanceFunctionTests.cs => AzureCosmosDB.ConformanceTests/CosmosDBDistanceFunctionTests.cs} (69%) rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSqlDynamicModelTests.cs => AzureCosmosDB.ConformanceTests/CosmosDBDynamicModelTests.cs} (50%) create mode 100644 MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingGenerationTests.cs rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingTypeTests.cs => AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingTypeTests.cs} (64%) rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSqlFilterTests.cs => AzureCosmosDB.ConformanceTests/CosmosDBFilterTests.cs} (54%) rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSqlHybridSearchTests.cs => AzureCosmosDB.ConformanceTests/CosmosDBHybridSearchTests.cs} (51%) create mode 100644 MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBIndexKindTests.cs rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSqlKeyTypeTests.cs => AzureCosmosDB.ConformanceTests/CosmosDBKeyTypeTests.cs} (50%) rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSqlMultiVectorModelTests.cs => AzureCosmosDB.ConformanceTests/CosmosDBMultiVectorModelTests.cs} (56%) create mode 100644 MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoDataModelTests.cs create mode 100644 MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoVectorModelTests.cs rename MEVD/test/{CosmosNoSql.ConformanceTests/CosmosNoSqlTestSuiteImplementationTests.cs => AzureCosmosDB.ConformanceTests/CosmosDBTestSuiteImplementationTests.cs} (79%) rename MEVD/test/{CosmosNoSql.ConformanceTests/Support/CosmosNoSqlConformanceTestHelpers.cs => AzureCosmosDB.ConformanceTests/Support/CosmosDBConformanceTestHelpers.cs} (84%) rename MEVD/test/{CosmosNoSql.ConformanceTests/Support/CosmosNoSqlFixture.cs => AzureCosmosDB.ConformanceTests/Support/CosmosDBFixture.cs} (51%) rename MEVD/test/{CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestEnvironment.cs => AzureCosmosDB.ConformanceTests/Support/CosmosDBTestEnvironment.cs} (85%) rename MEVD/test/{CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestStore.cs => AzureCosmosDB.ConformanceTests/Support/CosmosDBTestStore.cs} (86%) rename MEVD/test/{CosmosNoSql.UnitTests/CosmosNoSql.UnitTests.csproj => AzureCosmosDB.UnitTests/AzureCosmosDB.UnitTests.csproj} (72%) rename MEVD/test/{CosmosNoSql.UnitTests/CosmosNoSqlOptionsTests.cs => AzureCosmosDB.UnitTests/CosmosDBOptionsTests.cs} (83%) delete mode 100644 MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlBasicModelTests.cs delete mode 100644 MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingGenerationTests.cs delete mode 100644 MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlIndexKindTests.cs delete mode 100644 MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoDataModelTests.cs delete mode 100644 MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoVectorModelTests.cs diff --git a/CommunityToolkit.AI.slnx b/CommunityToolkit.AI.slnx index 31f6e90..acb7bee 100644 --- a/CommunityToolkit.AI.slnx +++ b/CommunityToolkit.AI.slnx @@ -9,7 +9,7 @@ - + @@ -23,8 +23,8 @@ - - + + diff --git a/MEVD/MEVD.slnf b/MEVD/MEVD.slnf index c8feb37..2b48cd6 100644 --- a/MEVD/MEVD.slnf +++ b/MEVD/MEVD.slnf @@ -4,7 +4,7 @@ "projects": [ "MEVD/src/AzureAISearch/AzureAISearch.csproj", - "MEVD/src/CosmosNoSql/CosmosNoSql.csproj", + "MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj", "MEVD/src/AzureDocumentDB/AzureDocumentDB.csproj", "MEVD/src/InMemory/InMemory.csproj", "MEVD/src/PgVector/PgVector.csproj", @@ -16,8 +16,8 @@ "MEVD/test/AzureAISearch.UnitTests/AzureAISearch.UnitTests.csproj", "MEVD/test/AzureAISearch.ConformanceTests/AzureAISearch.ConformanceTests.csproj", - "MEVD/test/CosmosNoSql.UnitTests/CosmosNoSql.UnitTests.csproj", - "MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSql.ConformanceTests.csproj", + "MEVD/test/AzureCosmosDB.UnitTests/AzureCosmosDB.UnitTests.csproj", + "MEVD/test/AzureCosmosDB.ConformanceTests/AzureCosmosDB.ConformanceTests.csproj", "MEVD/test/AzureDocumentDB.UnitTests/AzureDocumentDB.UnitTests.csproj", "MEVD/test/AzureDocumentDB.ConformanceTests/AzureDocumentDB.ConformanceTests.csproj", "MEVD/test/InMemory.UnitTests/InMemory.UnitTests.csproj", diff --git a/MEVD/src/CosmosNoSql/AssemblyInfo.cs b/MEVD/src/AzureCosmosDB/AssemblyInfo.cs similarity index 100% rename from MEVD/src/CosmosNoSql/AssemblyInfo.cs rename to MEVD/src/AzureCosmosDB/AssemblyInfo.cs diff --git a/MEVD/src/CosmosNoSql/CosmosNoSql.csproj b/MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj similarity index 86% rename from MEVD/src/CosmosNoSql/CosmosNoSql.csproj rename to MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj index 9c1c682..bbde767 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSql.csproj +++ b/MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj @@ -1,7 +1,7 @@ 1.0.0 - CommunityToolkit.VectorData.CosmosNoSql + CommunityToolkit.VectorData.AzureCosmosDB $(AssemblyName) net10.0;net8.0;netstandard2.0;net462 @@ -20,7 +20,7 @@ - + diff --git a/MEVD/src/CosmosNoSql/ByteArrayJsonConverter.cs b/MEVD/src/AzureCosmosDB/ByteArrayJsonConverter.cs similarity index 98% rename from MEVD/src/CosmosNoSql/ByteArrayJsonConverter.cs rename to MEVD/src/AzureCosmosDB/ByteArrayJsonConverter.cs index 15aba28..5df8413 100644 --- a/MEVD/src/CosmosNoSql/ByteArrayJsonConverter.cs +++ b/MEVD/src/AzureCosmosDB/ByteArrayJsonConverter.cs @@ -6,7 +6,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// /// A JSON converter for byte arrays that serializes them as JSON arrays of numbers diff --git a/MEVD/src/CosmosNoSql/ClientWrapper.cs b/MEVD/src/AzureCosmosDB/ClientWrapper.cs similarity index 94% rename from MEVD/src/CosmosNoSql/ClientWrapper.cs rename to MEVD/src/AzureCosmosDB/ClientWrapper.cs index 53eec7a..cbaa5ab 100644 --- a/MEVD/src/CosmosNoSql/ClientWrapper.cs +++ b/MEVD/src/AzureCosmosDB/ClientWrapper.cs @@ -5,7 +5,7 @@ using System.Threading; using Microsoft.Azure.Cosmos; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; internal sealed class ClientWrapper : IDisposable { diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlCollection.cs b/MEVD/src/AzureCosmosDB/CosmosDBCollection.cs similarity index 92% rename from MEVD/src/CosmosNoSql/CosmosNoSqlCollection.cs rename to MEVD/src/AzureCosmosDB/CosmosDBCollection.cs index 8cd8988..529a7ab 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlCollection.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBCollection.cs @@ -25,17 +25,17 @@ using SKDistanceFunction = Microsoft.Extensions.VectorData.DistanceFunction; using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// /// Service for storing and retrieving vector records, that uses Azure CosmosDB NoSQL as the underlying storage. /// /// /// The data type of the record key. Supported types are and (in which case the partition key -/// is the document ID), and (for other partition key configurations). +/// is the document ID), and (for other partition key configurations). /// The data model to use for adding, updating and retrieving data from storage. #pragma warning disable CA1711 // Identifiers should not have incorrect suffix -public class CosmosNoSqlCollection : VectorStoreCollection, IKeywordHybridSearchable +public class CosmosDBCollection : VectorStoreCollection, IKeywordHybridSearchable where TKey : notnull where TRecord : class #pragma warning restore CA1711 // Identifiers should not have incorrect suffix @@ -62,7 +62,7 @@ public class CosmosNoSqlCollection : VectorStoreCollection _partitionKeyProperties; /// The mapper to use when mapping between the consumer data model and the Azure CosmosDB NoSQL record. - private readonly ICosmosNoSqlMapper _mapper; + private readonly ICosmosDBMapper _mapper; /// public override string Name { get; } @@ -74,14 +74,14 @@ public class CosmosNoSqlCollection : VectorStoreCollection - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// that can be used to manage the collections in Azure CosmosDB NoSQL. - /// The name of the collection that this will access. + /// The name of the collection that this will access. /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosNoSqlCollection(Database database, string name, CosmosNoSqlCollectionOptions? options = default) + public CosmosDBCollection(Database database, string name, CosmosDBCollectionOptions? options = default) : this(new(database.Client, ownsClient: false), _ => database, name, options) { Throw.IfNull(database); @@ -89,21 +89,21 @@ public CosmosNoSqlCollection(Database database, string name, CosmosNoSqlCollecti } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Connection string required to connect to Azure CosmosDB NoSQL. /// Database name for Azure CosmosDB NoSQL. - /// The name of the collection that this will access. + /// The name of the collection that this will access. /// Optional configuration options for . /// Optional configuration options for . [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosNoSqlCollection( + public CosmosDBCollection( string connectionString, string databaseName, string name, CosmosClientOptions? clientOptions = null, - CosmosNoSqlCollectionOptions? options = null) + CosmosDBCollectionOptions? options = null) : this( new ClientWrapper(new CosmosClient(connectionString, clientOptions), ownsClient: true), client => client.GetDatabase(databaseName), @@ -115,34 +115,34 @@ public CosmosNoSqlCollection( Throw.IfNullOrWhitespace(name); } - internal CosmosNoSqlCollection( + internal CosmosDBCollection( ClientWrapper clientWrapper, Func databaseProvider, string name, - CosmosNoSqlCollectionOptions? options) + CosmosDBCollectionOptions? options) : this( clientWrapper, databaseProvider, name, static options => typeof(TRecord) == typeof(Dictionary) - ? throw new NotSupportedException(VectorDataStrings.NonDynamicCollectionWithDictionaryNotSupported(typeof(CosmosNoSqlDynamicCollection))) - : new CosmosNoSqlModelBuilder() + ? throw new NotSupportedException(VectorDataStrings.NonDynamicCollectionWithDictionaryNotSupported(typeof(CosmosDBDynamicCollection))) + : new CosmosDBModelBuilder() .Build(typeof(TRecord), typeof(TKey), options.Definition, options.EmbeddingGenerator, options.JsonSerializerOptions ?? JsonSerializerOptions.Default), options) { } - internal CosmosNoSqlCollection( + internal CosmosDBCollection( ClientWrapper clientWrapper, Func databaseProvider, string name, - Func modelFactory, - CosmosNoSqlCollectionOptions? options) + Func modelFactory, + CosmosDBCollectionOptions? options) { - // Validate TKey: must be string or Guid (partition key = document ID), CosmosNoSqlKey (other partition key cases), or object (used by CosmosNoSqlDynamicCollection). - if (typeof(TKey) != typeof(string) && typeof(TKey) != typeof(Guid) && typeof(TKey) != typeof(CosmosNoSqlKey) && typeof(TKey) != typeof(object)) + // Validate TKey: must be string or Guid (partition key = document ID), CosmosDBKey (other partition key cases), or object (used by CosmosDBDynamicCollection). + if (typeof(TKey) != typeof(string) && typeof(TKey) != typeof(Guid) && typeof(TKey) != typeof(CosmosDBKey) && typeof(TKey) != typeof(object)) { - throw new NotSupportedException($"The key type must be string, Guid, or CosmosNoSqlKey. Received: {typeof(TKey).Name}"); + throw new NotSupportedException($"The key type must be string, Guid, or CosmosDBKey. Received: {typeof(TKey).Name}"); } try @@ -156,7 +156,7 @@ internal CosmosNoSqlCollection( $"is required to be configured for {this.GetType().Name}."); } - options ??= CosmosNoSqlCollectionOptions.Default; + options ??= CosmosDBCollectionOptions.Default; // Assign. this.Name = name; @@ -167,8 +167,8 @@ internal CosmosNoSqlCollection( // Assign mapper. this._mapper = typeof(TRecord) == typeof(Dictionary) - ? (new CosmosNoSqlDynamicMapper(this._model, jsonSerializerOptions) as ICosmosNoSqlMapper)! - : new CosmosNoSqlMapper(this._model, options.JsonSerializerOptions); + ? (new CosmosDBDynamicMapper(this._model, jsonSerializerOptions) as ICosmosDBMapper)! + : new CosmosDBMapper(this._model, options.JsonSerializerOptions); // Setup partition key properties (supports hierarchical partition keys up to 3 levels) if (options.PartitionKeyProperties is null) @@ -205,18 +205,18 @@ internal CosmosNoSqlCollection( // When using simple key types (string/Guid), the partition key must be the key property only, // since the partition key value cannot be independently specified via a simple key. // Users who need hierarchical partition keys, a non-key partition key, or no partition key at all - // must use CosmosNoSqlKey as the key type. + // must use CosmosDBKey as the key type. if ((typeof(TKey) == typeof(string) || typeof(TKey) == typeof(Guid)) && (this._partitionKeyProperties is not [var singlePkProperty] || singlePkProperty != this._model.KeyProperty)) { throw new ArgumentException( $"When using {typeof(TKey).Name} as the key type, the partition key must be the key property " + - $"('{this._model.KeyProperty.ModelName}'). To use a different partition key configuration, use CosmosNoSqlKey as the key type."); + $"('{this._model.KeyProperty.ModelName}'). To use a different partition key configuration, use CosmosDBKey as the key type."); } this._collectionMetadata = new() { - VectorStoreSystemName = CosmosNoSqlConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosDBConstants.VectorStoreSystemName, VectorStoreName = this._database.Id, CollectionName = name }; @@ -291,7 +291,7 @@ public override async Task EnsureCollectionExistsAsync(CancellationToken cancell { throw new VectorStoreException("Call to vector store failed.", ex) { - VectorStoreSystemName = CosmosNoSqlConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosDBConstants.VectorStoreSystemName, VectorStoreName = this._collectionMetadata.VectorStoreName, CollectionName = this.Name, OperationName = "CreateContainer" @@ -316,7 +316,7 @@ await this._database { throw new VectorStoreException("Call to vector store failed.", ex) { - VectorStoreSystemName = CosmosNoSqlConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosDBConstants.VectorStoreSystemName, VectorStoreName = this._collectionMetadata.VectorStoreName, CollectionName = this.Name, OperationName = "DeleteContainer" @@ -493,7 +493,7 @@ await this.RunOperationAsync(OperationName, () => { var vectorProperty = model.VectorProperties[i]; - if (CosmosNoSqlModelBuilder.IsVectorPropertyTypeValidCore(vectorProperty.Type, out _)) + if (CosmosDBModelBuilder.IsVectorPropertyTypeValidCore(vectorProperty.Type, out _)) { continue; } @@ -548,7 +548,7 @@ public override async IAsyncEnumerable> SearchAsync< var vectorProperty = this._model.GetVectorPropertyOrSingle(options); object vector = await GetSearchVectorAsync(searchValue, vectorProperty, cancellationToken).ConfigureAwait(false); - var queryDefinition = CosmosNoSqlCollectionQueryBuilder.BuildSearchQuery( + var queryDefinition = CosmosDBCollectionQueryBuilder.BuildSearchQuery( vector, null, this._model, @@ -593,7 +593,7 @@ _ when vectorProperty.EmbeddingGenerationDispatcher is not null => await vectorProperty.GenerateEmbeddingAsync(searchValue, cancellationToken).ConfigureAwait(false), _ => vectorProperty.EmbeddingGenerator is null - ? throw new NotSupportedException(VectorDataStrings.InvalidSearchInputAndNoEmbeddingGeneratorWasConfigured(searchValue.GetType(), CosmosNoSqlModelBuilder.SupportedVectorTypes)) + ? throw new NotSupportedException(VectorDataStrings.InvalidSearchInputAndNoEmbeddingGeneratorWasConfigured(searchValue.GetType(), CosmosDBModelBuilder.SupportedVectorTypes)) : throw new InvalidOperationException(VectorDataStrings.IncompatibleEmbeddingGeneratorWasConfiguredForInputType(typeof(TInput), vectorProperty.EmbeddingGenerator.GetType())) }; @@ -610,9 +610,9 @@ public override async IAsyncEnumerable GetAsync(Expression> HybridSearchAsync( + var queryDefinition = CosmosDBCollectionQueryBuilder.BuildSearchQuery( vector, keywords, this._model, @@ -692,7 +692,7 @@ private void VerifyVectorType(TVector? vector) var vectorType = vector!.GetType(); - if (!CosmosNoSqlModelBuilder.IsVectorPropertyTypeValidCore(vectorType, out var supportedTypes)) + if (!CosmosDBModelBuilder.IsVectorPropertyTypeValidCore(vectorType, out var supportedTypes)) { throw new NotSupportedException( $"The provided vector type {vectorType.FullName} is not supported by the Azure CosmosDB NoSQL connector. Supported types are: {supportedTypes}"); @@ -711,11 +711,11 @@ private Task RunOperationAsync(string operationName, Func> operati private (string DocumentId, PartitionKey PartitionKey) GetDocumentIdAndPartitionKey(TKey key) => key switch { - CosmosNoSqlKey cosmosKey => (cosmosKey.DocumentId, cosmosKey.PartitionKey), + CosmosDBKey cosmosKey => (cosmosKey.DocumentId, cosmosKey.PartitionKey), string s => (s, new PartitionKey(s)), Guid g => (g.ToString(), new PartitionKey(g.ToString())), _ => throw new InvalidOperationException( - $"Keys must be of type string, Guid, or CosmosNoSqlKey. Received key of type '{key.GetType().FullName}'.") + $"Keys must be of type string, Guid, or CosmosDBKey. Received key of type '{key.GetType().FullName}'.") }; /// diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlCollectionOptions.cs b/MEVD/src/AzureCosmosDB/CosmosDBCollectionOptions.cs similarity index 81% rename from MEVD/src/CosmosNoSql/CosmosNoSqlCollectionOptions.cs rename to MEVD/src/AzureCosmosDB/CosmosDBCollectionOptions.cs index b26e936..e72e1bf 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlCollectionOptions.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBCollectionOptions.cs @@ -6,23 +6,23 @@ using Microsoft.Azure.Cosmos; using Microsoft.Extensions.VectorData; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Options when creating a . +/// Options when creating a . /// -public sealed class CosmosNoSqlCollectionOptions : VectorStoreCollectionOptions +public sealed class CosmosDBCollectionOptions : VectorStoreCollectionOptions { - internal static readonly CosmosNoSqlCollectionOptions Default = new(); + internal static readonly CosmosDBCollectionOptions Default = new(); /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public CosmosNoSqlCollectionOptions() + public CosmosDBCollectionOptions() { } - internal CosmosNoSqlCollectionOptions(CosmosNoSqlCollectionOptions? source) : base(source) + internal CosmosDBCollectionOptions(CosmosDBCollectionOptions? source) : base(source) { this.JsonSerializerOptions = source?.JsonSerializerOptions; this.PartitionKeyProperties = source?.PartitionKeyProperties is null ? null : [.. source.PartitionKeyProperties]; @@ -47,7 +47,7 @@ internal CosmosNoSqlCollectionOptions(CosmosNoSqlCollectionOptions? source) : ba /// When (the default), the key property (document ID) is automatically used as the partition key - a common /// Cosmos DB strategy; in this mode, the collection key type must be or . /// To use a different partition key (or hierarchical partition keys), specify the key properties here and use - /// as the key type. + /// as the key type. /// /// public IReadOnlyList? PartitionKeyProperties { get; set; } diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlCollectionQueryBuilder.cs b/MEVD/src/AzureCosmosDB/CosmosDBCollectionQueryBuilder.cs similarity index 96% rename from MEVD/src/CosmosNoSql/CosmosNoSqlCollectionQueryBuilder.cs rename to MEVD/src/AzureCosmosDB/CosmosDBCollectionQueryBuilder.cs index ccdceae..ca929d8 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlCollectionQueryBuilder.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBCollectionQueryBuilder.cs @@ -12,12 +12,12 @@ using Microsoft.Extensions.VectorData.ProviderServices; using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// /// Contains helpers to build queries for Azure CosmosDB NoSQL. /// -internal static class CosmosNoSqlCollectionQueryBuilder +internal static class CosmosDBCollectionQueryBuilder { /// /// Builds to get items from Azure CosmosDB NoSQL using vector search. @@ -41,7 +41,7 @@ public static QueryDefinition BuildSearchQuery( const string VectorVariableName = "@vector"; const string KeywordVariablePrefix = "@keyword"; - var tableVariableName = CosmosNoSqlConstants.ContainerAlias; + var tableVariableName = CosmosDBConstants.ContainerAlias; IEnumerable projectionProperties = model.Properties; if (!includeVectors) @@ -56,7 +56,7 @@ public static QueryDefinition BuildSearchQuery( // Build filter object. var (filterClause, filterParameters) = filter is not null - ? new CosmosNoSqlFilterTranslator().Translate(filter, model) + ? new CosmosDBFilterTranslator().Translate(filter, model) : ((string?)null, new Dictionary()); var queryParameters = new Dictionary @@ -162,7 +162,7 @@ internal static QueryDefinition BuildSearchQuery( FilteredRecordRetrievalOptions filterOptions, int top) { - var tableVariableName = CosmosNoSqlConstants.ContainerAlias; + var tableVariableName = CosmosDBConstants.ContainerAlias; IEnumerable projectionProperties = model.Properties; if (!filterOptions.IncludeVectors) diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlConstants.cs b/MEVD/src/AzureCosmosDB/CosmosDBConstants.cs similarity index 86% rename from MEVD/src/CosmosNoSql/CosmosNoSqlConstants.cs rename to MEVD/src/AzureCosmosDB/CosmosDBConstants.cs index 9b35882..bde529b 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlConstants.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBConstants.cs @@ -1,9 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; -internal static class CosmosNoSqlConstants +internal static class CosmosDBConstants { internal const string VectorStoreSystemName = "azure.cosmosdbnosql"; diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlDynamicCollection.cs b/MEVD/src/AzureCosmosDB/CosmosDBDynamicCollection.cs similarity index 76% rename from MEVD/src/CosmosNoSql/CosmosNoSqlDynamicCollection.cs rename to MEVD/src/AzureCosmosDB/CosmosDBDynamicCollection.cs index f53f9bc..62be5c7 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlDynamicCollection.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBDynamicCollection.cs @@ -8,30 +8,30 @@ using Microsoft.Azure.Cosmos; using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Represents a collection of vector store records in a CosmosNoSql database, mapped to a dynamic Dictionary<string, object?>. +/// Represents a collection of vector store records in a CosmosDB database, mapped to a dynamic Dictionary<string, object?>. /// /// /// -/// This collection accepts keys of type , but only instances +/// This collection accepts keys of type , but only instances /// are supported at runtime. Passing any other key type will result in an . /// /// #pragma warning disable CA1711 // Identifiers should not have incorrect suffix -public sealed class CosmosNoSqlDynamicCollection : CosmosNoSqlCollection> +public sealed class CosmosDBDynamicCollection : CosmosDBCollection> #pragma warning restore CA1711 // Identifiers should not have incorrect suffix { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// that can be used to manage the collections in Azure CosmosDB NoSQL. /// The name of the collection. /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosNoSqlDynamicCollection(Database database, string name, CosmosNoSqlCollectionOptions options) + public CosmosDBDynamicCollection(Database database, string name, CosmosDBCollectionOptions options) : this( new(database.Client, ownsClient: false), _ => database, @@ -41,21 +41,21 @@ public CosmosNoSqlDynamicCollection(Database database, string name, CosmosNoSqlC } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Connection string required to connect to Azure CosmosDB NoSQL. /// Database name for Azure CosmosDB NoSQL. - /// The name of the collection that this will access. + /// The name of the collection that this will access. /// Optional configuration options for . /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosNoSqlDynamicCollection( + public CosmosDBDynamicCollection( string connectionString, string databaseName, string collectionName, CosmosClientOptions? clientOptions = null, - CosmosNoSqlCollectionOptions? options = null) + CosmosDBCollectionOptions? options = null) : this( new(new CosmosClient(connectionString, clientOptions), ownsClient: true), client => client.GetDatabase(databaseName), @@ -67,16 +67,16 @@ public CosmosNoSqlDynamicCollection( Throw.IfNullOrWhitespace(collectionName); } - internal CosmosNoSqlDynamicCollection( + internal CosmosDBDynamicCollection( ClientWrapper clientWrapper, Func databaseProvider, string name, - CosmosNoSqlCollectionOptions? options) + CosmosDBCollectionOptions? options) : base( clientWrapper, databaseProvider, name, - static options => new CosmosNoSqlModelBuilder() + static options => new CosmosDBModelBuilder() .BuildDynamic( options.Definition ?? throw new ArgumentException("Definition is required for dynamic collections"), options.EmbeddingGenerator, diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlDynamicMapper.cs b/MEVD/src/AzureCosmosDB/CosmosDBDynamicMapper.cs similarity index 94% rename from MEVD/src/CosmosNoSql/CosmosNoSqlDynamicMapper.cs rename to MEVD/src/AzureCosmosDB/CosmosDBDynamicMapper.cs index d90c1e7..0ac4807 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlDynamicMapper.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBDynamicMapper.cs @@ -12,13 +12,13 @@ using MEAI = Microsoft.Extensions.AI; using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// /// A mapper that maps between the generic Semantic Kernel data model and the model that the data is stored under, within Azure CosmosDB NoSQL. /// -internal sealed class CosmosNoSqlDynamicMapper(CollectionModel model, JsonSerializerOptions jsonSerializerOptions) - : ICosmosNoSqlMapper> +internal sealed class CosmosDBDynamicMapper(CollectionModel model, JsonSerializerOptions jsonSerializerOptions) + : ICosmosDBMapper> { public JsonObject MapFromDataToStorageModel(Dictionary dataModel, int recordIndex, IReadOnlyList?[]? generatedEmbeddings) { @@ -26,7 +26,7 @@ public JsonObject MapFromDataToStorageModel(Dictionary dataMode var jsonObject = new JsonObject { - [CosmosNoSqlConstants.ReservedKeyPropertyName] = !dataModel.TryGetValue(model.KeyProperty.ModelName, out var keyValue) + [CosmosDBConstants.ReservedKeyPropertyName] = !dataModel.TryGetValue(model.KeyProperty.ModelName, out var keyValue) ? throw new InvalidOperationException($"Missing value for key property '{model.KeyProperty.ModelName}") : keyValue switch { @@ -124,7 +124,7 @@ static bool TryGetReadOnlyMemory(object value, [NotNullWhen(true)] out ReadOn switch (property) { case KeyPropertyModel keyProperty: - var key = (string?)storageModel[CosmosNoSqlConstants.ReservedKeyPropertyName] + var key = (string?)storageModel[CosmosDBConstants.ReservedKeyPropertyName] ?? throw new InvalidOperationException($"The key property '{keyProperty.StorageName}' is missing from the record retrieved from storage."); result[keyProperty.ModelName] = keyProperty.Type switch diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlFilterTranslator.cs b/MEVD/src/AzureCosmosDB/CosmosDBFilterTranslator.cs similarity index 98% rename from MEVD/src/CosmosNoSql/CosmosNoSqlFilterTranslator.cs rename to MEVD/src/AzureCosmosDB/CosmosDBFilterTranslator.cs index 7bed782..c094de3 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlFilterTranslator.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBFilterTranslator.cs @@ -11,11 +11,11 @@ using Microsoft.Extensions.VectorData.ProviderServices; using Microsoft.Extensions.VectorData.ProviderServices.Filter; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; #pragma warning disable MEVD9001 // Experimental: filter translation base types -internal class CosmosNoSqlFilterTranslator : FilterTranslatorBase +internal class CosmosDBFilterTranslator : FilterTranslatorBase { private readonly Dictionary _parameters = []; private readonly StringBuilder _sql = new(); @@ -364,7 +364,7 @@ protected void TranslateQueryParameter(string name, object? value) protected virtual void GeneratePropertyAccess(PropertyModel property) => this._sql - .Append(CosmosNoSqlConstants.ContainerAlias) + .Append(CosmosDBConstants.ContainerAlias) .Append("[\"") .Append(property.StorageName.Replace(@"\", @"\\").Replace("\"", "\\\"")) .Append("\"]"); diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlKey.cs b/MEVD/src/AzureCosmosDB/CosmosDBKey.cs similarity index 70% rename from MEVD/src/CosmosNoSql/CosmosNoSqlKey.cs rename to MEVD/src/AzureCosmosDB/CosmosDBKey.cs index 90709bc..e6e0fe3 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlKey.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBKey.cs @@ -4,7 +4,7 @@ using System; using Microsoft.Azure.Cosmos; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// /// Represents a key for Azure CosmosDB NoSQL, containing both the record key (document ID) and the partition key. @@ -21,98 +21,98 @@ namespace CommunityToolkit.VectorData.CosmosNoSql; /// /// // This is conceptually a record, but we're targeting .NET Standard 2.0 too. -public readonly struct CosmosNoSqlKey : IEquatable +public readonly struct CosmosDBKey : IEquatable { /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(string documentId, string partitionKey) + public CosmosDBKey(string documentId, string partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(Guid documentId, string partitionKey) + public CosmosDBKey(Guid documentId, string partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(string documentId, Guid partitionKey) + public CosmosDBKey(string documentId, Guid partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey.ToString()); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(Guid documentId, Guid partitionKey) + public CosmosDBKey(Guid documentId, Guid partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey.ToString()); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(string documentId, bool partitionKey) + public CosmosDBKey(string documentId, bool partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(Guid documentId, bool partitionKey) + public CosmosDBKey(Guid documentId, bool partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(string documentId, double partitionKey) + public CosmosDBKey(string documentId, double partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(Guid documentId, double partitionKey) + public CosmosDBKey(Guid documentId, double partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. @@ -120,14 +120,14 @@ public CosmosNoSqlKey(Guid documentId, double partitionKey) /// Use this constructor for hierarchical partition keys or special partition key values like or . /// For hierarchical partition keys, construct the using . /// - public CosmosNoSqlKey(string documentId, PartitionKey partitionKey) + public CosmosDBKey(string documentId, PartitionKey partitionKey) { this.DocumentId = documentId; this.PartitionKey = partitionKey; } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. @@ -135,7 +135,7 @@ public CosmosNoSqlKey(string documentId, PartitionKey partitionKey) /// Use this constructor for hierarchical partition keys or special partition key values like or . /// For hierarchical partition keys, construct the using . /// - public CosmosNoSqlKey(Guid documentId, PartitionKey partitionKey) + public CosmosDBKey(Guid documentId, PartitionKey partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = partitionKey; @@ -159,26 +159,26 @@ public CosmosNoSqlKey(Guid documentId, PartitionKey partitionKey) public PartitionKey PartitionKey { get; } /// - public bool Equals(CosmosNoSqlKey other) + public bool Equals(CosmosDBKey other) => Equals(this.DocumentId, other.DocumentId) && this.PartitionKey.Equals(other.PartitionKey); /// public override bool Equals(object? obj) - => obj is CosmosNoSqlKey other && this.Equals(other); + => obj is CosmosDBKey other && this.Equals(other); /// public override int GetHashCode() => HashCode.Combine(this.DocumentId, this.PartitionKey); /// - /// Determines whether two instances are equal. + /// Determines whether two instances are equal. /// - public static bool operator ==(CosmosNoSqlKey left, CosmosNoSqlKey right) + public static bool operator ==(CosmosDBKey left, CosmosDBKey right) => left.Equals(right); /// - /// Determines whether two instances are not equal. + /// Determines whether two instances are not equal. /// - public static bool operator !=(CosmosNoSqlKey left, CosmosNoSqlKey right) + public static bool operator !=(CosmosDBKey left, CosmosDBKey right) => !left.Equals(right); } diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlMapper.cs b/MEVD/src/AzureCosmosDB/CosmosDBMapper.cs similarity index 94% rename from MEVD/src/CosmosNoSql/CosmosNoSqlMapper.cs rename to MEVD/src/AzureCosmosDB/CosmosDBMapper.cs index 7b97536..8a1b5b5 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlMapper.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBMapper.cs @@ -10,20 +10,20 @@ using Microsoft.Extensions.VectorData.ProviderServices; using MEAI = Microsoft.Extensions.AI; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// /// Class for mapping between a json node stored in Azure CosmosDB NoSQL and the consumer data model. /// /// The consumer data model to map to or from. -internal sealed class CosmosNoSqlMapper : ICosmosNoSqlMapper +internal sealed class CosmosDBMapper : ICosmosDBMapper where TRecord : class { private readonly CollectionModel _model; private readonly KeyPropertyModel _keyProperty; private readonly JsonSerializerOptions _jsonSerializerOptions; - public CosmosNoSqlMapper(CollectionModel model, JsonSerializerOptions? jsonSerializerOptions) + public CosmosDBMapper(CollectionModel model, JsonSerializerOptions? jsonSerializerOptions) { this._model = model; this._keyProperty = model.KeyProperty; @@ -43,7 +43,7 @@ public JsonObject MapFromDataToStorageModel(TRecord dataModel, int recordIndex, // The key property in Azure CosmosDB NoSQL is always named 'id'. // But the external JSON serializer used just above isn't aware of that, and will produce a JSON object with another name, taking into // account e.g. naming policies. SerializedKeyName gets populated in the model builder - containing that name - once VectorStoreModelBuildingOptions.ReservedKeyPropertyName is set - RenameJsonProperty(jsonObject, this._keyProperty.SerializedKeyName!, CosmosNoSqlConstants.ReservedKeyPropertyName); + RenameJsonProperty(jsonObject, this._keyProperty.SerializedKeyName!, CosmosDBConstants.ReservedKeyPropertyName); // Go over the vector properties; inject any generated embeddings to overwrite the JSON serialized above. // Also, for Embedding properties we also need to overwrite with a simple array (since Embedding gets serialized as a complex object). @@ -117,7 +117,7 @@ public JsonObject MapFromDataToStorageModel(TRecord dataModel, int recordIndex, public TRecord MapFromStorageToDataModel(JsonObject storageModel, bool includeVectors) { // See above comment. - RenameJsonProperty(storageModel, CosmosNoSqlConstants.ReservedKeyPropertyName, this._keyProperty.SerializedKeyName!); + RenameJsonProperty(storageModel, CosmosDBConstants.ReservedKeyPropertyName, this._keyProperty.SerializedKeyName!); foreach (var vectorProperty in this._model.VectorProperties) { diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlModelBuilder.cs b/MEVD/src/AzureCosmosDB/CosmosDBModelBuilder.cs similarity index 88% rename from MEVD/src/CosmosNoSql/CosmosNoSqlModelBuilder.cs rename to MEVD/src/AzureCosmosDB/CosmosDBModelBuilder.cs index 9184a92..6d00661 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlModelBuilder.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBModelBuilder.cs @@ -7,9 +7,9 @@ using Microsoft.Extensions.AI; using Microsoft.Extensions.VectorData.ProviderServices; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; -internal class CosmosNoSqlModelBuilder() : CollectionJsonModelBuilder(s_modelBuildingOptions) +internal class CosmosDBModelBuilder() : CollectionJsonModelBuilder(s_modelBuildingOptions) { internal const string SupportedVectorTypes = "ReadOnlyMemory, Embedding, float[], ReadOnlyMemory, Embedding, byte[], ReadOnlyMemory, Embedding, sbyte[]"; @@ -18,19 +18,19 @@ internal class CosmosNoSqlModelBuilder() : CollectionJsonModelBuilder(s_modelBui RequiresAtLeastOneVector = false, SupportsMultipleVectors = true, UsesExternalSerializer = true, - ReservedKeyStorageName = CosmosNoSqlConstants.ReservedKeyPropertyName + ReservedKeyStorageName = CosmosDBConstants.ReservedKeyPropertyName }; protected override void ValidateKeyProperty(KeyPropertyModel keyProperty) { - // CosmosNoSqlKey is a composite key type (document ID + partition key) that doesn't correspond to any single key property type; + // CosmosDBKey is a composite key type (document ID + partition key) that doesn't correspond to any single key property type; // skip the base TKey-to-key-property validation when it's used. - if (this.KeyType != typeof(CosmosNoSqlKey)) + if (this.KeyType != typeof(CosmosDBKey)) { base.ValidateKeyProperty(keyProperty); } - // Note that the key property in Cosmos NoSQL refers to the document ID, not to the CosmosNoSqlKey structure which includes both + // Note that the key property in Cosmos NoSQL refers to the document ID, not to the CosmosDBKey structure which includes both // the document ID and the partition key (and which is the generic TKey type parameter of the collection). var type = keyProperty.Type; diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlServiceCollectionExtensions.cs b/MEVD/src/AzureCosmosDB/CosmosDBServiceCollectionExtensions.cs similarity index 67% rename from MEVD/src/CosmosNoSql/CosmosNoSqlServiceCollectionExtensions.cs rename to MEVD/src/AzureCosmosDB/CosmosDBServiceCollectionExtensions.cs index 0c6b045..808e80a 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlServiceCollectionExtensions.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBServiceCollectionExtensions.cs @@ -7,7 +7,7 @@ using Microsoft.Azure.Cosmos; using Microsoft.Extensions.AI; using Microsoft.Extensions.VectorData; -using CommunityToolkit.VectorData.CosmosNoSql; +using CommunityToolkit.VectorData.AzureCosmosDB; using Microsoft.Shared.Diagnostics; #pragma warning disable IDE0130 // Namespace does not match folder structure @@ -15,148 +15,148 @@ namespace Microsoft.Extensions.DependencyInjection; #pragma warning restore IDE0130 // Namespace does not match folder structure /// -/// Extension methods to register Azure CosmosDB NoSQL instances on an . +/// Extension methods to register Azure CosmosDB NoSQL instances on an . /// -public static class CosmosNoSqlServiceCollectionExtensions +public static class CosmosDBServiceCollectionExtensions { private const string DynamicCodeMessage = "The Cosmos NoSQL provider is currently incompatible with NativeAOT."; private const string UnreferencedCodeMessage = "The Cosmos NoSQL provider is currently incompatible with trimming."; /// - /// Registers a as + /// Registers a as /// with retrieved from the dependency injection container. /// - /// + /// [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddCosmosNoSqlVectorStore( + public static IServiceCollection AddCosmosDBVectorStore( this IServiceCollection services, - CosmosNoSqlVectorStoreOptions? options = default, + CosmosDBVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) - => AddKeyedCosmosNoSqlVectorStore(services, serviceKey: null, options, lifetime); + => AddKeyedCosmosDBVectorStore(services, serviceKey: null, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// with retrieved from the dependency injection container. /// - /// The to register the on. + /// The to register the on. /// The key with which to associate the vector store. - /// Optional options to further configure the . + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddKeyedCosmosNoSqlVectorStore( + public static IServiceCollection AddKeyedCosmosDBVectorStore( this IServiceCollection services, object? serviceKey, - CosmosNoSqlVectorStoreOptions? options = default, + CosmosDBVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) { Throw.IfNull(services); - services.Add(new ServiceDescriptor(typeof(CosmosNoSqlVectorStore), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosDBVectorStore), serviceKey, (sp, _) => { var database = sp.GetRequiredService(); options = GetStoreOptions(sp, _ => options); - return new CosmosNoSqlVectorStore(database, options); + return new CosmosDBVectorStore(database, options); }, lifetime)); services.Add(new ServiceDescriptor(typeof(VectorStore), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); return services; } /// - /// Registers a as + /// Registers a as /// using the provided and . /// - /// + /// [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddCosmosNoSqlVectorStore( + public static IServiceCollection AddCosmosDBVectorStore( this IServiceCollection services, string connectionString, string databaseName, - CosmosNoSqlVectorStoreOptions? options = default, + CosmosDBVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) - => AddKeyedCosmosNoSqlVectorStore(services, serviceKey: null, connectionString, databaseName, options, lifetime); + => AddKeyedCosmosDBVectorStore(services, serviceKey: null, connectionString, databaseName, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// using the provided and . /// - /// The to register the on. + /// The to register the on. /// The key with which to associate the vector store. /// Connection string required to connect to Azure CosmosDB NoSQL. /// Database name for Azure CosmosDB NoSQL. - /// Optional options to further configure the . + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddKeyedCosmosNoSqlVectorStore( + public static IServiceCollection AddKeyedCosmosDBVectorStore( this IServiceCollection services, object? serviceKey, string connectionString, string databaseName, - CosmosNoSqlVectorStoreOptions? options = default, + CosmosDBVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) { Throw.IfNull(services); Throw.IfNullOrWhitespace(connectionString); Throw.IfNullOrWhitespace(databaseName); - services.Add(new ServiceDescriptor(typeof(CosmosNoSqlVectorStore), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosDBVectorStore), serviceKey, (sp, _) => { options = GetStoreOptions(sp, _ => options); var clientOptions = CreateClientOptions(options?.JsonSerializerOptions); - return new CosmosNoSqlVectorStore(connectionString, databaseName, clientOptions, options); + return new CosmosDBVectorStore(connectionString, databaseName, clientOptions, options); }, lifetime)); services.Add(new ServiceDescriptor(typeof(VectorStore), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); return services; } /// - /// Registers a as + /// Registers a as /// with retrieved from the dependency injection container. /// - /// + /// [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddCosmosNoSqlCollection( + public static IServiceCollection AddCosmosDBCollection( this IServiceCollection services, string name, - CosmosNoSqlCollectionOptions? options = default, + CosmosDBCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class - => AddKeyedCosmosNoSqlCollection(services, serviceKey: null, name, options, lifetime); + => AddKeyedCosmosDBCollection(services, serviceKey: null, name, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// with retrieved from the dependency injection container. /// /// The type of the key. /// The type of the record. - /// The to register the on. + /// The to register the on. /// The key with which to associate the collection. /// The name of the collection. - /// Optional options to further configure the . + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddKeyedCosmosNoSqlCollection( + public static IServiceCollection AddKeyedCosmosDBCollection( this IServiceCollection services, object? serviceKey, string name, - CosmosNoSqlCollectionOptions? options = default, + CosmosDBCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class @@ -164,12 +164,12 @@ public static IServiceCollection AddKeyedCosmosNoSqlCollection( Throw.IfNull(services); Throw.IfNullOrWhitespace(name); - services.Add(new ServiceDescriptor(typeof(CosmosNoSqlCollection), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosDBCollection), serviceKey, (sp, _) => { var database = sp.GetRequiredService(); options = GetCollectionOptions(sp, _ => options); - return new CosmosNoSqlCollection(database, name, options); + return new CosmosDBCollection(database, name, options); }, lifetime)); AddAbstractions(services, serviceKey, lifetime); @@ -178,46 +178,46 @@ public static IServiceCollection AddKeyedCosmosNoSqlCollection( } /// - /// Registers a as + /// Registers a as /// using the provided and . /// - /// + /// [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddCosmosNoSqlCollection( + public static IServiceCollection AddCosmosDBCollection( this IServiceCollection services, string name, string connectionString, string databaseName, - CosmosNoSqlCollectionOptions? options = default, + CosmosDBCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class - => AddKeyedCosmosNoSqlCollection(services, serviceKey: null, name, connectionString, databaseName, options, lifetime); + => AddKeyedCosmosDBCollection(services, serviceKey: null, name, connectionString, databaseName, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// using the provided and . /// /// The type of the key. /// The type of the record. - /// The to register the on. + /// The to register the on. /// The key with which to associate the collection. /// The name of the collection. /// Connection string required to connect to Azure CosmosDB NoSQL. /// Database name for Azure CosmosDB NoSQL. - /// Optional options to further configure the . + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddKeyedCosmosNoSqlCollection( + public static IServiceCollection AddKeyedCosmosDBCollection( this IServiceCollection services, object? serviceKey, string name, string connectionString, string databaseName, - CosmosNoSqlCollectionOptions? options = default, + CosmosDBCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class @@ -225,29 +225,29 @@ public static IServiceCollection AddKeyedCosmosNoSqlCollection( Throw.IfNullOrWhitespace(connectionString); Throw.IfNullOrWhitespace(databaseName); - return AddKeyedCosmosNoSqlCollection(services, serviceKey, name, _ => connectionString, _ => databaseName, _ => options!, lifetime); + return AddKeyedCosmosDBCollection(services, serviceKey, name, _ => connectionString, _ => databaseName, _ => options!, lifetime); } /// - /// Registers a as + /// Registers a as /// using the provided and . /// - /// + /// [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddCosmosNoSqlCollection( + public static IServiceCollection AddCosmosDBCollection( this IServiceCollection services, string name, Func connectionStringProvider, Func databaseNameProvider, - Func? optionsProvider = default, + Func? optionsProvider = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class - => AddKeyedCosmosNoSqlCollection(services, serviceKey: null, name, connectionStringProvider, databaseNameProvider, optionsProvider, lifetime); + => AddKeyedCosmosDBCollection(services, serviceKey: null, name, connectionStringProvider, databaseNameProvider, optionsProvider, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// using the provided and . /// /// The type of the key. @@ -262,13 +262,13 @@ public static IServiceCollection AddCosmosNoSqlCollection( /// Service collection. [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddKeyedCosmosNoSqlCollection( + public static IServiceCollection AddKeyedCosmosDBCollection( this IServiceCollection services, object? serviceKey, string name, Func connectionStringProvider, Func databaseNameProvider, - Func? optionsProvider = default, + Func? optionsProvider = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class @@ -278,12 +278,12 @@ public static IServiceCollection AddKeyedCosmosNoSqlCollection( Throw.IfNull(connectionStringProvider); Throw.IfNull(databaseNameProvider); - services.Add(new ServiceDescriptor(typeof(CosmosNoSqlCollection), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosDBCollection), serviceKey, (sp, _) => { var options = GetCollectionOptions(sp, optionsProvider); var clientOptions = CreateClientOptions(options?.JsonSerializerOptions); - return new CosmosNoSqlCollection( + return new CosmosDBCollection( connectionString: connectionStringProvider(sp), databaseName: databaseNameProvider(sp), name: name, @@ -301,16 +301,16 @@ private static void AddAbstractions(IServiceCollection services, where TRecord : class { services.Add(new ServiceDescriptor(typeof(VectorStoreCollection), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); services.Add(new ServiceDescriptor(typeof(IVectorSearchable), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); services.Add(new ServiceDescriptor(typeof(IKeywordHybridSearchable), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); } - private static CosmosNoSqlVectorStoreOptions? GetStoreOptions(IServiceProvider sp, Func? optionsProvider) + private static CosmosDBVectorStoreOptions? GetStoreOptions(IServiceProvider sp, Func? optionsProvider) { var options = optionsProvider?.Invoke(sp); if (options?.EmbeddingGenerator is not null) @@ -324,7 +324,7 @@ private static void AddAbstractions(IServiceCollection services, : new(options) { EmbeddingGenerator = embeddingGenerator }; // Create a brand new copy in order to avoid modifying the original options. } - private static CosmosNoSqlCollectionOptions? GetCollectionOptions(IServiceProvider sp, Func? optionsProvider) + private static CosmosDBCollectionOptions? GetCollectionOptions(IServiceProvider sp, Func? optionsProvider) { var options = optionsProvider?.Invoke(sp); if (options?.EmbeddingGenerator is not null) @@ -340,7 +340,7 @@ private static void AddAbstractions(IServiceCollection services, private static CosmosClientOptions CreateClientOptions(JsonSerializerOptions? jsonSerializerOptions) => new() { - ApplicationName = "CommunityToolkit.VectorData.CosmosNoSql", + ApplicationName = "CommunityToolkit.VectorData.AzureCosmosDB", UseSystemTextJsonSerializerWithOptions = jsonSerializerOptions ?? JsonSerializerOptions.Default, }; } diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlVectorStore.cs b/MEVD/src/AzureCosmosDB/CosmosDBVectorStore.cs similarity index 86% rename from MEVD/src/CosmosNoSql/CosmosNoSqlVectorStore.cs rename to MEVD/src/AzureCosmosDB/CosmosDBVectorStore.cs index 020fb57..e671b99 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlVectorStore.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBVectorStore.cs @@ -15,7 +15,7 @@ using Microsoft.Extensions.VectorData.ProviderServices; using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// /// Class for accessing the list of collections in a Azure CosmosDB NoSQL vector store. @@ -23,7 +23,7 @@ namespace CommunityToolkit.VectorData.CosmosNoSql; /// /// This class can be used with collections of any schema type, but requires you to provide schema information when getting a collection. /// -public sealed class CosmosNoSqlVectorStore : VectorStore +public sealed class CosmosDBVectorStore : VectorStore { /// Metadata about vector store. private readonly VectorStoreMetadata _metadata; @@ -40,35 +40,35 @@ public sealed class CosmosNoSqlVectorStore : VectorStore private readonly IEmbeddingGenerator? _embeddingGenerator; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// that can be used to manage the collections in Azure CosmosDB NoSQL. /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosNoSqlVectorStore(Database database, CosmosNoSqlVectorStoreOptions? options = null) + public CosmosDBVectorStore(Database database, CosmosDBVectorStoreOptions? options = null) : this(new(database.Client, ownsClient: false), _ => database, options) { Throw.IfNull(database); } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Connection string required to connect to Azure CosmosDB NoSQL. /// Database name for Azure CosmosDB NoSQL. /// Optional configuration options for . /// Optional configuration options for . - public CosmosNoSqlVectorStore(string connectionString, string databaseName, - CosmosClientOptions? clientOptions = null, CosmosNoSqlVectorStoreOptions? storeOptions = null) + public CosmosDBVectorStore(string connectionString, string databaseName, + CosmosClientOptions? clientOptions = null, CosmosDBVectorStoreOptions? storeOptions = null) : this(new ClientWrapper(new CosmosClient(connectionString, clientOptions), ownsClient: true), client => client.GetDatabase(databaseName), storeOptions) { Throw.IfNullOrWhitespace(connectionString); Throw.IfNullOrWhitespace(databaseName); } - private CosmosNoSqlVectorStore(ClientWrapper clientWrapper, - Func databaseProvider, CosmosNoSqlVectorStoreOptions? options) + private CosmosDBVectorStore(ClientWrapper clientWrapper, + Func databaseProvider, CosmosDBVectorStoreOptions? options) { try { @@ -78,7 +78,7 @@ private CosmosNoSqlVectorStore(ClientWrapper clientWrapper, this._metadata = new() { - VectorStoreSystemName = CosmosNoSqlConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosDBConstants.VectorStoreSystemName, VectorStoreName = this._database.Id }; } @@ -105,13 +105,13 @@ protected override void Dispose(bool disposing) [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] #if NET - public override CosmosNoSqlCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) + public override CosmosDBCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) #else public override VectorStoreCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) #endif => typeof(TRecord) == typeof(Dictionary) ? throw new ArgumentException(VectorDataStrings.GetCollectionWithDictionaryNotSupported) - : new CosmosNoSqlCollection( + : new CosmosDBCollection( this._clientWrapper.Share(), _ => this._database, name, @@ -126,11 +126,11 @@ public override VectorStoreCollection GetCollection> GetDynamicCollection(string name, VectorStoreCollectionDefinition definition) #endif - => new CosmosNoSqlDynamicCollection( + => new CosmosDBDynamicCollection( this._clientWrapper.Share(), _ => this._database, name, diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlVectorStoreOptions.cs b/MEVD/src/AzureCosmosDB/CosmosDBVectorStoreOptions.cs similarity index 69% rename from MEVD/src/CosmosNoSql/CosmosNoSqlVectorStoreOptions.cs rename to MEVD/src/AzureCosmosDB/CosmosDBVectorStoreOptions.cs index 76c8765..d147dc3 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlVectorStoreOptions.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDBVectorStoreOptions.cs @@ -4,21 +4,21 @@ using System.Text.Json; using Microsoft.Extensions.AI; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Options when creating a . +/// Options when creating a . /// -public sealed class CosmosNoSqlVectorStoreOptions +public sealed class CosmosDBVectorStoreOptions { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public CosmosNoSqlVectorStoreOptions() + public CosmosDBVectorStoreOptions() { } - internal CosmosNoSqlVectorStoreOptions(CosmosNoSqlVectorStoreOptions? source) + internal CosmosDBVectorStoreOptions(CosmosDBVectorStoreOptions? source) { this.JsonSerializerOptions = source?.JsonSerializerOptions; this.EmbeddingGenerator = source?.EmbeddingGenerator; diff --git a/MEVD/src/CosmosNoSql/ErrorHandlingFeedIterator.cs b/MEVD/src/AzureCosmosDB/ErrorHandlingFeedIterator.cs similarity index 97% rename from MEVD/src/CosmosNoSql/ErrorHandlingFeedIterator.cs rename to MEVD/src/AzureCosmosDB/ErrorHandlingFeedIterator.cs index e79d760..802ef7c 100644 --- a/MEVD/src/CosmosNoSql/ErrorHandlingFeedIterator.cs +++ b/MEVD/src/AzureCosmosDB/ErrorHandlingFeedIterator.cs @@ -6,7 +6,7 @@ using Microsoft.Azure.Cosmos; using Microsoft.Extensions.VectorData; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; internal class ErrorHandlingFeedIterator : FeedIterator { diff --git a/MEVD/src/CosmosNoSql/ICosmosNoSQLMapper.cs b/MEVD/src/AzureCosmosDB/ICosmosDBMapper.cs similarity index 87% rename from MEVD/src/CosmosNoSql/ICosmosNoSQLMapper.cs rename to MEVD/src/AzureCosmosDB/ICosmosDBMapper.cs index 957fcaa..f3c8440 100644 --- a/MEVD/src/CosmosNoSql/ICosmosNoSQLMapper.cs +++ b/MEVD/src/AzureCosmosDB/ICosmosDBMapper.cs @@ -5,9 +5,9 @@ using System.Text.Json.Nodes; using MEAI = Microsoft.Extensions.AI; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; -internal interface ICosmosNoSqlMapper +internal interface ICosmosDBMapper { /// /// Maps from the consumer record data model to the storage model. diff --git a/MEVD/src/CosmosNoSql/README.md b/MEVD/src/AzureCosmosDB/README.md similarity index 74% rename from MEVD/src/CosmosNoSql/README.md rename to MEVD/src/AzureCosmosDB/README.md index aba66f3..3247f51 100644 --- a/MEVD/src/CosmosNoSql/README.md +++ b/MEVD/src/AzureCosmosDB/README.md @@ -1,24 +1,24 @@ -# CommunityToolkit.VectorData.CosmosNoSql +# CommunityToolkit.VectorData.AzureCosmosDB -`CommunityToolkit.VectorData.CosmosNoSql` is the Azure Cosmos DB for NoSQL provider for `Microsoft.Extensions.VectorData`. +`CommunityToolkit.VectorData.AzureCosmosDB` is the Azure Cosmos DB for NoSQL provider for `Microsoft.Extensions.VectorData`. ## Install ```xml - + ``` ## Get started ```csharp using Microsoft.Azure.Cosmos; -using CommunityToolkit.VectorData.CosmosNoSql; +using CommunityToolkit.VectorData.AzureCosmosDB; using Microsoft.Extensions.VectorData; CosmosClient client = new(""); Database database = client.GetDatabase("vector-database"); -VectorStore vectorStore = new CosmosNoSqlVectorStore(database); +VectorStore vectorStore = new CosmosDBVectorStore(database); VectorStoreCollection collection = vectorStore.GetCollection("hotels"); ``` @@ -28,8 +28,8 @@ You can also register the provider with dependency injection: ```csharp using Microsoft.Extensions.DependencyInjection; -services.AddCosmosNoSqlVectorStore("", "vector-database"); -services.AddCosmosNoSqlCollection( +services.AddCosmosDBVectorStore("", "vector-database"); +services.AddCosmosDBCollection( name: "hotels", connectionString: "", databaseName: "vector-database"); diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSql.ConformanceTests.csproj b/MEVD/test/AzureCosmosDB.ConformanceTests/AzureCosmosDB.ConformanceTests.csproj similarity index 83% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSql.ConformanceTests.csproj rename to MEVD/test/AzureCosmosDB.ConformanceTests/AzureCosmosDB.ConformanceTests.csproj index b0552db..2faa0b7 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSql.ConformanceTests.csproj +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/AzureCosmosDB.ConformanceTests.csproj @@ -6,7 +6,7 @@ enable true false - CosmosNoSql.ConformanceTests + AzureCosmosDB.ConformanceTests @@ -17,7 +17,7 @@ - + diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBBasicModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBBasicModelTests.cs new file mode 100644 index 0000000..b94237b --- /dev/null +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBBasicModelTests.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureCosmosDB.ConformanceTests.Support; +using VectorData.ConformanceTests.ModelTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureCosmosDB.ConformanceTests; + +public sealed class CosmosDBBasicModelTests(CosmosDBBasicModelTests.Fixture fixture) + : BasicModelTests(fixture), IClassFixture +{ + public override Task SearchAsync_with_Skip() + { + Assert.SkipUnless(!((CosmosDBTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); + + return base.SearchAsync_with_Skip(); + } + + public new sealed class Fixture : BasicModelTests.Fixture + { + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBBasicModelTests))); + + public override TestStore TestStore => _store.Value; + } +} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlCollectionManagementTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBCollectionManagementTests.cs similarity index 57% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlCollectionManagementTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBCollectionManagementTests.cs index 5c3664e..de9f699 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlCollectionManagementTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBCollectionManagementTests.cs @@ -1,13 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlCollectionManagementTests(CosmosNoSqlFixture fixture) - : CollectionManagementTests(fixture), IClassFixture +public sealed class CosmosDBCollectionManagementTests(CosmosDBFixture fixture) + : CollectionManagementTests(fixture), IClassFixture { } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDataTypeTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDataTypeTests.cs similarity index 70% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDataTypeTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDataTypeTests.cs index 26357bd..068b21f 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDataTypeTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDataTypeTests.cs @@ -1,23 +1,23 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests.Support; using VectorData.ConformanceTests.TypeTests; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; // The type is internal to disable the tests due to emulator limitations -internal sealed class CosmosNoSqlDataTypeTests(CosmosNoSqlDataTypeTests.Fixture fixture) - : DataTypeTests.DefaultRecord>(fixture), IClassFixture +internal sealed class CosmosDBDataTypeTests(CosmosDBDataTypeTests.Fixture fixture) + : DataTypeTests.DefaultRecord>(fixture), IClassFixture { public override Task DateTimeOffset() => Task.CompletedTask; public new sealed class Fixture : DataTypeTests.DefaultRecord>.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlDataTypeTests))); + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBDataTypeTests))); public override TestStore TestStore => _store.Value; diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDependencyInjectionTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDependencyInjectionTests.cs similarity index 52% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDependencyInjectionTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDependencyInjectionTests.cs index d269e77..f62204d 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDependencyInjectionTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDependencyInjectionTests.cs @@ -1,15 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CommunityToolkit.VectorData.CosmosNoSql; +using CommunityToolkit.VectorData.AzureCosmosDB; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using VectorData.ConformanceTests; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlDependencyInjectionTests - : DependencyInjectionTests.Record>, string, DependencyInjectionTests.Record> +public sealed class CosmosDBDependencyInjectionTests + : DependencyInjectionTests.Record>, string, DependencyInjectionTests.Record> { private const string TestConnectionString = "AccountEndpoint=https://localhost:8081;AccountKey=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="; @@ -18,8 +18,8 @@ public sealed class CosmosNoSqlDependencyInjectionTests get { yield return (services, serviceKey, lifetime) => serviceKey is null - ? services.AddCosmosNoSqlVectorStore(TestConnectionString, nameof(CosmosNoSqlDependencyInjectionTests), lifetime: lifetime) - : services.AddKeyedCosmosNoSqlVectorStore(serviceKey, TestConnectionString, nameof(CosmosNoSqlDependencyInjectionTests), lifetime: lifetime); + ? services.AddCosmosDBVectorStore(TestConnectionString, nameof(CosmosDBDependencyInjectionTests), lifetime: lifetime) + : services.AddKeyedCosmosDBVectorStore(serviceKey, TestConnectionString, nameof(CosmosDBDependencyInjectionTests), lifetime: lifetime); } } @@ -28,8 +28,8 @@ public sealed class CosmosNoSqlDependencyInjectionTests get { yield return (services, serviceKey, name, lifetime) => serviceKey is null - ? services.AddCosmosNoSqlCollection(name, TestConnectionString, nameof(CosmosNoSqlDependencyInjectionTests), lifetime: lifetime) - : services.AddKeyedCosmosNoSqlCollection(serviceKey, name, TestConnectionString, nameof(CosmosNoSqlDependencyInjectionTests), lifetime: lifetime); + ? services.AddCosmosDBCollection(name, TestConnectionString, nameof(CosmosDBDependencyInjectionTests), lifetime: lifetime) + : services.AddKeyedCosmosDBCollection(serviceKey, name, TestConnectionString, nameof(CosmosDBDependencyInjectionTests), lifetime: lifetime); } } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDistanceFunctionTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDistanceFunctionTests.cs similarity index 69% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDistanceFunctionTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDistanceFunctionTests.cs index b847702..502a75a 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDistanceFunctionTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDistanceFunctionTests.cs @@ -1,15 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlDistanceFunctionTests(CosmosNoSqlDistanceFunctionTests.Fixture fixture) - : DistanceFunctionTests(fixture), IClassFixture +public sealed class CosmosDBDistanceFunctionTests(CosmosDBDistanceFunctionTests.Fixture fixture) + : DistanceFunctionTests(fixture), IClassFixture { public override Task CosineDistance() => Assert.ThrowsAsync(base.CosineDistance); public override Task EuclideanSquaredDistance() => Assert.ThrowsAsync(base.EuclideanSquaredDistance); @@ -19,14 +19,14 @@ public sealed class CosmosNoSqlDistanceFunctionTests(CosmosNoSqlDistanceFunction public override Task EuclideanDistance() { - Assert.SkipUnless(!((CosmosNoSqlTestStore)fixture.TestStore).UsesLocalEmulator, "Fails on emulator, most likely due to emulator bug"); + Assert.SkipUnless(!((CosmosDBTestStore)fixture.TestStore).UsesLocalEmulator, "Fails on emulator, most likely due to emulator bug"); return base.EuclideanDistance(); } public new sealed class Fixture : DistanceFunctionTests.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlDistanceFunctionTests))); + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBDistanceFunctionTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDynamicModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDynamicModelTests.cs similarity index 50% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDynamicModelTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDynamicModelTests.cs index 20cdc0c..526e00c 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDynamicModelTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDynamicModelTests.cs @@ -1,27 +1,27 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests.ModelTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlDynamicModelTests(CosmosNoSqlDynamicModelTests.Fixture fixture) - : DynamicModelTests(fixture), IClassFixture +public sealed class CosmosDBDynamicModelTests(CosmosDBDynamicModelTests.Fixture fixture) + : DynamicModelTests(fixture), IClassFixture { public override Task SearchAsync_with_Skip() { // The vNext emulator's DiskANN index does not support OFFSET in vector search. - Assert.SkipUnless(!((CosmosNoSqlTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); + Assert.SkipUnless(!((CosmosDBTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); return base.SearchAsync_with_Skip(); } public new sealed class Fixture : DynamicModelTests.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlDynamicModelTests))); + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBDynamicModelTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingGenerationTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingGenerationTests.cs new file mode 100644 index 0000000..039c450 --- /dev/null +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingGenerationTests.cs @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureCosmosDB.ConformanceTests.Support; +using CommunityToolkit.VectorData.AzureCosmosDB; +using Microsoft.Extensions.AI; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.VectorData; +using VectorData.ConformanceTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureCosmosDB.ConformanceTests; + +public sealed class CosmosDBEmbeddingGenerationTests( + CosmosDBEmbeddingGenerationTests.StringVectorFixture stringVectorFixture, + CosmosDBEmbeddingGenerationTests.RomOfFloatVectorFixture romOfFloatVectorFixture) + : EmbeddingGenerationTests(stringVectorFixture, romOfFloatVectorFixture), + IClassFixture, + IClassFixture +{ + public new sealed class StringVectorFixture : EmbeddingGenerationTests.StringVectorFixture + { + public override string DefaultIndexKind => "DiskAnn"; + + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBEmbeddingGenerationTests))); + + public override TestStore TestStore => _store.Value; + + public override VectorStoreCollectionDefinition CreateRecordDefinition() + => CosmosDBConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); + + public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator = null) + => new CosmosDBVectorStore( + ((CosmosDBTestStore)TestStore).Database, + new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosDBTestStore.SerializerOptions }); + + public override Func[] DependencyInjectionStoreRegistrationDelegates => + [ + services => services + .AddSingleton(((CosmosDBTestStore)TestStore).Database) + .AddCosmosDBVectorStore(new() + { + JsonSerializerOptions = CosmosDBTestStore.SerializerOptions, + }), + ]; + + public override Func[] DependencyInjectionCollectionRegistrationDelegates => + [ + services => services + .AddSingleton(((CosmosDBTestStore)TestStore).Database) + .AddCosmosDBCollection(CollectionName, new() + { + JsonSerializerOptions = CosmosDBTestStore.SerializerOptions, + }), + ]; + } + + public new sealed class RomOfFloatVectorFixture : EmbeddingGenerationTests.RomOfFloatVectorFixture + { + public override string DefaultIndexKind => "DiskAnn"; + + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBEmbeddingGenerationTests))); + + public override TestStore TestStore => _store.Value; + + public override VectorStoreCollectionDefinition CreateRecordDefinition() + => CosmosDBConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); + + public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator = null) + => new CosmosDBVectorStore( + ((CosmosDBTestStore)TestStore).Database, + new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosDBTestStore.SerializerOptions }); + + public override Func[] DependencyInjectionStoreRegistrationDelegates => + [ + services => services.AddCosmosDBVectorStore( + ((CosmosDBTestStore)TestStore).ConnectionString, + nameof(CosmosDBEmbeddingGenerationTests), + new() { JsonSerializerOptions = CosmosDBTestStore.SerializerOptions }) + ]; + + public override Func[] DependencyInjectionCollectionRegistrationDelegates => + [ + services => services.AddCosmosDBCollection( + CollectionName, + ((CosmosDBTestStore)TestStore).ConnectionString, + nameof(CosmosDBEmbeddingGenerationTests), + new() { JsonSerializerOptions = CosmosDBTestStore.SerializerOptions }) + ]; + } +} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingTypeTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingTypeTests.cs similarity index 64% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingTypeTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingTypeTests.cs index d551e7f..3eacaf7 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingTypeTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingTypeTests.cs @@ -1,23 +1,23 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using Microsoft.Extensions.AI; using Microsoft.Extensions.VectorData; using VectorData.ConformanceTests.Support; using VectorData.ConformanceTests.TypeTests; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlEmbeddingTypeTests(CosmosNoSqlEmbeddingTypeTests.Fixture fixture) - : EmbeddingTypeTests(fixture), IClassFixture +public sealed class CosmosDBEmbeddingTypeTests(CosmosDBEmbeddingTypeTests.Fixture fixture) + : EmbeddingTypeTests(fixture), IClassFixture { public new sealed class Fixture : EmbeddingTypeTests.Fixture { public override string DefaultIndexKind => "DiskAnn"; - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlEmbeddingTypeTests))); + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBEmbeddingTypeTests))); public override TestStore TestStore => _store.Value; @@ -25,7 +25,7 @@ public override VectorStoreCollectionDefinition CreateRecordDefinition CosmosNoSqlConformanceTestHelpers.UseLowerCaseVectorStorageName( + => CosmosDBConformanceTestHelpers.UseLowerCaseVectorStorageName( base.CreateRecordDefinition(embeddingGenerator, distanceFunction, dimensions), "vector"); } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlFilterTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBFilterTests.cs similarity index 54% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlFilterTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBFilterTests.cs index 5e95100..5232352 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlFilterTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBFilterTests.cs @@ -1,20 +1,20 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; // The type is internal to disable the tests due to emulator limitations -internal sealed class CosmosNoSqlFilterTests(CosmosNoSqlFilterTests.Fixture fixture) - : FilterTests(fixture), IClassFixture +internal sealed class CosmosDBFilterTests(CosmosDBFilterTests.Fixture fixture) + : FilterTests(fixture), IClassFixture { public new sealed class Fixture : FilterTests.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlFilterTests))); + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBFilterTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlHybridSearchTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBHybridSearchTests.cs similarity index 51% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlHybridSearchTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBHybridSearchTests.cs index 94151ee..7fe6639 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlHybridSearchTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBHybridSearchTests.cs @@ -1,31 +1,31 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; // The type is internal to disable the tests due to emulator limitations -internal sealed class CosmosNoSqlHybridSearchTests( - CosmosNoSqlHybridSearchTests.VectorAndStringFixture vectorAndStringFixture, - CosmosNoSqlHybridSearchTests.MultiTextFixture multiTextFixture) +internal sealed class CosmosDBHybridSearchTests( + CosmosDBHybridSearchTests.VectorAndStringFixture vectorAndStringFixture, + CosmosDBHybridSearchTests.MultiTextFixture multiTextFixture) : HybridSearchTests(vectorAndStringFixture, multiTextFixture), - IClassFixture, - IClassFixture + IClassFixture, + IClassFixture { public new sealed class VectorAndStringFixture : HybridSearchTests.VectorAndStringFixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(VectorAndStringFixture))); + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(VectorAndStringFixture))); public override TestStore TestStore => _store.Value; } public new sealed class MultiTextFixture : HybridSearchTests.MultiTextFixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(MultiTextFixture))); + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(MultiTextFixture))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBIndexKindTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBIndexKindTests.cs new file mode 100644 index 0000000..29b33cc --- /dev/null +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBIndexKindTests.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureCosmosDB.ConformanceTests.Support; +using VectorData.ConformanceTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureCosmosDB.ConformanceTests; + +public sealed class CosmosDBIndexKindTests(CosmosDBIndexKindTests.Fixture fixture) + : IndexKindTests(fixture), IClassFixture +{ + [Fact] + public Task DiskAnn() => Test("DiskAnn"); + + public override Task Flat() + { + Assert.SkipUnless(!((CosmosDBTestStore)fixture.TestStore).UsesLocalEmulator, "Not supported on emulator."); + + return base.Flat(); + } + + public new sealed class Fixture : IndexKindTests.Fixture + { + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBIndexKindTests))); + + public override TestStore TestStore => _store.Value; + } +} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlKeyTypeTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBKeyTypeTests.cs similarity index 50% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlKeyTypeTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBKeyTypeTests.cs index 57a46ed..6df92e7 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlKeyTypeTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBKeyTypeTests.cs @@ -1,19 +1,19 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests.Support; using VectorData.ConformanceTests.TypeTests; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlKeyTypeTests(CosmosNoSqlKeyTypeTests.Fixture fixture) - : KeyTypeTests(fixture), IClassFixture +public sealed class CosmosDBKeyTypeTests(CosmosDBKeyTypeTests.Fixture fixture) + : KeyTypeTests(fixture), IClassFixture { public new sealed class Fixture : KeyTypeTests.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlKeyTypeTests))); + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBKeyTypeTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlMultiVectorModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBMultiVectorModelTests.cs similarity index 56% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlMultiVectorModelTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBMultiVectorModelTests.cs index 659f76e..864060a 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlMultiVectorModelTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBMultiVectorModelTests.cs @@ -1,19 +1,19 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests.ModelTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlMultiVectorModelTests(CosmosNoSqlMultiVectorModelTests.Fixture fixture) - : MultiVectorModelTests(fixture), IClassFixture +public sealed class CosmosDBMultiVectorModelTests(CosmosDBMultiVectorModelTests.Fixture fixture) + : MultiVectorModelTests(fixture), IClassFixture { public new sealed class Fixture : MultiVectorModelTests.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlMultiVectorModelTests))); + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBMultiVectorModelTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoDataModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoDataModelTests.cs new file mode 100644 index 0000000..07c16d2 --- /dev/null +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoDataModelTests.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureCosmosDB.ConformanceTests.Support; +using VectorData.ConformanceTests.ModelTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureCosmosDB.ConformanceTests; + +public sealed class CosmosDBNoDataModelTests(CosmosDBNoDataModelTests.Fixture fixture) + : NoDataModelTests(fixture), IClassFixture +{ + public new sealed class Fixture : NoDataModelTests.Fixture + { + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBNoDataModelTests))); + + public override TestStore TestStore => _store.Value; + } +} diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoVectorModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoVectorModelTests.cs new file mode 100644 index 0000000..1bd1032 --- /dev/null +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoVectorModelTests.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureCosmosDB.ConformanceTests.Support; +using VectorData.ConformanceTests.ModelTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureCosmosDB.ConformanceTests; + +public sealed class CosmosDBNoVectorModelTests(CosmosDBNoVectorModelTests.Fixture fixture) + : NoVectorModelTests(fixture), IClassFixture +{ + public new sealed class Fixture : NoVectorModelTests.Fixture + { + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBNoVectorModelTests))); + + public override TestStore TestStore => _store.Value; + } +} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlTestSuiteImplementationTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBTestSuiteImplementationTests.cs similarity index 79% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlTestSuiteImplementationTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBTestSuiteImplementationTests.cs index a84ae45..4b12ffc 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlTestSuiteImplementationTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBTestSuiteImplementationTests.cs @@ -4,9 +4,9 @@ using VectorData.ConformanceTests; using VectorData.ConformanceTests.TypeTests; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlTestSuiteImplementationTests : TestSuiteImplementationTests +public sealed class CosmosDBTestSuiteImplementationTests : TestSuiteImplementationTests { protected override ICollection IgnoredTestBases { get; } = [ diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlConformanceTestHelpers.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBConformanceTestHelpers.cs similarity index 84% rename from MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlConformanceTestHelpers.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBConformanceTestHelpers.cs index 91d2106..ac7be07 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlConformanceTestHelpers.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBConformanceTestHelpers.cs @@ -3,9 +3,9 @@ using Microsoft.Extensions.VectorData; -namespace CosmosNoSql.ConformanceTests.Support; +namespace AzureCosmosDB.ConformanceTests.Support; -internal static class CosmosNoSqlConformanceTestHelpers +internal static class CosmosDBConformanceTestHelpers { public static VectorStoreCollectionDefinition UseLowerCaseVectorStorageName( VectorStoreCollectionDefinition definition, diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlFixture.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBFixture.cs similarity index 51% rename from MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlFixture.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBFixture.cs index f57f66c..7738291 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlFixture.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBFixture.cs @@ -3,11 +3,11 @@ using VectorData.ConformanceTests.Support; -namespace CosmosNoSql.ConformanceTests.Support; +namespace AzureCosmosDB.ConformanceTests.Support; -public sealed class CosmosNoSqlFixture : VectorStoreFixture +public sealed class CosmosDBFixture : VectorStoreFixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlFixture))); + private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBFixture))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestEnvironment.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestEnvironment.cs similarity index 85% rename from MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestEnvironment.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestEnvironment.cs index faa6157..c254f4d 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestEnvironment.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestEnvironment.cs @@ -3,17 +3,17 @@ using Microsoft.Extensions.Configuration; -namespace CosmosNoSql.ConformanceTests.Support; +namespace AzureCosmosDB.ConformanceTests.Support; #pragma warning disable CA1810 // Initialize all static fields when those fields are declared -internal static class CosmosNoSqlTestEnvironment +internal static class CosmosDBTestEnvironment { public static readonly string? ConnectionString; public static bool IsConnectionStringDefined => ConnectionString is not null; - static CosmosNoSqlTestEnvironment() + static CosmosDBTestEnvironment() { var configuration = new ConfigurationBuilder() .AddJsonFile(path: "testsettings.json", optional: true) diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestStore.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestStore.cs similarity index 86% rename from MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestStore.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestStore.cs index 0998d11..7fb1c30 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestStore.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestStore.cs @@ -2,18 +2,18 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Text.Json; -using CommunityToolkit.VectorData.CosmosNoSql; +using CommunityToolkit.VectorData.AzureCosmosDB; using Microsoft.Azure.Cosmos; using Microsoft.Extensions.VectorData; using Testcontainers.CosmosDb; using VectorData.ConformanceTests.Support; -namespace CosmosNoSql.ConformanceTests.Support; +namespace AzureCosmosDB.ConformanceTests.Support; #pragma warning disable CA1001 // Type owns disposable fields but is not disposable /// The emulator does not support running multiple queries simultaneously, so we create a unique database for each test store instance. -internal sealed class CosmosNoSqlTestStore(string uniqueDatabaseName) : TestStore +internal sealed class CosmosDBTestStore(string uniqueDatabaseName) : TestStore { private CosmosDbContainer? _container; private CosmosClient? _client; @@ -29,7 +29,7 @@ internal sealed class CosmosNoSqlTestStore(string uniqueDatabaseName) : TestStor public static JsonSerializerOptions SerializerOptions { get; } = new(JsonSerializerDefaults.Web) { - PropertyNamingPolicy = new CosmosNoSqlTestJsonNamingPolicy() + PropertyNamingPolicy = new CosmosDBTestJsonNamingPolicy() }; public Database Database => _database ?? throw new InvalidOperationException("Cosmos DB test store has not been started."); @@ -37,7 +37,7 @@ internal sealed class CosmosNoSqlTestStore(string uniqueDatabaseName) : TestStor public override VectorStoreCollection CreateCollection( string name, VectorStoreCollectionDefinition definition) - => new CosmosNoSqlCollection( + => new CosmosDBCollection( Database, name, new() @@ -49,7 +49,7 @@ public override VectorStoreCollection CreateCollection> CreateDynamicCollection( string name, VectorStoreCollectionDefinition definition) - => new CosmosNoSqlDynamicCollection( + => new CosmosDBDynamicCollection( Database, name, new() @@ -60,9 +60,9 @@ public override VectorStoreCollection CreateCollection CreateDatabaseWithRetryAsync() throw new TimeoutException("Cosmos DB did not become available within one minute."); } - private sealed class CosmosNoSqlTestJsonNamingPolicy : JsonNamingPolicy + private sealed class CosmosDBTestJsonNamingPolicy : JsonNamingPolicy { public override string ConvertName(string name) => name is "Vector" or "Embedding" diff --git a/MEVD/test/CosmosNoSql.UnitTests/CosmosNoSql.UnitTests.csproj b/MEVD/test/AzureCosmosDB.UnitTests/AzureCosmosDB.UnitTests.csproj similarity index 72% rename from MEVD/test/CosmosNoSql.UnitTests/CosmosNoSql.UnitTests.csproj rename to MEVD/test/AzureCosmosDB.UnitTests/AzureCosmosDB.UnitTests.csproj index a5a5be1..8a09eab 100644 --- a/MEVD/test/CosmosNoSql.UnitTests/CosmosNoSql.UnitTests.csproj +++ b/MEVD/test/AzureCosmosDB.UnitTests/AzureCosmosDB.UnitTests.csproj @@ -1,8 +1,8 @@  - CommunityToolkit.VectorData.CosmosNoSql.UnitTests - CommunityToolkit.VectorData.CosmosNoSql.UnitTests + CommunityToolkit.VectorData.AzureCosmosDB.UnitTests + CommunityToolkit.VectorData.AzureCosmosDB.UnitTests net10.0 true enable @@ -19,6 +19,6 @@ - + diff --git a/MEVD/test/CosmosNoSql.UnitTests/CosmosNoSqlOptionsTests.cs b/MEVD/test/AzureCosmosDB.UnitTests/CosmosDBOptionsTests.cs similarity index 83% rename from MEVD/test/CosmosNoSql.UnitTests/CosmosNoSqlOptionsTests.cs rename to MEVD/test/AzureCosmosDB.UnitTests/CosmosDBOptionsTests.cs index 3d5febf..4cf42a6 100644 --- a/MEVD/test/CosmosNoSql.UnitTests/CosmosNoSqlOptionsTests.cs +++ b/MEVD/test/AzureCosmosDB.UnitTests/CosmosDBOptionsTests.cs @@ -3,19 +3,19 @@ using System.Collections.Generic; using System.Text.Json; -using CommunityToolkit.VectorData.CosmosNoSql; +using CommunityToolkit.VectorData.AzureCosmosDB; using Microsoft.Azure.Cosmos; using Xunit; -namespace CommunityToolkit.VectorData.CosmosNoSql.UnitTests; +namespace CommunityToolkit.VectorData.AzureCosmosDB.UnitTests; -public sealed class CosmosNoSqlOptionsTests +public sealed class CosmosDBOptionsTests { [Fact] public void CollectionOptionsPropertiesCanBeConfigured() { JsonSerializerOptions serializerOptions = new(JsonSerializerDefaults.Web); - CosmosNoSqlCollectionOptions source = new() + CosmosDBCollectionOptions source = new() { JsonSerializerOptions = serializerOptions, PartitionKeyProperties = new[] { "tenantId", "category" }, @@ -35,7 +35,7 @@ public void CollectionOptionsPropertiesCanBeConfigured() public void VectorStoreOptionsPropertiesCanBeConfigured() { JsonSerializerOptions serializerOptions = new(JsonSerializerDefaults.Web); - CosmosNoSqlVectorStoreOptions source = new() + CosmosDBVectorStoreOptions source = new() { JsonSerializerOptions = serializerOptions, }; diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlBasicModelTests.cs b/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlBasicModelTests.cs deleted file mode 100644 index cc8b326..0000000 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlBasicModelTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using CosmosNoSql.ConformanceTests.Support; -using VectorData.ConformanceTests.ModelTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosNoSql.ConformanceTests; - -public sealed class CosmosNoSqlBasicModelTests(CosmosNoSqlBasicModelTests.Fixture fixture) - : BasicModelTests(fixture), IClassFixture -{ - public override Task SearchAsync_with_Skip() - { - Assert.SkipUnless(!((CosmosNoSqlTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); - - return base.SearchAsync_with_Skip(); - } - - public new sealed class Fixture : BasicModelTests.Fixture - { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlBasicModelTests))); - - public override TestStore TestStore => _store.Value; - } -} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingGenerationTests.cs b/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingGenerationTests.cs deleted file mode 100644 index bf210af..0000000 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingGenerationTests.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using CosmosNoSql.ConformanceTests.Support; -using CommunityToolkit.VectorData.CosmosNoSql; -using Microsoft.Extensions.AI; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.VectorData; -using VectorData.ConformanceTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosNoSql.ConformanceTests; - -public sealed class CosmosNoSqlEmbeddingGenerationTests( - CosmosNoSqlEmbeddingGenerationTests.StringVectorFixture stringVectorFixture, - CosmosNoSqlEmbeddingGenerationTests.RomOfFloatVectorFixture romOfFloatVectorFixture) - : EmbeddingGenerationTests(stringVectorFixture, romOfFloatVectorFixture), - IClassFixture, - IClassFixture -{ - public new sealed class StringVectorFixture : EmbeddingGenerationTests.StringVectorFixture - { - public override string DefaultIndexKind => "DiskAnn"; - - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlEmbeddingGenerationTests))); - - public override TestStore TestStore => _store.Value; - - public override VectorStoreCollectionDefinition CreateRecordDefinition() - => CosmosNoSqlConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); - - public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator = null) - => new CosmosNoSqlVectorStore( - ((CosmosNoSqlTestStore)TestStore).Database, - new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions }); - - public override Func[] DependencyInjectionStoreRegistrationDelegates => - [ - services => services - .AddSingleton(((CosmosNoSqlTestStore)TestStore).Database) - .AddCosmosNoSqlVectorStore(new() - { - JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions, - }), - ]; - - public override Func[] DependencyInjectionCollectionRegistrationDelegates => - [ - services => services - .AddSingleton(((CosmosNoSqlTestStore)TestStore).Database) - .AddCosmosNoSqlCollection(CollectionName, new() - { - JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions, - }), - ]; - } - - public new sealed class RomOfFloatVectorFixture : EmbeddingGenerationTests.RomOfFloatVectorFixture - { - public override string DefaultIndexKind => "DiskAnn"; - - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlEmbeddingGenerationTests))); - - public override TestStore TestStore => _store.Value; - - public override VectorStoreCollectionDefinition CreateRecordDefinition() - => CosmosNoSqlConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); - - public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator = null) - => new CosmosNoSqlVectorStore( - ((CosmosNoSqlTestStore)TestStore).Database, - new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions }); - - public override Func[] DependencyInjectionStoreRegistrationDelegates => - [ - services => services.AddCosmosNoSqlVectorStore( - ((CosmosNoSqlTestStore)TestStore).ConnectionString, - nameof(CosmosNoSqlEmbeddingGenerationTests), - new() { JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions }) - ]; - - public override Func[] DependencyInjectionCollectionRegistrationDelegates => - [ - services => services.AddCosmosNoSqlCollection( - CollectionName, - ((CosmosNoSqlTestStore)TestStore).ConnectionString, - nameof(CosmosNoSqlEmbeddingGenerationTests), - new() { JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions }) - ]; - } -} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlIndexKindTests.cs b/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlIndexKindTests.cs deleted file mode 100644 index 0a68893..0000000 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlIndexKindTests.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using CosmosNoSql.ConformanceTests.Support; -using VectorData.ConformanceTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosNoSql.ConformanceTests; - -public sealed class CosmosNoSqlIndexKindTests(CosmosNoSqlIndexKindTests.Fixture fixture) - : IndexKindTests(fixture), IClassFixture -{ - [Fact] - public Task DiskAnn() => Test("DiskAnn"); - - public override Task Flat() - { - Assert.SkipUnless(!((CosmosNoSqlTestStore)fixture.TestStore).UsesLocalEmulator, "Not supported on emulator."); - - return base.Flat(); - } - - public new sealed class Fixture : IndexKindTests.Fixture - { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlIndexKindTests))); - - public override TestStore TestStore => _store.Value; - } -} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoDataModelTests.cs b/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoDataModelTests.cs deleted file mode 100644 index 944fc09..0000000 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoDataModelTests.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using CosmosNoSql.ConformanceTests.Support; -using VectorData.ConformanceTests.ModelTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosNoSql.ConformanceTests; - -public sealed class CosmosNoSqlNoDataModelTests(CosmosNoSqlNoDataModelTests.Fixture fixture) - : NoDataModelTests(fixture), IClassFixture -{ - public new sealed class Fixture : NoDataModelTests.Fixture - { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlNoDataModelTests))); - - public override TestStore TestStore => _store.Value; - } -} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoVectorModelTests.cs b/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoVectorModelTests.cs deleted file mode 100644 index 7268f04..0000000 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoVectorModelTests.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using CosmosNoSql.ConformanceTests.Support; -using VectorData.ConformanceTests.ModelTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosNoSql.ConformanceTests; - -public sealed class CosmosNoSqlNoVectorModelTests(CosmosNoSqlNoVectorModelTests.Fixture fixture) - : NoVectorModelTests(fixture), IClassFixture -{ - public new sealed class Fixture : NoVectorModelTests.Fixture - { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlNoVectorModelTests))); - - public override TestStore TestStore => _store.Value; - } -} diff --git a/README.md b/README.md index 10c9f03..3ef7a71 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ The following NuGet packages have been published: | Package | Version | Downloads | |---------|---------|-----------| | [CommunityToolkit.VectorData.AzureAISearch] | ![AzureAISearch Version][v-azureaisearch] | ![AzureAISearch Downloads][d-azureaisearch] | +| [CommunityToolkit.VectorData.AzureCosmosDB] | ![AzureCosmosDB Version][v-azurecosmosdb] | ![AzureCosmosDB Downloads][d-azurecosmosdb] | | [CommunityToolkit.VectorData.AzureDocumentDB] | ![AzureDocumentDB Version][v-azuredocumentdb] | ![AzureDocumentDB Downloads][d-azuredocumentdb] | -| [CommunityToolkit.VectorData.CosmosNoSql] | ![CosmosNoSql Version][v-cosmosnosql] | ![CosmosNoSql Downloads][d-cosmosnosql] | | [CommunityToolkit.VectorData.InMemory] | ![InMemory Version][v-inmemory] | ![InMemory Downloads][d-inmemory] | | [CommunityToolkit.VectorData.PgVector] | ![PgVector Version][v-pgvector] | ![PgVector Downloads][d-pgvector] | | [CommunityToolkit.VectorData.Qdrant] | ![Qdrant Version][v-qdrant] | ![Qdrant Downloads][d-qdrant] | @@ -52,8 +52,8 @@ The Vector Data connectors in this toolkit were initially part of the [Semantic [CommunityToolkit.VectorData.AzureAISearch]: https://www.nuget.org/packages/CommunityToolkit.VectorData.AzureAISearch +[CommunityToolkit.VectorData.AzureCosmosDB]: https://www.nuget.org/packages/CommunityToolkit.VectorData.AzureCosmosDB [CommunityToolkit.VectorData.AzureDocumentDB]: https://www.nuget.org/packages/CommunityToolkit.VectorData.AzureDocumentDB -[CommunityToolkit.VectorData.CosmosNoSql]: https://www.nuget.org/packages/CommunityToolkit.VectorData.CosmosNoSql [CommunityToolkit.VectorData.InMemory]: https://www.nuget.org/packages/CommunityToolkit.VectorData.InMemory [CommunityToolkit.VectorData.PgVector]: https://www.nuget.org/packages/CommunityToolkit.VectorData.PgVector [CommunityToolkit.VectorData.Qdrant]: https://www.nuget.org/packages/CommunityToolkit.VectorData.Qdrant @@ -64,8 +64,8 @@ The Vector Data connectors in this toolkit were initially part of the [Semantic [v-azureaisearch]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.AzureAISearch +[v-azurecosmosdb]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.AzureCosmosDB [v-azuredocumentdb]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.AzureDocumentDB -[v-cosmosnosql]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.CosmosNoSql [v-inmemory]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.InMemory [v-pgvector]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.PgVector [v-qdrant]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.Qdrant @@ -76,8 +76,8 @@ The Vector Data connectors in this toolkit were initially part of the [Semantic [d-azureaisearch]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.AzureAISearch +[d-azurecosmosdb]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.AzureCosmosDB [d-azuredocumentdb]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.AzureDocumentDB -[d-cosmosnosql]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.CosmosNoSql [d-inmemory]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.InMemory [d-pgvector]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.PgVector [d-qdrant]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.Qdrant From de1682869feca11974f1cee5db1499a1d8d4fe46 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Aug 2026 10:22:00 +0000 Subject: [PATCH 2/3] Remove DB acronym from Cosmos type/method names, add package tags Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com> --- MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj | 1 + ...mosDBCollection.cs => CosmosCollection.cs} | 98 ++++++------ ...nOptions.cs => CosmosCollectionOptions.cs} | 16 +- ...der.cs => CosmosCollectionQueryBuilder.cs} | 12 +- ...osmosDBConstants.cs => CosmosConstants.cs} | 6 +- ...llection.cs => CosmosDynamicCollection.cs} | 30 ++-- ...ynamicMapper.cs => CosmosDynamicMapper.cs} | 10 +- ...ranslator.cs => CosmosFilterTranslator.cs} | 4 +- .../{CosmosDBKey.cs => CosmosKey.cs} | 56 +++---- .../{CosmosDBMapper.cs => CosmosMapper.cs} | 12 +- ...BModelBuilder.cs => CosmosModelBuilder.cs} | 10 +- ...s => CosmosServiceCollectionExtensions.cs} | 140 +++++++++--------- ...sDBVectorStore.cs => CosmosVectorStore.cs} | 36 ++--- ...Options.cs => CosmosVectorStoreOptions.cs} | 12 +- .../{ICosmosDBMapper.cs => ICosmosMapper.cs} | 2 +- MEVD/src/AzureCosmosDB/README.md | 6 +- ...ModelTests.cs => CosmosBasicModelTests.cs} | 8 +- ....cs => CosmosCollectionManagementTests.cs} | 4 +- ...ataTypeTests.cs => CosmosDataTypeTests.cs} | 6 +- ...s.cs => CosmosDependencyInjectionTests.cs} | 12 +- ...ests.cs => CosmosDistanceFunctionTests.cs} | 8 +- ...delTests.cs => CosmosDynamicModelTests.cs} | 8 +- ...s.cs => CosmosEmbeddingGenerationTests.cs} | 58 ++++---- ...peTests.cs => CosmosEmbeddingTypeTests.cs} | 8 +- ...sDBFilterTests.cs => CosmosFilterTests.cs} | 6 +- ...rchTests.cs => CosmosHybridSearchTests.cs} | 14 +- ...exKindTests.cs => CosmosIndexKindTests.cs} | 8 +- ...BKeyTypeTests.cs => CosmosKeyTypeTests.cs} | 6 +- ...ests.cs => CosmosMultiVectorModelTests.cs} | 6 +- ...odelTests.cs => CosmosNoDataModelTests.cs} | 6 +- ...elTests.cs => CosmosNoVectorModelTests.cs} | 6 +- ... => CosmosTestSuiteImplementationTests.cs} | 2 +- ...ers.cs => CosmosConformanceTestHelpers.cs} | 2 +- .../{CosmosDBFixture.cs => CosmosFixture.cs} | 4 +- ...nvironment.cs => CosmosTestEnvironment.cs} | 4 +- ...osmosDBTestStore.cs => CosmosTestStore.cs} | 16 +- ...BOptionsTests.cs => CosmosOptionsTests.cs} | 6 +- 37 files changed, 325 insertions(+), 324 deletions(-) rename MEVD/src/AzureCosmosDB/{CosmosDBCollection.cs => CosmosCollection.cs} (90%) rename MEVD/src/AzureCosmosDB/{CosmosDBCollectionOptions.cs => CosmosCollectionOptions.cs} (81%) rename MEVD/src/AzureCosmosDB/{CosmosDBCollectionQueryBuilder.cs => CosmosCollectionQueryBuilder.cs} (96%) rename MEVD/src/AzureCosmosDB/{CosmosDBConstants.cs => CosmosConstants.cs} (75%) rename MEVD/src/AzureCosmosDB/{CosmosDBDynamicCollection.cs => CosmosDynamicCollection.cs} (75%) rename MEVD/src/AzureCosmosDB/{CosmosDBDynamicMapper.cs => CosmosDynamicMapper.cs} (95%) rename MEVD/src/AzureCosmosDB/{CosmosDBFilterTranslator.cs => CosmosFilterTranslator.cs} (99%) rename MEVD/src/AzureCosmosDB/{CosmosDBKey.cs => CosmosKey.cs} (70%) rename MEVD/src/AzureCosmosDB/{CosmosDBMapper.cs => CosmosMapper.cs} (93%) rename MEVD/src/AzureCosmosDB/{CosmosDBModelBuilder.cs => CosmosModelBuilder.cs} (90%) rename MEVD/src/AzureCosmosDB/{CosmosDBServiceCollectionExtensions.cs => CosmosServiceCollectionExtensions.cs} (67%) rename MEVD/src/AzureCosmosDB/{CosmosDBVectorStore.cs => CosmosVectorStore.cs} (84%) rename MEVD/src/AzureCosmosDB/{CosmosDBVectorStoreOptions.cs => CosmosVectorStoreOptions.cs} (69%) rename MEVD/src/AzureCosmosDB/{ICosmosDBMapper.cs => ICosmosMapper.cs} (94%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBBasicModelTests.cs => CosmosBasicModelTests.cs} (55%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBCollectionManagementTests.cs => CosmosCollectionManagementTests.cs} (78%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBDataTypeTests.cs => CosmosDataTypeTests.cs} (78%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBDependencyInjectionTests.cs => CosmosDependencyInjectionTests.cs} (57%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBDistanceFunctionTests.cs => CosmosDistanceFunctionTests.cs} (75%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBDynamicModelTests.cs => CosmosDynamicModelTests.cs} (58%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBEmbeddingGenerationTests.cs => CosmosEmbeddingGenerationTests.cs} (51%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBEmbeddingTypeTests.cs => CosmosEmbeddingTypeTests.cs} (71%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBFilterTests.cs => CosmosFilterTests.cs} (66%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBHybridSearchTests.cs => CosmosHybridSearchTests.cs} (58%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBIndexKindTests.cs => CosmosIndexKindTests.cs} (59%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBKeyTypeTests.cs => CosmosKeyTypeTests.cs} (62%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBMultiVectorModelTests.cs => CosmosMultiVectorModelTests.cs} (67%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBNoDataModelTests.cs => CosmosNoDataModelTests.cs} (61%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBNoVectorModelTests.cs => CosmosNoVectorModelTests.cs} (61%) rename MEVD/test/AzureCosmosDB.ConformanceTests/{CosmosDBTestSuiteImplementationTests.cs => CosmosTestSuiteImplementationTests.cs} (85%) rename MEVD/test/AzureCosmosDB.ConformanceTests/Support/{CosmosDBConformanceTestHelpers.cs => CosmosConformanceTestHelpers.cs} (91%) rename MEVD/test/AzureCosmosDB.ConformanceTests/Support/{CosmosDBFixture.cs => CosmosFixture.cs} (63%) rename MEVD/test/AzureCosmosDB.ConformanceTests/Support/{CosmosDBTestEnvironment.cs => CosmosTestEnvironment.cs} (91%) rename MEVD/test/AzureCosmosDB.ConformanceTests/Support/{CosmosDBTestStore.cs => CosmosTestStore.cs} (89%) rename MEVD/test/AzureCosmosDB.UnitTests/{CosmosDBOptionsTests.cs => CosmosOptionsTests.cs} (90%) diff --git a/MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj b/MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj index bbde767..de2babe 100644 --- a/MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj +++ b/MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj @@ -7,6 +7,7 @@ Azure Cosmos DB for NoSQL provider for Microsoft.Extensions.VectorData Azure Cosmos DB for NoSQL provider for Microsoft.Extensions.VectorData by the .NET Community Toolkit + AzureCosmosDB;CosmosNoSql;VectorData true diff --git a/MEVD/src/AzureCosmosDB/CosmosDBCollection.cs b/MEVD/src/AzureCosmosDB/CosmosCollection.cs similarity index 90% rename from MEVD/src/AzureCosmosDB/CosmosDBCollection.cs rename to MEVD/src/AzureCosmosDB/CosmosCollection.cs index 529a7ab..37dfceb 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBCollection.cs +++ b/MEVD/src/AzureCosmosDB/CosmosCollection.cs @@ -28,14 +28,14 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Service for storing and retrieving vector records, that uses Azure CosmosDB NoSQL as the underlying storage. +/// Service for storing and retrieving vector records, that uses Azure Cosmos NoSQL as the underlying storage. /// /// /// The data type of the record key. Supported types are and (in which case the partition key -/// is the document ID), and (for other partition key configurations). +/// is the document ID), and (for other partition key configurations). /// The data model to use for adding, updating and retrieving data from storage. #pragma warning disable CA1711 // Identifiers should not have incorrect suffix -public class CosmosDBCollection : VectorStoreCollection, IKeywordHybridSearchable +public class CosmosCollection : VectorStoreCollection, IKeywordHybridSearchable where TKey : notnull where TRecord : class #pragma warning restore CA1711 // Identifiers should not have incorrect suffix @@ -51,7 +51,7 @@ public class CosmosDBCollection : VectorStoreCollection that can be used to manage the collections in Azure CosmosDB NoSQL. + /// that can be used to manage the collections in Azure Cosmos NoSQL. private readonly Database _database; /// The model for this collection. @@ -61,8 +61,8 @@ public class CosmosDBCollection : VectorStoreCollectionThe properties to use as partition key (supports hierarchical partition keys up to 3 levels). private readonly List _partitionKeyProperties; - /// The mapper to use when mapping between the consumer data model and the Azure CosmosDB NoSQL record. - private readonly ICosmosDBMapper _mapper; + /// The mapper to use when mapping between the consumer data model and the Azure Cosmos NoSQL record. + private readonly ICosmosMapper _mapper; /// public override string Name { get; } @@ -74,14 +74,14 @@ public class CosmosDBCollection : VectorStoreCollection - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// that can be used to manage the collections in Azure CosmosDB NoSQL. - /// The name of the collection that this will access. + /// that can be used to manage the collections in Azure Cosmos NoSQL. + /// The name of the collection that this will access. /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosDBCollection(Database database, string name, CosmosDBCollectionOptions? options = default) + public CosmosCollection(Database database, string name, CosmosCollectionOptions? options = default) : this(new(database.Client, ownsClient: false), _ => database, name, options) { Throw.IfNull(database); @@ -89,21 +89,21 @@ public CosmosDBCollection(Database database, string name, CosmosDBCollectionOpti } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// Connection string required to connect to Azure CosmosDB NoSQL. - /// Database name for Azure CosmosDB NoSQL. - /// The name of the collection that this will access. + /// Connection string required to connect to Azure Cosmos NoSQL. + /// Database name for Azure Cosmos NoSQL. + /// The name of the collection that this will access. /// Optional configuration options for . /// Optional configuration options for . [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosDBCollection( + public CosmosCollection( string connectionString, string databaseName, string name, CosmosClientOptions? clientOptions = null, - CosmosDBCollectionOptions? options = null) + CosmosCollectionOptions? options = null) : this( new ClientWrapper(new CosmosClient(connectionString, clientOptions), ownsClient: true), client => client.GetDatabase(databaseName), @@ -115,34 +115,34 @@ public CosmosDBCollection( Throw.IfNullOrWhitespace(name); } - internal CosmosDBCollection( + internal CosmosCollection( ClientWrapper clientWrapper, Func databaseProvider, string name, - CosmosDBCollectionOptions? options) + CosmosCollectionOptions? options) : this( clientWrapper, databaseProvider, name, static options => typeof(TRecord) == typeof(Dictionary) - ? throw new NotSupportedException(VectorDataStrings.NonDynamicCollectionWithDictionaryNotSupported(typeof(CosmosDBDynamicCollection))) - : new CosmosDBModelBuilder() + ? throw new NotSupportedException(VectorDataStrings.NonDynamicCollectionWithDictionaryNotSupported(typeof(CosmosDynamicCollection))) + : new CosmosModelBuilder() .Build(typeof(TRecord), typeof(TKey), options.Definition, options.EmbeddingGenerator, options.JsonSerializerOptions ?? JsonSerializerOptions.Default), options) { } - internal CosmosDBCollection( + internal CosmosCollection( ClientWrapper clientWrapper, Func databaseProvider, string name, - Func modelFactory, - CosmosDBCollectionOptions? options) + Func modelFactory, + CosmosCollectionOptions? options) { - // Validate TKey: must be string or Guid (partition key = document ID), CosmosDBKey (other partition key cases), or object (used by CosmosDBDynamicCollection). - if (typeof(TKey) != typeof(string) && typeof(TKey) != typeof(Guid) && typeof(TKey) != typeof(CosmosDBKey) && typeof(TKey) != typeof(object)) + // Validate TKey: must be string or Guid (partition key = document ID), CosmosKey (other partition key cases), or object (used by CosmosDynamicCollection). + if (typeof(TKey) != typeof(string) && typeof(TKey) != typeof(Guid) && typeof(TKey) != typeof(CosmosKey) && typeof(TKey) != typeof(object)) { - throw new NotSupportedException($"The key type must be string, Guid, or CosmosDBKey. Received: {typeof(TKey).Name}"); + throw new NotSupportedException($"The key type must be string, Guid, or CosmosKey. Received: {typeof(TKey).Name}"); } try @@ -156,7 +156,7 @@ internal CosmosDBCollection( $"is required to be configured for {this.GetType().Name}."); } - options ??= CosmosDBCollectionOptions.Default; + options ??= CosmosCollectionOptions.Default; // Assign. this.Name = name; @@ -167,8 +167,8 @@ internal CosmosDBCollection( // Assign mapper. this._mapper = typeof(TRecord) == typeof(Dictionary) - ? (new CosmosDBDynamicMapper(this._model, jsonSerializerOptions) as ICosmosDBMapper)! - : new CosmosDBMapper(this._model, options.JsonSerializerOptions); + ? (new CosmosDynamicMapper(this._model, jsonSerializerOptions) as ICosmosMapper)! + : new CosmosMapper(this._model, options.JsonSerializerOptions); // Setup partition key properties (supports hierarchical partition keys up to 3 levels) if (options.PartitionKeyProperties is null) @@ -205,18 +205,18 @@ internal CosmosDBCollection( // When using simple key types (string/Guid), the partition key must be the key property only, // since the partition key value cannot be independently specified via a simple key. // Users who need hierarchical partition keys, a non-key partition key, or no partition key at all - // must use CosmosDBKey as the key type. + // must use CosmosKey as the key type. if ((typeof(TKey) == typeof(string) || typeof(TKey) == typeof(Guid)) && (this._partitionKeyProperties is not [var singlePkProperty] || singlePkProperty != this._model.KeyProperty)) { throw new ArgumentException( $"When using {typeof(TKey).Name} as the key type, the partition key must be the key property " + - $"('{this._model.KeyProperty.ModelName}'). To use a different partition key configuration, use CosmosDBKey as the key type."); + $"('{this._model.KeyProperty.ModelName}'). To use a different partition key configuration, use CosmosKey as the key type."); } this._collectionMetadata = new() { - VectorStoreSystemName = CosmosDBConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosConstants.VectorStoreSystemName, VectorStoreName = this._database.Id, CollectionName = name }; @@ -291,7 +291,7 @@ public override async Task EnsureCollectionExistsAsync(CancellationToken cancell { throw new VectorStoreException("Call to vector store failed.", ex) { - VectorStoreSystemName = CosmosDBConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosConstants.VectorStoreSystemName, VectorStoreName = this._collectionMetadata.VectorStoreName, CollectionName = this.Name, OperationName = "CreateContainer" @@ -316,7 +316,7 @@ await this._database { throw new VectorStoreException("Call to vector store failed.", ex) { - VectorStoreSystemName = CosmosDBConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosConstants.VectorStoreSystemName, VectorStoreName = this._collectionMetadata.VectorStoreName, CollectionName = this.Name, OperationName = "DeleteContainer" @@ -493,7 +493,7 @@ await this.RunOperationAsync(OperationName, () => { var vectorProperty = model.VectorProperties[i]; - if (CosmosDBModelBuilder.IsVectorPropertyTypeValidCore(vectorProperty.Type, out _)) + if (CosmosModelBuilder.IsVectorPropertyTypeValidCore(vectorProperty.Type, out _)) { continue; } @@ -548,7 +548,7 @@ public override async IAsyncEnumerable> SearchAsync< var vectorProperty = this._model.GetVectorPropertyOrSingle(options); object vector = await GetSearchVectorAsync(searchValue, vectorProperty, cancellationToken).ConfigureAwait(false); - var queryDefinition = CosmosDBCollectionQueryBuilder.BuildSearchQuery( + var queryDefinition = CosmosCollectionQueryBuilder.BuildSearchQuery( vector, null, this._model, @@ -593,7 +593,7 @@ _ when vectorProperty.EmbeddingGenerationDispatcher is not null => await vectorProperty.GenerateEmbeddingAsync(searchValue, cancellationToken).ConfigureAwait(false), _ => vectorProperty.EmbeddingGenerator is null - ? throw new NotSupportedException(VectorDataStrings.InvalidSearchInputAndNoEmbeddingGeneratorWasConfigured(searchValue.GetType(), CosmosDBModelBuilder.SupportedVectorTypes)) + ? throw new NotSupportedException(VectorDataStrings.InvalidSearchInputAndNoEmbeddingGeneratorWasConfigured(searchValue.GetType(), CosmosModelBuilder.SupportedVectorTypes)) : throw new InvalidOperationException(VectorDataStrings.IncompatibleEmbeddingGeneratorWasConfiguredForInputType(typeof(TInput), vectorProperty.EmbeddingGenerator.GetType())) }; @@ -610,9 +610,9 @@ public override async IAsyncEnumerable GetAsync(Expression> HybridSearchAsync( + var queryDefinition = CosmosCollectionQueryBuilder.BuildSearchQuery( vector, keywords, this._model, @@ -692,10 +692,10 @@ private void VerifyVectorType(TVector? vector) var vectorType = vector!.GetType(); - if (!CosmosDBModelBuilder.IsVectorPropertyTypeValidCore(vectorType, out var supportedTypes)) + if (!CosmosModelBuilder.IsVectorPropertyTypeValidCore(vectorType, out var supportedTypes)) { throw new NotSupportedException( - $"The provided vector type {vectorType.FullName} is not supported by the Azure CosmosDB NoSQL connector. Supported types are: {supportedTypes}"); + $"The provided vector type {vectorType.FullName} is not supported by the Azure Cosmos NoSQL connector. Supported types are: {supportedTypes}"); } } @@ -711,11 +711,11 @@ private Task RunOperationAsync(string operationName, Func> operati private (string DocumentId, PartitionKey PartitionKey) GetDocumentIdAndPartitionKey(TKey key) => key switch { - CosmosDBKey cosmosKey => (cosmosKey.DocumentId, cosmosKey.PartitionKey), + CosmosKey cosmosKey => (cosmosKey.DocumentId, cosmosKey.PartitionKey), string s => (s, new PartitionKey(s)), Guid g => (g.ToString(), new PartitionKey(g.ToString())), _ => throw new InvalidOperationException( - $"Keys must be of type string, Guid, or CosmosDBKey. Received key of type '{key.GetType().FullName}'.") + $"Keys must be of type string, Guid, or CosmosKey. Received key of type '{key.GetType().FullName}'.") }; /// @@ -806,7 +806,7 @@ private ContainerProperties GetContainerProperties() } /// - /// More information about Azure CosmosDB NoSQL index kinds here: . + /// More information about Azure Cosmos NoSQL index kinds here: . /// private static VectorIndexType GetIndexKind(string? indexKind, string vectorPropertyName) => indexKind switch @@ -814,11 +814,11 @@ private static VectorIndexType GetIndexKind(string? indexKind, string vectorProp "DiskAnn" or null => VectorIndexType.DiskANN, "Flat" => VectorIndexType.Flat, "QuantizedFlat" => VectorIndexType.QuantizedFlat, - _ => throw new InvalidOperationException($"Index kind '{indexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure CosmosDB NoSQL VectorStore.") + _ => throw new InvalidOperationException($"Index kind '{indexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure Cosmos NoSQL VectorStore.") }; /// - /// More information about Azure CosmosDB NoSQL distance functions here: . + /// More information about Azure Cosmos NoSQL distance functions here: . /// private static DistanceFunction GetDistanceFunction(string? distanceFunction, string vectorPropertyName) => distanceFunction switch @@ -827,7 +827,7 @@ private static DistanceFunction GetDistanceFunction(string? distanceFunction, st SKDistanceFunction.DotProductSimilarity => DistanceFunction.DotProduct, SKDistanceFunction.EuclideanDistance => DistanceFunction.Euclidean, - _ => throw new NotSupportedException($"Distance function '{distanceFunction}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure CosmosDB NoSQL VectorStore.") + _ => throw new NotSupportedException($"Distance function '{distanceFunction}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure Cosmos NoSQL VectorStore.") }; /// @@ -845,7 +845,7 @@ private static VectorDataType GetDataType(Type vectorDataType, string vectorProp Type type when type == typeof(ReadOnlyMemory) || type == typeof(Embedding) || type == typeof(sbyte[]) => VectorDataType.Int8, - _ => throw new InvalidOperationException($"Data type '{vectorDataType}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure CosmosDB NoSQL VectorStore.") + _ => throw new InvalidOperationException($"Data type '{vectorDataType}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure Cosmos NoSQL VectorStore.") }; private async IAsyncEnumerable GetItemsAsync(QueryDefinition queryDefinition, string operationName, [EnumeratorCancellation] CancellationToken cancellationToken) diff --git a/MEVD/src/AzureCosmosDB/CosmosDBCollectionOptions.cs b/MEVD/src/AzureCosmosDB/CosmosCollectionOptions.cs similarity index 81% rename from MEVD/src/AzureCosmosDB/CosmosDBCollectionOptions.cs rename to MEVD/src/AzureCosmosDB/CosmosCollectionOptions.cs index e72e1bf..65fa914 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBCollectionOptions.cs +++ b/MEVD/src/AzureCosmosDB/CosmosCollectionOptions.cs @@ -9,20 +9,20 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Options when creating a . +/// Options when creating a . /// -public sealed class CosmosDBCollectionOptions : VectorStoreCollectionOptions +public sealed class CosmosCollectionOptions : VectorStoreCollectionOptions { - internal static readonly CosmosDBCollectionOptions Default = new(); + internal static readonly CosmosCollectionOptions Default = new(); /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public CosmosDBCollectionOptions() + public CosmosCollectionOptions() { } - internal CosmosDBCollectionOptions(CosmosDBCollectionOptions? source) : base(source) + internal CosmosCollectionOptions(CosmosCollectionOptions? source) : base(source) { this.JsonSerializerOptions = source?.JsonSerializerOptions; this.PartitionKeyProperties = source?.PartitionKeyProperties is null ? null : [.. source.PartitionKeyProperties]; @@ -31,7 +31,7 @@ internal CosmosDBCollectionOptions(CosmosDBCollectionOptions? source) : base(sou } /// - /// Gets or sets the JSON serializer options to use when converting between the data model and the Azure CosmosDB NoSQL record. + /// Gets or sets the JSON serializer options to use when converting between the data model and the Azure Cosmos NoSQL record. /// public JsonSerializerOptions? JsonSerializerOptions { get; set; } @@ -47,7 +47,7 @@ internal CosmosDBCollectionOptions(CosmosDBCollectionOptions? source) : base(sou /// When (the default), the key property (document ID) is automatically used as the partition key - a common /// Cosmos DB strategy; in this mode, the collection key type must be or . /// To use a different partition key (or hierarchical partition keys), specify the key properties here and use - /// as the key type. + /// as the key type. /// /// public IReadOnlyList? PartitionKeyProperties { get; set; } diff --git a/MEVD/src/AzureCosmosDB/CosmosDBCollectionQueryBuilder.cs b/MEVD/src/AzureCosmosDB/CosmosCollectionQueryBuilder.cs similarity index 96% rename from MEVD/src/AzureCosmosDB/CosmosDBCollectionQueryBuilder.cs rename to MEVD/src/AzureCosmosDB/CosmosCollectionQueryBuilder.cs index ca929d8..6afe13a 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBCollectionQueryBuilder.cs +++ b/MEVD/src/AzureCosmosDB/CosmosCollectionQueryBuilder.cs @@ -15,12 +15,12 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Contains helpers to build queries for Azure CosmosDB NoSQL. +/// Contains helpers to build queries for Azure Cosmos NoSQL. /// -internal static class CosmosDBCollectionQueryBuilder +internal static class CosmosCollectionQueryBuilder { /// - /// Builds to get items from Azure CosmosDB NoSQL using vector search. + /// Builds to get items from Azure Cosmos NoSQL using vector search. /// public static QueryDefinition BuildSearchQuery( object vector, @@ -41,7 +41,7 @@ public static QueryDefinition BuildSearchQuery( const string VectorVariableName = "@vector"; const string KeywordVariablePrefix = "@keyword"; - var tableVariableName = CosmosDBConstants.ContainerAlias; + var tableVariableName = CosmosConstants.ContainerAlias; IEnumerable projectionProperties = model.Properties; if (!includeVectors) @@ -56,7 +56,7 @@ public static QueryDefinition BuildSearchQuery( // Build filter object. var (filterClause, filterParameters) = filter is not null - ? new CosmosDBFilterTranslator().Translate(filter, model) + ? new CosmosFilterTranslator().Translate(filter, model) : ((string?)null, new Dictionary()); var queryParameters = new Dictionary @@ -162,7 +162,7 @@ internal static QueryDefinition BuildSearchQuery( FilteredRecordRetrievalOptions filterOptions, int top) { - var tableVariableName = CosmosDBConstants.ContainerAlias; + var tableVariableName = CosmosConstants.ContainerAlias; IEnumerable projectionProperties = model.Properties; if (!filterOptions.IncludeVectors) diff --git a/MEVD/src/AzureCosmosDB/CosmosDBConstants.cs b/MEVD/src/AzureCosmosDB/CosmosConstants.cs similarity index 75% rename from MEVD/src/AzureCosmosDB/CosmosDBConstants.cs rename to MEVD/src/AzureCosmosDB/CosmosConstants.cs index bde529b..17f2dd0 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBConstants.cs +++ b/MEVD/src/AzureCosmosDB/CosmosConstants.cs @@ -3,17 +3,17 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; -internal static class CosmosDBConstants +internal static class CosmosConstants { internal const string VectorStoreSystemName = "azure.cosmosdbnosql"; /// - /// Reserved key property name in Azure CosmosDB NoSQL. + /// Reserved key property name in Azure Cosmos NoSQL. /// internal const string ReservedKeyPropertyName = "id"; /// - /// Variable name for table in Azure CosmosDB NoSQL queries. + /// Variable name for table in Azure Cosmos NoSQL queries. /// Can be any string. Example: "SELECT x.Name FROM x". /// internal const char ContainerAlias = 'x'; diff --git a/MEVD/src/AzureCosmosDB/CosmosDBDynamicCollection.cs b/MEVD/src/AzureCosmosDB/CosmosDynamicCollection.cs similarity index 75% rename from MEVD/src/AzureCosmosDB/CosmosDBDynamicCollection.cs rename to MEVD/src/AzureCosmosDB/CosmosDynamicCollection.cs index 62be5c7..7a3471e 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBDynamicCollection.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDynamicCollection.cs @@ -11,27 +11,27 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Represents a collection of vector store records in a CosmosDB database, mapped to a dynamic Dictionary<string, object?>. +/// Represents a collection of vector store records in a Cosmos database, mapped to a dynamic Dictionary<string, object?>. /// /// /// -/// This collection accepts keys of type , but only instances +/// This collection accepts keys of type , but only instances /// are supported at runtime. Passing any other key type will result in an . /// /// #pragma warning disable CA1711 // Identifiers should not have incorrect suffix -public sealed class CosmosDBDynamicCollection : CosmosDBCollection> +public sealed class CosmosDynamicCollection : CosmosCollection> #pragma warning restore CA1711 // Identifiers should not have incorrect suffix { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// that can be used to manage the collections in Azure CosmosDB NoSQL. + /// that can be used to manage the collections in Azure Cosmos NoSQL. /// The name of the collection. /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosDBDynamicCollection(Database database, string name, CosmosDBCollectionOptions options) + public CosmosDynamicCollection(Database database, string name, CosmosCollectionOptions options) : this( new(database.Client, ownsClient: false), _ => database, @@ -41,21 +41,21 @@ public CosmosDBDynamicCollection(Database database, string name, CosmosDBCollect } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// Connection string required to connect to Azure CosmosDB NoSQL. - /// Database name for Azure CosmosDB NoSQL. - /// The name of the collection that this will access. + /// Connection string required to connect to Azure Cosmos NoSQL. + /// Database name for Azure Cosmos NoSQL. + /// The name of the collection that this will access. /// Optional configuration options for . /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosDBDynamicCollection( + public CosmosDynamicCollection( string connectionString, string databaseName, string collectionName, CosmosClientOptions? clientOptions = null, - CosmosDBCollectionOptions? options = null) + CosmosCollectionOptions? options = null) : this( new(new CosmosClient(connectionString, clientOptions), ownsClient: true), client => client.GetDatabase(databaseName), @@ -67,16 +67,16 @@ public CosmosDBDynamicCollection( Throw.IfNullOrWhitespace(collectionName); } - internal CosmosDBDynamicCollection( + internal CosmosDynamicCollection( ClientWrapper clientWrapper, Func databaseProvider, string name, - CosmosDBCollectionOptions? options) + CosmosCollectionOptions? options) : base( clientWrapper, databaseProvider, name, - static options => new CosmosDBModelBuilder() + static options => new CosmosModelBuilder() .BuildDynamic( options.Definition ?? throw new ArgumentException("Definition is required for dynamic collections"), options.EmbeddingGenerator, diff --git a/MEVD/src/AzureCosmosDB/CosmosDBDynamicMapper.cs b/MEVD/src/AzureCosmosDB/CosmosDynamicMapper.cs similarity index 95% rename from MEVD/src/AzureCosmosDB/CosmosDBDynamicMapper.cs rename to MEVD/src/AzureCosmosDB/CosmosDynamicMapper.cs index 0ac4807..7550cff 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBDynamicMapper.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDynamicMapper.cs @@ -15,10 +15,10 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// A mapper that maps between the generic Semantic Kernel data model and the model that the data is stored under, within Azure CosmosDB NoSQL. +/// A mapper that maps between the generic Semantic Kernel data model and the model that the data is stored under, within Azure Cosmos NoSQL. /// -internal sealed class CosmosDBDynamicMapper(CollectionModel model, JsonSerializerOptions jsonSerializerOptions) - : ICosmosDBMapper> +internal sealed class CosmosDynamicMapper(CollectionModel model, JsonSerializerOptions jsonSerializerOptions) + : ICosmosMapper> { public JsonObject MapFromDataToStorageModel(Dictionary dataModel, int recordIndex, IReadOnlyList?[]? generatedEmbeddings) { @@ -26,7 +26,7 @@ public JsonObject MapFromDataToStorageModel(Dictionary dataMode var jsonObject = new JsonObject { - [CosmosDBConstants.ReservedKeyPropertyName] = !dataModel.TryGetValue(model.KeyProperty.ModelName, out var keyValue) + [CosmosConstants.ReservedKeyPropertyName] = !dataModel.TryGetValue(model.KeyProperty.ModelName, out var keyValue) ? throw new InvalidOperationException($"Missing value for key property '{model.KeyProperty.ModelName}") : keyValue switch { @@ -124,7 +124,7 @@ static bool TryGetReadOnlyMemory(object value, [NotNullWhen(true)] out ReadOn switch (property) { case KeyPropertyModel keyProperty: - var key = (string?)storageModel[CosmosDBConstants.ReservedKeyPropertyName] + var key = (string?)storageModel[CosmosConstants.ReservedKeyPropertyName] ?? throw new InvalidOperationException($"The key property '{keyProperty.StorageName}' is missing from the record retrieved from storage."); result[keyProperty.ModelName] = keyProperty.Type switch diff --git a/MEVD/src/AzureCosmosDB/CosmosDBFilterTranslator.cs b/MEVD/src/AzureCosmosDB/CosmosFilterTranslator.cs similarity index 99% rename from MEVD/src/AzureCosmosDB/CosmosDBFilterTranslator.cs rename to MEVD/src/AzureCosmosDB/CosmosFilterTranslator.cs index c094de3..2367cd5 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBFilterTranslator.cs +++ b/MEVD/src/AzureCosmosDB/CosmosFilterTranslator.cs @@ -15,7 +15,7 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; #pragma warning disable MEVD9001 // Experimental: filter translation base types -internal class CosmosDBFilterTranslator : FilterTranslatorBase +internal class CosmosFilterTranslator : FilterTranslatorBase { private readonly Dictionary _parameters = []; private readonly StringBuilder _sql = new(); @@ -364,7 +364,7 @@ protected void TranslateQueryParameter(string name, object? value) protected virtual void GeneratePropertyAccess(PropertyModel property) => this._sql - .Append(CosmosDBConstants.ContainerAlias) + .Append(CosmosConstants.ContainerAlias) .Append("[\"") .Append(property.StorageName.Replace(@"\", @"\\").Replace("\"", "\\\"")) .Append("\"]"); diff --git a/MEVD/src/AzureCosmosDB/CosmosDBKey.cs b/MEVD/src/AzureCosmosDB/CosmosKey.cs similarity index 70% rename from MEVD/src/AzureCosmosDB/CosmosDBKey.cs rename to MEVD/src/AzureCosmosDB/CosmosKey.cs index e6e0fe3..151e880 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBKey.cs +++ b/MEVD/src/AzureCosmosDB/CosmosKey.cs @@ -7,7 +7,7 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Represents a key for Azure CosmosDB NoSQL, containing both the record key (document ID) and the partition key. +/// Represents a key for Azure Cosmos NoSQL, containing both the record key (document ID) and the partition key. /// /// /// @@ -21,98 +21,98 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; /// /// // This is conceptually a record, but we're targeting .NET Standard 2.0 too. -public readonly struct CosmosDBKey : IEquatable +public readonly struct CosmosKey : IEquatable { /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosDBKey(string documentId, string partitionKey) + public CosmosKey(string documentId, string partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosDBKey(Guid documentId, string partitionKey) + public CosmosKey(Guid documentId, string partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosDBKey(string documentId, Guid partitionKey) + public CosmosKey(string documentId, Guid partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey.ToString()); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosDBKey(Guid documentId, Guid partitionKey) + public CosmosKey(Guid documentId, Guid partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey.ToString()); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosDBKey(string documentId, bool partitionKey) + public CosmosKey(string documentId, bool partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosDBKey(Guid documentId, bool partitionKey) + public CosmosKey(Guid documentId, bool partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosDBKey(string documentId, double partitionKey) + public CosmosKey(string documentId, double partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosDBKey(Guid documentId, double partitionKey) + public CosmosKey(Guid documentId, double partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. @@ -120,14 +120,14 @@ public CosmosDBKey(Guid documentId, double partitionKey) /// Use this constructor for hierarchical partition keys or special partition key values like or . /// For hierarchical partition keys, construct the using . /// - public CosmosDBKey(string documentId, PartitionKey partitionKey) + public CosmosKey(string documentId, PartitionKey partitionKey) { this.DocumentId = documentId; this.PartitionKey = partitionKey; } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. @@ -135,7 +135,7 @@ public CosmosDBKey(string documentId, PartitionKey partitionKey) /// Use this constructor for hierarchical partition keys or special partition key values like or . /// For hierarchical partition keys, construct the using . /// - public CosmosDBKey(Guid documentId, PartitionKey partitionKey) + public CosmosKey(Guid documentId, PartitionKey partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = partitionKey; @@ -159,26 +159,26 @@ public CosmosDBKey(Guid documentId, PartitionKey partitionKey) public PartitionKey PartitionKey { get; } /// - public bool Equals(CosmosDBKey other) + public bool Equals(CosmosKey other) => Equals(this.DocumentId, other.DocumentId) && this.PartitionKey.Equals(other.PartitionKey); /// public override bool Equals(object? obj) - => obj is CosmosDBKey other && this.Equals(other); + => obj is CosmosKey other && this.Equals(other); /// public override int GetHashCode() => HashCode.Combine(this.DocumentId, this.PartitionKey); /// - /// Determines whether two instances are equal. + /// Determines whether two instances are equal. /// - public static bool operator ==(CosmosDBKey left, CosmosDBKey right) + public static bool operator ==(CosmosKey left, CosmosKey right) => left.Equals(right); /// - /// Determines whether two instances are not equal. + /// Determines whether two instances are not equal. /// - public static bool operator !=(CosmosDBKey left, CosmosDBKey right) + public static bool operator !=(CosmosKey left, CosmosKey right) => !left.Equals(right); } diff --git a/MEVD/src/AzureCosmosDB/CosmosDBMapper.cs b/MEVD/src/AzureCosmosDB/CosmosMapper.cs similarity index 93% rename from MEVD/src/AzureCosmosDB/CosmosDBMapper.cs rename to MEVD/src/AzureCosmosDB/CosmosMapper.cs index 8a1b5b5..d21c84d 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBMapper.cs +++ b/MEVD/src/AzureCosmosDB/CosmosMapper.cs @@ -13,17 +13,17 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Class for mapping between a json node stored in Azure CosmosDB NoSQL and the consumer data model. +/// Class for mapping between a json node stored in Azure Cosmos NoSQL and the consumer data model. /// /// The consumer data model to map to or from. -internal sealed class CosmosDBMapper : ICosmosDBMapper +internal sealed class CosmosMapper : ICosmosMapper where TRecord : class { private readonly CollectionModel _model; private readonly KeyPropertyModel _keyProperty; private readonly JsonSerializerOptions _jsonSerializerOptions; - public CosmosDBMapper(CollectionModel model, JsonSerializerOptions? jsonSerializerOptions) + public CosmosMapper(CollectionModel model, JsonSerializerOptions? jsonSerializerOptions) { this._model = model; this._keyProperty = model.KeyProperty; @@ -40,10 +40,10 @@ public JsonObject MapFromDataToStorageModel(TRecord dataModel, int recordIndex, { var jsonObject = JsonSerializer.SerializeToNode(dataModel, this._jsonSerializerOptions)!.AsObject(); - // The key property in Azure CosmosDB NoSQL is always named 'id'. + // The key property in Azure Cosmos NoSQL is always named 'id'. // But the external JSON serializer used just above isn't aware of that, and will produce a JSON object with another name, taking into // account e.g. naming policies. SerializedKeyName gets populated in the model builder - containing that name - once VectorStoreModelBuildingOptions.ReservedKeyPropertyName is set - RenameJsonProperty(jsonObject, this._keyProperty.SerializedKeyName!, CosmosDBConstants.ReservedKeyPropertyName); + RenameJsonProperty(jsonObject, this._keyProperty.SerializedKeyName!, CosmosConstants.ReservedKeyPropertyName); // Go over the vector properties; inject any generated embeddings to overwrite the JSON serialized above. // Also, for Embedding properties we also need to overwrite with a simple array (since Embedding gets serialized as a complex object). @@ -117,7 +117,7 @@ public JsonObject MapFromDataToStorageModel(TRecord dataModel, int recordIndex, public TRecord MapFromStorageToDataModel(JsonObject storageModel, bool includeVectors) { // See above comment. - RenameJsonProperty(storageModel, CosmosDBConstants.ReservedKeyPropertyName, this._keyProperty.SerializedKeyName!); + RenameJsonProperty(storageModel, CosmosConstants.ReservedKeyPropertyName, this._keyProperty.SerializedKeyName!); foreach (var vectorProperty in this._model.VectorProperties) { diff --git a/MEVD/src/AzureCosmosDB/CosmosDBModelBuilder.cs b/MEVD/src/AzureCosmosDB/CosmosModelBuilder.cs similarity index 90% rename from MEVD/src/AzureCosmosDB/CosmosDBModelBuilder.cs rename to MEVD/src/AzureCosmosDB/CosmosModelBuilder.cs index 6d00661..254898e 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBModelBuilder.cs +++ b/MEVD/src/AzureCosmosDB/CosmosModelBuilder.cs @@ -9,7 +9,7 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; -internal class CosmosDBModelBuilder() : CollectionJsonModelBuilder(s_modelBuildingOptions) +internal class CosmosModelBuilder() : CollectionJsonModelBuilder(s_modelBuildingOptions) { internal const string SupportedVectorTypes = "ReadOnlyMemory, Embedding, float[], ReadOnlyMemory, Embedding, byte[], ReadOnlyMemory, Embedding, sbyte[]"; @@ -18,19 +18,19 @@ internal class CosmosDBModelBuilder() : CollectionJsonModelBuilder(s_modelBuildi RequiresAtLeastOneVector = false, SupportsMultipleVectors = true, UsesExternalSerializer = true, - ReservedKeyStorageName = CosmosDBConstants.ReservedKeyPropertyName + ReservedKeyStorageName = CosmosConstants.ReservedKeyPropertyName }; protected override void ValidateKeyProperty(KeyPropertyModel keyProperty) { - // CosmosDBKey is a composite key type (document ID + partition key) that doesn't correspond to any single key property type; + // CosmosKey is a composite key type (document ID + partition key) that doesn't correspond to any single key property type; // skip the base TKey-to-key-property validation when it's used. - if (this.KeyType != typeof(CosmosDBKey)) + if (this.KeyType != typeof(CosmosKey)) { base.ValidateKeyProperty(keyProperty); } - // Note that the key property in Cosmos NoSQL refers to the document ID, not to the CosmosDBKey structure which includes both + // Note that the key property in Cosmos NoSQL refers to the document ID, not to the CosmosKey structure which includes both // the document ID and the partition key (and which is the generic TKey type parameter of the collection). var type = keyProperty.Type; diff --git a/MEVD/src/AzureCosmosDB/CosmosDBServiceCollectionExtensions.cs b/MEVD/src/AzureCosmosDB/CosmosServiceCollectionExtensions.cs similarity index 67% rename from MEVD/src/AzureCosmosDB/CosmosDBServiceCollectionExtensions.cs rename to MEVD/src/AzureCosmosDB/CosmosServiceCollectionExtensions.cs index 808e80a..1ba4980 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBServiceCollectionExtensions.cs +++ b/MEVD/src/AzureCosmosDB/CosmosServiceCollectionExtensions.cs @@ -15,148 +15,148 @@ namespace Microsoft.Extensions.DependencyInjection; #pragma warning restore IDE0130 // Namespace does not match folder structure /// -/// Extension methods to register Azure CosmosDB NoSQL instances on an . +/// Extension methods to register Azure Cosmos NoSQL instances on an . /// -public static class CosmosDBServiceCollectionExtensions +public static class CosmosServiceCollectionExtensions { private const string DynamicCodeMessage = "The Cosmos NoSQL provider is currently incompatible with NativeAOT."; private const string UnreferencedCodeMessage = "The Cosmos NoSQL provider is currently incompatible with trimming."; /// - /// Registers a as + /// Registers a as /// with retrieved from the dependency injection container. /// - /// + /// [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddCosmosDBVectorStore( + public static IServiceCollection AddCosmosVectorStore( this IServiceCollection services, - CosmosDBVectorStoreOptions? options = default, + CosmosVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) - => AddKeyedCosmosDBVectorStore(services, serviceKey: null, options, lifetime); + => AddKeyedCosmosVectorStore(services, serviceKey: null, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// with retrieved from the dependency injection container. /// - /// The to register the on. + /// The to register the on. /// The key with which to associate the vector store. - /// Optional options to further configure the . + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddKeyedCosmosDBVectorStore( + public static IServiceCollection AddKeyedCosmosVectorStore( this IServiceCollection services, object? serviceKey, - CosmosDBVectorStoreOptions? options = default, + CosmosVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) { Throw.IfNull(services); - services.Add(new ServiceDescriptor(typeof(CosmosDBVectorStore), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosVectorStore), serviceKey, (sp, _) => { var database = sp.GetRequiredService(); options = GetStoreOptions(sp, _ => options); - return new CosmosDBVectorStore(database, options); + return new CosmosVectorStore(database, options); }, lifetime)); services.Add(new ServiceDescriptor(typeof(VectorStore), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); return services; } /// - /// Registers a as + /// Registers a as /// using the provided and . /// - /// + /// [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddCosmosDBVectorStore( + public static IServiceCollection AddCosmosVectorStore( this IServiceCollection services, string connectionString, string databaseName, - CosmosDBVectorStoreOptions? options = default, + CosmosVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) - => AddKeyedCosmosDBVectorStore(services, serviceKey: null, connectionString, databaseName, options, lifetime); + => AddKeyedCosmosVectorStore(services, serviceKey: null, connectionString, databaseName, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// using the provided and . /// - /// The to register the on. + /// The to register the on. /// The key with which to associate the vector store. - /// Connection string required to connect to Azure CosmosDB NoSQL. - /// Database name for Azure CosmosDB NoSQL. - /// Optional options to further configure the . + /// Connection string required to connect to Azure Cosmos NoSQL. + /// Database name for Azure Cosmos NoSQL. + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddKeyedCosmosDBVectorStore( + public static IServiceCollection AddKeyedCosmosVectorStore( this IServiceCollection services, object? serviceKey, string connectionString, string databaseName, - CosmosDBVectorStoreOptions? options = default, + CosmosVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) { Throw.IfNull(services); Throw.IfNullOrWhitespace(connectionString); Throw.IfNullOrWhitespace(databaseName); - services.Add(new ServiceDescriptor(typeof(CosmosDBVectorStore), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosVectorStore), serviceKey, (sp, _) => { options = GetStoreOptions(sp, _ => options); var clientOptions = CreateClientOptions(options?.JsonSerializerOptions); - return new CosmosDBVectorStore(connectionString, databaseName, clientOptions, options); + return new CosmosVectorStore(connectionString, databaseName, clientOptions, options); }, lifetime)); services.Add(new ServiceDescriptor(typeof(VectorStore), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); return services; } /// - /// Registers a as + /// Registers a as /// with retrieved from the dependency injection container. /// - /// + /// [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddCosmosDBCollection( + public static IServiceCollection AddCosmosCollection( this IServiceCollection services, string name, - CosmosDBCollectionOptions? options = default, + CosmosCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class - => AddKeyedCosmosDBCollection(services, serviceKey: null, name, options, lifetime); + => AddKeyedCosmosCollection(services, serviceKey: null, name, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// with retrieved from the dependency injection container. /// /// The type of the key. /// The type of the record. - /// The to register the on. + /// The to register the on. /// The key with which to associate the collection. /// The name of the collection. - /// Optional options to further configure the . + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddKeyedCosmosDBCollection( + public static IServiceCollection AddKeyedCosmosCollection( this IServiceCollection services, object? serviceKey, string name, - CosmosDBCollectionOptions? options = default, + CosmosCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class @@ -164,12 +164,12 @@ public static IServiceCollection AddKeyedCosmosDBCollection( Throw.IfNull(services); Throw.IfNullOrWhitespace(name); - services.Add(new ServiceDescriptor(typeof(CosmosDBCollection), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosCollection), serviceKey, (sp, _) => { var database = sp.GetRequiredService(); options = GetCollectionOptions(sp, _ => options); - return new CosmosDBCollection(database, name, options); + return new CosmosCollection(database, name, options); }, lifetime)); AddAbstractions(services, serviceKey, lifetime); @@ -178,46 +178,46 @@ public static IServiceCollection AddKeyedCosmosDBCollection( } /// - /// Registers a as + /// Registers a as /// using the provided and . /// - /// + /// [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddCosmosDBCollection( + public static IServiceCollection AddCosmosCollection( this IServiceCollection services, string name, string connectionString, string databaseName, - CosmosDBCollectionOptions? options = default, + CosmosCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class - => AddKeyedCosmosDBCollection(services, serviceKey: null, name, connectionString, databaseName, options, lifetime); + => AddKeyedCosmosCollection(services, serviceKey: null, name, connectionString, databaseName, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// using the provided and . /// /// The type of the key. /// The type of the record. - /// The to register the on. + /// The to register the on. /// The key with which to associate the collection. /// The name of the collection. - /// Connection string required to connect to Azure CosmosDB NoSQL. - /// Database name for Azure CosmosDB NoSQL. - /// Optional options to further configure the . + /// Connection string required to connect to Azure Cosmos NoSQL. + /// Database name for Azure Cosmos NoSQL. + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddKeyedCosmosDBCollection( + public static IServiceCollection AddKeyedCosmosCollection( this IServiceCollection services, object? serviceKey, string name, string connectionString, string databaseName, - CosmosDBCollectionOptions? options = default, + CosmosCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class @@ -225,29 +225,29 @@ public static IServiceCollection AddKeyedCosmosDBCollection( Throw.IfNullOrWhitespace(connectionString); Throw.IfNullOrWhitespace(databaseName); - return AddKeyedCosmosDBCollection(services, serviceKey, name, _ => connectionString, _ => databaseName, _ => options!, lifetime); + return AddKeyedCosmosCollection(services, serviceKey, name, _ => connectionString, _ => databaseName, _ => options!, lifetime); } /// - /// Registers a as + /// Registers a as /// using the provided and . /// - /// + /// [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddCosmosDBCollection( + public static IServiceCollection AddCosmosCollection( this IServiceCollection services, string name, Func connectionStringProvider, Func databaseNameProvider, - Func? optionsProvider = default, + Func? optionsProvider = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class - => AddKeyedCosmosDBCollection(services, serviceKey: null, name, connectionStringProvider, databaseNameProvider, optionsProvider, lifetime); + => AddKeyedCosmosCollection(services, serviceKey: null, name, connectionStringProvider, databaseNameProvider, optionsProvider, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// using the provided and . /// /// The type of the key. @@ -262,13 +262,13 @@ public static IServiceCollection AddCosmosDBCollection( /// Service collection. [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddKeyedCosmosDBCollection( + public static IServiceCollection AddKeyedCosmosCollection( this IServiceCollection services, object? serviceKey, string name, Func connectionStringProvider, Func databaseNameProvider, - Func? optionsProvider = default, + Func? optionsProvider = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class @@ -278,12 +278,12 @@ public static IServiceCollection AddKeyedCosmosDBCollection( Throw.IfNull(connectionStringProvider); Throw.IfNull(databaseNameProvider); - services.Add(new ServiceDescriptor(typeof(CosmosDBCollection), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosCollection), serviceKey, (sp, _) => { var options = GetCollectionOptions(sp, optionsProvider); var clientOptions = CreateClientOptions(options?.JsonSerializerOptions); - return new CosmosDBCollection( + return new CosmosCollection( connectionString: connectionStringProvider(sp), databaseName: databaseNameProvider(sp), name: name, @@ -301,16 +301,16 @@ private static void AddAbstractions(IServiceCollection services, where TRecord : class { services.Add(new ServiceDescriptor(typeof(VectorStoreCollection), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); services.Add(new ServiceDescriptor(typeof(IVectorSearchable), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); services.Add(new ServiceDescriptor(typeof(IKeywordHybridSearchable), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); } - private static CosmosDBVectorStoreOptions? GetStoreOptions(IServiceProvider sp, Func? optionsProvider) + private static CosmosVectorStoreOptions? GetStoreOptions(IServiceProvider sp, Func? optionsProvider) { var options = optionsProvider?.Invoke(sp); if (options?.EmbeddingGenerator is not null) @@ -324,7 +324,7 @@ private static void AddAbstractions(IServiceCollection services, : new(options) { EmbeddingGenerator = embeddingGenerator }; // Create a brand new copy in order to avoid modifying the original options. } - private static CosmosDBCollectionOptions? GetCollectionOptions(IServiceProvider sp, Func? optionsProvider) + private static CosmosCollectionOptions? GetCollectionOptions(IServiceProvider sp, Func? optionsProvider) { var options = optionsProvider?.Invoke(sp); if (options?.EmbeddingGenerator is not null) diff --git a/MEVD/src/AzureCosmosDB/CosmosDBVectorStore.cs b/MEVD/src/AzureCosmosDB/CosmosVectorStore.cs similarity index 84% rename from MEVD/src/AzureCosmosDB/CosmosDBVectorStore.cs rename to MEVD/src/AzureCosmosDB/CosmosVectorStore.cs index e671b99..712bfe1 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBVectorStore.cs +++ b/MEVD/src/AzureCosmosDB/CosmosVectorStore.cs @@ -18,17 +18,17 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Class for accessing the list of collections in a Azure CosmosDB NoSQL vector store. +/// Class for accessing the list of collections in a Azure Cosmos NoSQL vector store. /// /// /// This class can be used with collections of any schema type, but requires you to provide schema information when getting a collection. /// -public sealed class CosmosDBVectorStore : VectorStore +public sealed class CosmosVectorStore : VectorStore { /// Metadata about vector store. private readonly VectorStoreMetadata _metadata; - /// that can be used to manage the collections in Azure CosmosDB NoSQL. + /// that can be used to manage the collections in Azure Cosmos NoSQL. private readonly Database _database; private readonly ClientWrapper _clientWrapper; @@ -40,35 +40,35 @@ public sealed class CosmosDBVectorStore : VectorStore private readonly IEmbeddingGenerator? _embeddingGenerator; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// that can be used to manage the collections in Azure CosmosDB NoSQL. + /// that can be used to manage the collections in Azure Cosmos NoSQL. /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosDBVectorStore(Database database, CosmosDBVectorStoreOptions? options = null) + public CosmosVectorStore(Database database, CosmosVectorStoreOptions? options = null) : this(new(database.Client, ownsClient: false), _ => database, options) { Throw.IfNull(database); } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// Connection string required to connect to Azure CosmosDB NoSQL. - /// Database name for Azure CosmosDB NoSQL. + /// Connection string required to connect to Azure Cosmos NoSQL. + /// Database name for Azure Cosmos NoSQL. /// Optional configuration options for . /// Optional configuration options for . - public CosmosDBVectorStore(string connectionString, string databaseName, - CosmosClientOptions? clientOptions = null, CosmosDBVectorStoreOptions? storeOptions = null) + public CosmosVectorStore(string connectionString, string databaseName, + CosmosClientOptions? clientOptions = null, CosmosVectorStoreOptions? storeOptions = null) : this(new ClientWrapper(new CosmosClient(connectionString, clientOptions), ownsClient: true), client => client.GetDatabase(databaseName), storeOptions) { Throw.IfNullOrWhitespace(connectionString); Throw.IfNullOrWhitespace(databaseName); } - private CosmosDBVectorStore(ClientWrapper clientWrapper, - Func databaseProvider, CosmosDBVectorStoreOptions? options) + private CosmosVectorStore(ClientWrapper clientWrapper, + Func databaseProvider, CosmosVectorStoreOptions? options) { try { @@ -78,7 +78,7 @@ private CosmosDBVectorStore(ClientWrapper clientWrapper, this._metadata = new() { - VectorStoreSystemName = CosmosDBConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosConstants.VectorStoreSystemName, VectorStoreName = this._database.Id }; } @@ -105,13 +105,13 @@ protected override void Dispose(bool disposing) [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] #if NET - public override CosmosDBCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) + public override CosmosCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) #else public override VectorStoreCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) #endif => typeof(TRecord) == typeof(Dictionary) ? throw new ArgumentException(VectorDataStrings.GetCollectionWithDictionaryNotSupported) - : new CosmosDBCollection( + : new CosmosCollection( this._clientWrapper.Share(), _ => this._database, name, @@ -126,11 +126,11 @@ public override VectorStoreCollection GetCollection> GetDynamicCollection(string name, VectorStoreCollectionDefinition definition) #endif - => new CosmosDBDynamicCollection( + => new CosmosDynamicCollection( this._clientWrapper.Share(), _ => this._database, name, diff --git a/MEVD/src/AzureCosmosDB/CosmosDBVectorStoreOptions.cs b/MEVD/src/AzureCosmosDB/CosmosVectorStoreOptions.cs similarity index 69% rename from MEVD/src/AzureCosmosDB/CosmosDBVectorStoreOptions.cs rename to MEVD/src/AzureCosmosDB/CosmosVectorStoreOptions.cs index d147dc3..fe0ff8e 100644 --- a/MEVD/src/AzureCosmosDB/CosmosDBVectorStoreOptions.cs +++ b/MEVD/src/AzureCosmosDB/CosmosVectorStoreOptions.cs @@ -7,25 +7,25 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Options when creating a . +/// Options when creating a . /// -public sealed class CosmosDBVectorStoreOptions +public sealed class CosmosVectorStoreOptions { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public CosmosDBVectorStoreOptions() + public CosmosVectorStoreOptions() { } - internal CosmosDBVectorStoreOptions(CosmosDBVectorStoreOptions? source) + internal CosmosVectorStoreOptions(CosmosVectorStoreOptions? source) { this.JsonSerializerOptions = source?.JsonSerializerOptions; this.EmbeddingGenerator = source?.EmbeddingGenerator; } /// - /// Gets or sets the JSON serializer options to use when converting between the data model and the Azure CosmosDB NoSQL record. + /// Gets or sets the JSON serializer options to use when converting between the data model and the Azure Cosmos NoSQL record. /// public JsonSerializerOptions? JsonSerializerOptions { get; set; } diff --git a/MEVD/src/AzureCosmosDB/ICosmosDBMapper.cs b/MEVD/src/AzureCosmosDB/ICosmosMapper.cs similarity index 94% rename from MEVD/src/AzureCosmosDB/ICosmosDBMapper.cs rename to MEVD/src/AzureCosmosDB/ICosmosMapper.cs index f3c8440..2d57569 100644 --- a/MEVD/src/AzureCosmosDB/ICosmosDBMapper.cs +++ b/MEVD/src/AzureCosmosDB/ICosmosMapper.cs @@ -7,7 +7,7 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB; -internal interface ICosmosDBMapper +internal interface ICosmosMapper { /// /// Maps from the consumer record data model to the storage model. diff --git a/MEVD/src/AzureCosmosDB/README.md b/MEVD/src/AzureCosmosDB/README.md index 3247f51..71451a5 100644 --- a/MEVD/src/AzureCosmosDB/README.md +++ b/MEVD/src/AzureCosmosDB/README.md @@ -18,7 +18,7 @@ using Microsoft.Extensions.VectorData; CosmosClient client = new(""); Database database = client.GetDatabase("vector-database"); -VectorStore vectorStore = new CosmosDBVectorStore(database); +VectorStore vectorStore = new CosmosVectorStore(database); VectorStoreCollection collection = vectorStore.GetCollection("hotels"); ``` @@ -28,8 +28,8 @@ You can also register the provider with dependency injection: ```csharp using Microsoft.Extensions.DependencyInjection; -services.AddCosmosDBVectorStore("", "vector-database"); -services.AddCosmosDBCollection( +services.AddCosmosVectorStore("", "vector-database"); +services.AddCosmosCollection( name: "hotels", connectionString: "", databaseName: "vector-database"); diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBBasicModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosBasicModelTests.cs similarity index 55% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBBasicModelTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosBasicModelTests.cs index b94237b..bc91727 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBBasicModelTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosBasicModelTests.cs @@ -8,19 +8,19 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBBasicModelTests(CosmosDBBasicModelTests.Fixture fixture) - : BasicModelTests(fixture), IClassFixture +public sealed class CosmosBasicModelTests(CosmosBasicModelTests.Fixture fixture) + : BasicModelTests(fixture), IClassFixture { public override Task SearchAsync_with_Skip() { - Assert.SkipUnless(!((CosmosDBTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); + Assert.SkipUnless(!((CosmosTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); return base.SearchAsync_with_Skip(); } public new sealed class Fixture : BasicModelTests.Fixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBBasicModelTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosBasicModelTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBCollectionManagementTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosCollectionManagementTests.cs similarity index 78% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBCollectionManagementTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosCollectionManagementTests.cs index de9f699..aa4814f 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBCollectionManagementTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosCollectionManagementTests.cs @@ -7,7 +7,7 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBCollectionManagementTests(CosmosDBFixture fixture) - : CollectionManagementTests(fixture), IClassFixture +public sealed class CosmosCollectionManagementTests(CosmosFixture fixture) + : CollectionManagementTests(fixture), IClassFixture { } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDataTypeTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDataTypeTests.cs similarity index 78% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDataTypeTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDataTypeTests.cs index 068b21f..7e3444b 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDataTypeTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDataTypeTests.cs @@ -9,15 +9,15 @@ namespace AzureCosmosDB.ConformanceTests; // The type is internal to disable the tests due to emulator limitations -internal sealed class CosmosDBDataTypeTests(CosmosDBDataTypeTests.Fixture fixture) - : DataTypeTests.DefaultRecord>(fixture), IClassFixture +internal sealed class CosmosDataTypeTests(CosmosDataTypeTests.Fixture fixture) + : DataTypeTests.DefaultRecord>(fixture), IClassFixture { public override Task DateTimeOffset() => Task.CompletedTask; public new sealed class Fixture : DataTypeTests.DefaultRecord>.Fixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBDataTypeTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosDataTypeTests))); public override TestStore TestStore => _store.Value; diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDependencyInjectionTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDependencyInjectionTests.cs similarity index 57% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDependencyInjectionTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDependencyInjectionTests.cs index f62204d..73a426d 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDependencyInjectionTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDependencyInjectionTests.cs @@ -8,8 +8,8 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBDependencyInjectionTests - : DependencyInjectionTests.Record>, string, DependencyInjectionTests.Record> +public sealed class CosmosDependencyInjectionTests + : DependencyInjectionTests.Record>, string, DependencyInjectionTests.Record> { private const string TestConnectionString = "AccountEndpoint=https://localhost:8081;AccountKey=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="; @@ -18,8 +18,8 @@ public sealed class CosmosDBDependencyInjectionTests get { yield return (services, serviceKey, lifetime) => serviceKey is null - ? services.AddCosmosDBVectorStore(TestConnectionString, nameof(CosmosDBDependencyInjectionTests), lifetime: lifetime) - : services.AddKeyedCosmosDBVectorStore(serviceKey, TestConnectionString, nameof(CosmosDBDependencyInjectionTests), lifetime: lifetime); + ? services.AddCosmosVectorStore(TestConnectionString, nameof(CosmosDependencyInjectionTests), lifetime: lifetime) + : services.AddKeyedCosmosVectorStore(serviceKey, TestConnectionString, nameof(CosmosDependencyInjectionTests), lifetime: lifetime); } } @@ -28,8 +28,8 @@ public sealed class CosmosDBDependencyInjectionTests get { yield return (services, serviceKey, name, lifetime) => serviceKey is null - ? services.AddCosmosDBCollection(name, TestConnectionString, nameof(CosmosDBDependencyInjectionTests), lifetime: lifetime) - : services.AddKeyedCosmosDBCollection(serviceKey, name, TestConnectionString, nameof(CosmosDBDependencyInjectionTests), lifetime: lifetime); + ? services.AddCosmosCollection(name, TestConnectionString, nameof(CosmosDependencyInjectionTests), lifetime: lifetime) + : services.AddKeyedCosmosCollection(serviceKey, name, TestConnectionString, nameof(CosmosDependencyInjectionTests), lifetime: lifetime); } } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDistanceFunctionTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDistanceFunctionTests.cs similarity index 75% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDistanceFunctionTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDistanceFunctionTests.cs index 502a75a..d240533 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDistanceFunctionTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDistanceFunctionTests.cs @@ -8,8 +8,8 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBDistanceFunctionTests(CosmosDBDistanceFunctionTests.Fixture fixture) - : DistanceFunctionTests(fixture), IClassFixture +public sealed class CosmosDistanceFunctionTests(CosmosDistanceFunctionTests.Fixture fixture) + : DistanceFunctionTests(fixture), IClassFixture { public override Task CosineDistance() => Assert.ThrowsAsync(base.CosineDistance); public override Task EuclideanSquaredDistance() => Assert.ThrowsAsync(base.EuclideanSquaredDistance); @@ -19,14 +19,14 @@ public sealed class CosmosDBDistanceFunctionTests(CosmosDBDistanceFunctionTests. public override Task EuclideanDistance() { - Assert.SkipUnless(!((CosmosDBTestStore)fixture.TestStore).UsesLocalEmulator, "Fails on emulator, most likely due to emulator bug"); + Assert.SkipUnless(!((CosmosTestStore)fixture.TestStore).UsesLocalEmulator, "Fails on emulator, most likely due to emulator bug"); return base.EuclideanDistance(); } public new sealed class Fixture : DistanceFunctionTests.Fixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBDistanceFunctionTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosDistanceFunctionTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDynamicModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDynamicModelTests.cs similarity index 58% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDynamicModelTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDynamicModelTests.cs index 526e00c..a9b8e3b 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBDynamicModelTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDynamicModelTests.cs @@ -8,20 +8,20 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBDynamicModelTests(CosmosDBDynamicModelTests.Fixture fixture) - : DynamicModelTests(fixture), IClassFixture +public sealed class CosmosDynamicModelTests(CosmosDynamicModelTests.Fixture fixture) + : DynamicModelTests(fixture), IClassFixture { public override Task SearchAsync_with_Skip() { // The vNext emulator's DiskANN index does not support OFFSET in vector search. - Assert.SkipUnless(!((CosmosDBTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); + Assert.SkipUnless(!((CosmosTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); return base.SearchAsync_with_Skip(); } public new sealed class Fixture : DynamicModelTests.Fixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBDynamicModelTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosDynamicModelTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingGenerationTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingGenerationTests.cs similarity index 51% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingGenerationTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingGenerationTests.cs index 039c450..716dfc8 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingGenerationTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingGenerationTests.cs @@ -12,46 +12,46 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBEmbeddingGenerationTests( - CosmosDBEmbeddingGenerationTests.StringVectorFixture stringVectorFixture, - CosmosDBEmbeddingGenerationTests.RomOfFloatVectorFixture romOfFloatVectorFixture) +public sealed class CosmosEmbeddingGenerationTests( + CosmosEmbeddingGenerationTests.StringVectorFixture stringVectorFixture, + CosmosEmbeddingGenerationTests.RomOfFloatVectorFixture romOfFloatVectorFixture) : EmbeddingGenerationTests(stringVectorFixture, romOfFloatVectorFixture), - IClassFixture, - IClassFixture + IClassFixture, + IClassFixture { public new sealed class StringVectorFixture : EmbeddingGenerationTests.StringVectorFixture { public override string DefaultIndexKind => "DiskAnn"; - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBEmbeddingGenerationTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosEmbeddingGenerationTests))); public override TestStore TestStore => _store.Value; public override VectorStoreCollectionDefinition CreateRecordDefinition() - => CosmosDBConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); + => CosmosConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator = null) - => new CosmosDBVectorStore( - ((CosmosDBTestStore)TestStore).Database, - new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosDBTestStore.SerializerOptions }); + => new CosmosVectorStore( + ((CosmosTestStore)TestStore).Database, + new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosTestStore.SerializerOptions }); public override Func[] DependencyInjectionStoreRegistrationDelegates => [ services => services - .AddSingleton(((CosmosDBTestStore)TestStore).Database) - .AddCosmosDBVectorStore(new() + .AddSingleton(((CosmosTestStore)TestStore).Database) + .AddCosmosVectorStore(new() { - JsonSerializerOptions = CosmosDBTestStore.SerializerOptions, + JsonSerializerOptions = CosmosTestStore.SerializerOptions, }), ]; public override Func[] DependencyInjectionCollectionRegistrationDelegates => [ services => services - .AddSingleton(((CosmosDBTestStore)TestStore).Database) - .AddCosmosDBCollection(CollectionName, new() + .AddSingleton(((CosmosTestStore)TestStore).Database) + .AddCosmosCollection(CollectionName, new() { - JsonSerializerOptions = CosmosDBTestStore.SerializerOptions, + JsonSerializerOptions = CosmosTestStore.SerializerOptions, }), ]; } @@ -60,33 +60,33 @@ public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGene { public override string DefaultIndexKind => "DiskAnn"; - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBEmbeddingGenerationTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosEmbeddingGenerationTests))); public override TestStore TestStore => _store.Value; public override VectorStoreCollectionDefinition CreateRecordDefinition() - => CosmosDBConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); + => CosmosConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator = null) - => new CosmosDBVectorStore( - ((CosmosDBTestStore)TestStore).Database, - new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosDBTestStore.SerializerOptions }); + => new CosmosVectorStore( + ((CosmosTestStore)TestStore).Database, + new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosTestStore.SerializerOptions }); public override Func[] DependencyInjectionStoreRegistrationDelegates => [ - services => services.AddCosmosDBVectorStore( - ((CosmosDBTestStore)TestStore).ConnectionString, - nameof(CosmosDBEmbeddingGenerationTests), - new() { JsonSerializerOptions = CosmosDBTestStore.SerializerOptions }) + services => services.AddCosmosVectorStore( + ((CosmosTestStore)TestStore).ConnectionString, + nameof(CosmosEmbeddingGenerationTests), + new() { JsonSerializerOptions = CosmosTestStore.SerializerOptions }) ]; public override Func[] DependencyInjectionCollectionRegistrationDelegates => [ - services => services.AddCosmosDBCollection( + services => services.AddCosmosCollection( CollectionName, - ((CosmosDBTestStore)TestStore).ConnectionString, - nameof(CosmosDBEmbeddingGenerationTests), - new() { JsonSerializerOptions = CosmosDBTestStore.SerializerOptions }) + ((CosmosTestStore)TestStore).ConnectionString, + nameof(CosmosEmbeddingGenerationTests), + new() { JsonSerializerOptions = CosmosTestStore.SerializerOptions }) ]; } } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingTypeTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingTypeTests.cs similarity index 71% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingTypeTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingTypeTests.cs index 3eacaf7..777d588 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBEmbeddingTypeTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingTypeTests.cs @@ -10,14 +10,14 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBEmbeddingTypeTests(CosmosDBEmbeddingTypeTests.Fixture fixture) - : EmbeddingTypeTests(fixture), IClassFixture +public sealed class CosmosEmbeddingTypeTests(CosmosEmbeddingTypeTests.Fixture fixture) + : EmbeddingTypeTests(fixture), IClassFixture { public new sealed class Fixture : EmbeddingTypeTests.Fixture { public override string DefaultIndexKind => "DiskAnn"; - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBEmbeddingTypeTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosEmbeddingTypeTests))); public override TestStore TestStore => _store.Value; @@ -25,7 +25,7 @@ public override VectorStoreCollectionDefinition CreateRecordDefinition CosmosDBConformanceTestHelpers.UseLowerCaseVectorStorageName( + => CosmosConformanceTestHelpers.UseLowerCaseVectorStorageName( base.CreateRecordDefinition(embeddingGenerator, distanceFunction, dimensions), "vector"); } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBFilterTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosFilterTests.cs similarity index 66% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBFilterTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosFilterTests.cs index 5232352..dae2942 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBFilterTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosFilterTests.cs @@ -9,12 +9,12 @@ namespace AzureCosmosDB.ConformanceTests; // The type is internal to disable the tests due to emulator limitations -internal sealed class CosmosDBFilterTests(CosmosDBFilterTests.Fixture fixture) - : FilterTests(fixture), IClassFixture +internal sealed class CosmosFilterTests(CosmosFilterTests.Fixture fixture) + : FilterTests(fixture), IClassFixture { public new sealed class Fixture : FilterTests.Fixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBFilterTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosFilterTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBHybridSearchTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosHybridSearchTests.cs similarity index 58% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBHybridSearchTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosHybridSearchTests.cs index 7fe6639..7488846 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBHybridSearchTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosHybridSearchTests.cs @@ -9,23 +9,23 @@ namespace AzureCosmosDB.ConformanceTests; // The type is internal to disable the tests due to emulator limitations -internal sealed class CosmosDBHybridSearchTests( - CosmosDBHybridSearchTests.VectorAndStringFixture vectorAndStringFixture, - CosmosDBHybridSearchTests.MultiTextFixture multiTextFixture) +internal sealed class CosmosHybridSearchTests( + CosmosHybridSearchTests.VectorAndStringFixture vectorAndStringFixture, + CosmosHybridSearchTests.MultiTextFixture multiTextFixture) : HybridSearchTests(vectorAndStringFixture, multiTextFixture), - IClassFixture, - IClassFixture + IClassFixture, + IClassFixture { public new sealed class VectorAndStringFixture : HybridSearchTests.VectorAndStringFixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(VectorAndStringFixture))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(VectorAndStringFixture))); public override TestStore TestStore => _store.Value; } public new sealed class MultiTextFixture : HybridSearchTests.MultiTextFixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(MultiTextFixture))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(MultiTextFixture))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBIndexKindTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosIndexKindTests.cs similarity index 59% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBIndexKindTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosIndexKindTests.cs index 29b33cc..5c9ce24 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBIndexKindTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosIndexKindTests.cs @@ -8,22 +8,22 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBIndexKindTests(CosmosDBIndexKindTests.Fixture fixture) - : IndexKindTests(fixture), IClassFixture +public sealed class CosmosIndexKindTests(CosmosIndexKindTests.Fixture fixture) + : IndexKindTests(fixture), IClassFixture { [Fact] public Task DiskAnn() => Test("DiskAnn"); public override Task Flat() { - Assert.SkipUnless(!((CosmosDBTestStore)fixture.TestStore).UsesLocalEmulator, "Not supported on emulator."); + Assert.SkipUnless(!((CosmosTestStore)fixture.TestStore).UsesLocalEmulator, "Not supported on emulator."); return base.Flat(); } public new sealed class Fixture : IndexKindTests.Fixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBIndexKindTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosIndexKindTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBKeyTypeTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosKeyTypeTests.cs similarity index 62% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBKeyTypeTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosKeyTypeTests.cs index 6df92e7..b88e4bc 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBKeyTypeTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosKeyTypeTests.cs @@ -8,12 +8,12 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBKeyTypeTests(CosmosDBKeyTypeTests.Fixture fixture) - : KeyTypeTests(fixture), IClassFixture +public sealed class CosmosKeyTypeTests(CosmosKeyTypeTests.Fixture fixture) + : KeyTypeTests(fixture), IClassFixture { public new sealed class Fixture : KeyTypeTests.Fixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBKeyTypeTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosKeyTypeTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBMultiVectorModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosMultiVectorModelTests.cs similarity index 67% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBMultiVectorModelTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosMultiVectorModelTests.cs index 864060a..1740295 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBMultiVectorModelTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosMultiVectorModelTests.cs @@ -8,12 +8,12 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBMultiVectorModelTests(CosmosDBMultiVectorModelTests.Fixture fixture) - : MultiVectorModelTests(fixture), IClassFixture +public sealed class CosmosMultiVectorModelTests(CosmosMultiVectorModelTests.Fixture fixture) + : MultiVectorModelTests(fixture), IClassFixture { public new sealed class Fixture : MultiVectorModelTests.Fixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBMultiVectorModelTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosMultiVectorModelTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoDataModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoDataModelTests.cs similarity index 61% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoDataModelTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoDataModelTests.cs index 07c16d2..4cc91bf 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoDataModelTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoDataModelTests.cs @@ -8,12 +8,12 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBNoDataModelTests(CosmosDBNoDataModelTests.Fixture fixture) - : NoDataModelTests(fixture), IClassFixture +public sealed class CosmosNoDataModelTests(CosmosNoDataModelTests.Fixture fixture) + : NoDataModelTests(fixture), IClassFixture { public new sealed class Fixture : NoDataModelTests.Fixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBNoDataModelTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosNoDataModelTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoVectorModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoVectorModelTests.cs similarity index 61% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoVectorModelTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoVectorModelTests.cs index 1bd1032..2cfc2b6 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBNoVectorModelTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoVectorModelTests.cs @@ -8,12 +8,12 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBNoVectorModelTests(CosmosDBNoVectorModelTests.Fixture fixture) - : NoVectorModelTests(fixture), IClassFixture +public sealed class CosmosNoVectorModelTests(CosmosNoVectorModelTests.Fixture fixture) + : NoVectorModelTests(fixture), IClassFixture { public new sealed class Fixture : NoVectorModelTests.Fixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBNoVectorModelTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosNoVectorModelTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBTestSuiteImplementationTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosTestSuiteImplementationTests.cs similarity index 85% rename from MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBTestSuiteImplementationTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosTestSuiteImplementationTests.cs index 4b12ffc..80ba470 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDBTestSuiteImplementationTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosTestSuiteImplementationTests.cs @@ -6,7 +6,7 @@ namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosDBTestSuiteImplementationTests : TestSuiteImplementationTests +public sealed class CosmosTestSuiteImplementationTests : TestSuiteImplementationTests { protected override ICollection IgnoredTestBases { get; } = [ diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBConformanceTestHelpers.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosConformanceTestHelpers.cs similarity index 91% rename from MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBConformanceTestHelpers.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosConformanceTestHelpers.cs index ac7be07..536e4a4 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBConformanceTestHelpers.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosConformanceTestHelpers.cs @@ -5,7 +5,7 @@ namespace AzureCosmosDB.ConformanceTests.Support; -internal static class CosmosDBConformanceTestHelpers +internal static class CosmosConformanceTestHelpers { public static VectorStoreCollectionDefinition UseLowerCaseVectorStorageName( VectorStoreCollectionDefinition definition, diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBFixture.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosFixture.cs similarity index 63% rename from MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBFixture.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosFixture.cs index 7738291..80518f6 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBFixture.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosFixture.cs @@ -5,9 +5,9 @@ namespace AzureCosmosDB.ConformanceTests.Support; -public sealed class CosmosDBFixture : VectorStoreFixture +public sealed class CosmosFixture : VectorStoreFixture { - private readonly Lazy _store = new(() => new CosmosDBTestStore(nameof(CosmosDBFixture))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosFixture))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestEnvironment.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestEnvironment.cs similarity index 91% rename from MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestEnvironment.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestEnvironment.cs index c254f4d..50d6eae 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestEnvironment.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestEnvironment.cs @@ -7,13 +7,13 @@ namespace AzureCosmosDB.ConformanceTests.Support; #pragma warning disable CA1810 // Initialize all static fields when those fields are declared -internal static class CosmosDBTestEnvironment +internal static class CosmosTestEnvironment { public static readonly string? ConnectionString; public static bool IsConnectionStringDefined => ConnectionString is not null; - static CosmosDBTestEnvironment() + static CosmosTestEnvironment() { var configuration = new ConfigurationBuilder() .AddJsonFile(path: "testsettings.json", optional: true) diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestStore.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestStore.cs similarity index 89% rename from MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestStore.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestStore.cs index 7fb1c30..80d381b 100644 --- a/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosDBTestStore.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestStore.cs @@ -13,7 +13,7 @@ namespace AzureCosmosDB.ConformanceTests.Support; #pragma warning disable CA1001 // Type owns disposable fields but is not disposable /// The emulator does not support running multiple queries simultaneously, so we create a unique database for each test store instance. -internal sealed class CosmosDBTestStore(string uniqueDatabaseName) : TestStore +internal sealed class CosmosTestStore(string uniqueDatabaseName) : TestStore { private CosmosDbContainer? _container; private CosmosClient? _client; @@ -29,7 +29,7 @@ internal sealed class CosmosDBTestStore(string uniqueDatabaseName) : TestStore public static JsonSerializerOptions SerializerOptions { get; } = new(JsonSerializerDefaults.Web) { - PropertyNamingPolicy = new CosmosDBTestJsonNamingPolicy() + PropertyNamingPolicy = new CosmosTestJsonNamingPolicy() }; public Database Database => _database ?? throw new InvalidOperationException("Cosmos DB test store has not been started."); @@ -37,7 +37,7 @@ internal sealed class CosmosDBTestStore(string uniqueDatabaseName) : TestStore public override VectorStoreCollection CreateCollection( string name, VectorStoreCollectionDefinition definition) - => new CosmosDBCollection( + => new CosmosCollection( Database, name, new() @@ -49,7 +49,7 @@ public override VectorStoreCollection CreateCollection> CreateDynamicCollection( string name, VectorStoreCollectionDefinition definition) - => new CosmosDBDynamicCollection( + => new CosmosDynamicCollection( Database, name, new() @@ -60,9 +60,9 @@ public override VectorStoreCollection CreateCollection CreateDatabaseWithRetryAsync() throw new TimeoutException("Cosmos DB did not become available within one minute."); } - private sealed class CosmosDBTestJsonNamingPolicy : JsonNamingPolicy + private sealed class CosmosTestJsonNamingPolicy : JsonNamingPolicy { public override string ConvertName(string name) => name is "Vector" or "Embedding" diff --git a/MEVD/test/AzureCosmosDB.UnitTests/CosmosDBOptionsTests.cs b/MEVD/test/AzureCosmosDB.UnitTests/CosmosOptionsTests.cs similarity index 90% rename from MEVD/test/AzureCosmosDB.UnitTests/CosmosDBOptionsTests.cs rename to MEVD/test/AzureCosmosDB.UnitTests/CosmosOptionsTests.cs index 4cf42a6..3894d38 100644 --- a/MEVD/test/AzureCosmosDB.UnitTests/CosmosDBOptionsTests.cs +++ b/MEVD/test/AzureCosmosDB.UnitTests/CosmosOptionsTests.cs @@ -9,13 +9,13 @@ namespace CommunityToolkit.VectorData.AzureCosmosDB.UnitTests; -public sealed class CosmosDBOptionsTests +public sealed class CosmosOptionsTests { [Fact] public void CollectionOptionsPropertiesCanBeConfigured() { JsonSerializerOptions serializerOptions = new(JsonSerializerDefaults.Web); - CosmosDBCollectionOptions source = new() + CosmosCollectionOptions source = new() { JsonSerializerOptions = serializerOptions, PartitionKeyProperties = new[] { "tenantId", "category" }, @@ -35,7 +35,7 @@ public void CollectionOptionsPropertiesCanBeConfigured() public void VectorStoreOptionsPropertiesCanBeConfigured() { JsonSerializerOptions serializerOptions = new(JsonSerializerDefaults.Web); - CosmosDBVectorStoreOptions source = new() + CosmosVectorStoreOptions source = new() { JsonSerializerOptions = serializerOptions, }; From d93753466b4904c4c42921e9ca32273b6f98aa41 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Wed, 19 Aug 2026 16:01:19 +0200 Subject: [PATCH 3/3] Update MEVD/src/AzureCosmosDB/README.md --- MEVD/src/AzureCosmosDB/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MEVD/src/AzureCosmosDB/README.md b/MEVD/src/AzureCosmosDB/README.md index 71451a5..40f73b9 100644 --- a/MEVD/src/AzureCosmosDB/README.md +++ b/MEVD/src/AzureCosmosDB/README.md @@ -5,7 +5,7 @@ ## Install ```xml - + ``` ## Get started