Skip to content

Commit

Permalink
ContainerProperties: Refactors Vector Embedding and Indexing Policy I…
Browse files Browse the repository at this point in the history
…nterfaces to Mark Them as Public for GA (#4845)

# Pull Request Template

## Description

The purpose of this PR is to mark the new `VectorEmbeddingPolicy` in the
`ContainerProperties` as a public surface interface for `GA` release,
and introducing new `VectorIndexes` in the `IndexingPolicy` to enable
Vector Similarity Search in Cosmos DB ecosystem.

Relevant PRs for the vector similarity work: 

- [ContainerProperties: Adds Vector Embedding and Indexing
Policy](#4379)
- [ContainerProperties: Refactors Vector Embedding and Indexing Policy
Interfaces to Mark Them as Public for
Preview](#4486)
- [VectorIndexDefinition: Adds Support for Partitioned
DiskANN](#4792)

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

## Closing issues

To automatically close an issue: closes #4825
  • Loading branch information
kundadebdatta authored Oct 24, 2024
1 parent f6ae4c4 commit ed75a42
Show file tree
Hide file tree
Showing 15 changed files with 409 additions and 428 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,7 @@ public ClientEncryptionPolicyDefinition WithClientEncryptionPolicy(int policyFor
/// </summary>
/// <param name="embeddings">List of vector embeddings to include in the policy definition.</param>
/// <returns>An instance of <see cref="VectorEmbeddingPolicyDefinition"/>.</returns>
#if PREVIEW
public
#else
internal
#endif
VectorEmbeddingPolicyDefinition WithVectorEmbeddingPolicy(
public VectorEmbeddingPolicyDefinition WithVectorEmbeddingPolicy(
Collection<Embedding> embeddings)
{
return new VectorEmbeddingPolicyDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,7 @@ public SpatialIndexDefinition<IndexingPolicyDefinition<T>> WithSpatialIndex()
/// Defines a <see cref="VectorIndexPath"/> in the current <see cref="Container"/>'s definition.
/// </summary>
/// <returns>An instance of <see cref="VectorIndexDefinition{T}"/>.</returns>
#if PREVIEW
public
#else
internal
#endif
VectorIndexDefinition<IndexingPolicyDefinition<T>> WithVectorIndex()
public VectorIndexDefinition<IndexingPolicyDefinition<T>> WithVectorIndex()
{
return new VectorIndexDefinition<IndexingPolicyDefinition<T>>(
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ namespace Microsoft.Azure.Cosmos.Fluent
/// <summary>
/// <see cref="VectorEmbeddingPolicy"/> fluent definition.
/// </summary>
#if PREVIEW
public
#else
internal
#endif
class VectorEmbeddingPolicyDefinition
public class VectorEmbeddingPolicyDefinition
{
private readonly ContainerBuilder parent;
private readonly Action<VectorEmbeddingPolicy> attachCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ namespace Microsoft.Azure.Cosmos.Fluent
/// Vector index fluent definition.
/// </summary>
/// <seealso cref="VectorIndexPath"/>
#if PREVIEW
public
#else
internal
#endif
class VectorIndexDefinition<T>
public class VectorIndexDefinition<T>
{
private readonly VectorIndexPath vectorIndexPath = new ();
private readonly T parent;
Expand Down Expand Up @@ -63,7 +58,12 @@ public VectorIndexDefinition<T> Path(
/// types DiskANN and quantizedFlat. Note that, the allowed range for this parameter is between 1 and 3.
/// </param>
/// <returns>An instance of the current <see cref="VectorIndexDefinition{T}"/>.</returns>
public VectorIndexDefinition<T> WithQuantizationByteSize(
#if PREVIEW
public
#else
internal
#endif
VectorIndexDefinition<T> WithQuantizationByteSize(
int quantizationByteSize)
{
this.vectorIndexPath.QuantizationByteSize = quantizationByteSize;
Expand All @@ -78,7 +78,12 @@ public VectorIndexDefinition<T> WithQuantizationByteSize(
/// This is an optional parameter and applies to index type DiskANN only. The allowed range for this parameter is between 25 and 500.
/// </param>
/// <returns>An instance of the current <see cref="VectorIndexDefinition{T}"/>.</returns>
public VectorIndexDefinition<T> WithIndexingSearchListSize(
#if PREVIEW
public
#else
internal
#endif
VectorIndexDefinition<T> WithIndexingSearchListSize(
int indexingSearchListSize)
{
this.vectorIndexPath.IndexingSearchListSize = indexingSearchListSize;
Expand All @@ -93,7 +98,12 @@ public VectorIndexDefinition<T> WithIndexingSearchListSize(
/// applies to index types DiskANN and quantizedFlat.
/// </param>
/// <returns>An instance of the current <see cref="VectorIndexDefinition{T}"/>.</returns>
public VectorIndexDefinition<T> WithVectorIndexShardKey(
#if PREVIEW
public
#else
internal
#endif
VectorIndexDefinition<T> WithVectorIndexShardKey(
string[] vectorIndexShardKey)
{
this.vectorIndexPath.VectorIndexShardKey = vectorIndexShardKey ?? throw new ArgumentNullException(nameof(vectorIndexShardKey));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,7 @@ public IndexingPolicy IndexingPolicy
/// </para>
/// </remarks>
[JsonIgnore]
#if PREVIEW
public
#else
internal
#endif
VectorEmbeddingPolicy VectorEmbeddingPolicy
public VectorEmbeddingPolicy VectorEmbeddingPolicy
{
get => this.vectorEmbeddingPolicyInternal;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ namespace Microsoft.Azure.Cosmos
/// Defines the distance function for a vector index specification in the Azure Cosmos DB service.
/// </summary>
/// <seealso cref="Embedding"/> for usage.
#if PREVIEW
public
#else
internal
#endif
enum DistanceFunction
public enum DistanceFunction
{
/// <summary>
/// Represents the euclidean distance function.
Expand Down
7 changes: 1 addition & 6 deletions Microsoft.Azure.Cosmos/src/Resource/Settings/Embedding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ namespace Microsoft.Azure.Cosmos
/// <summary>
/// Represents the embedding settings for the vector index.
/// </summary>
#if PREVIEW
public
#else
internal
#endif
class Embedding : IEquatable<Embedding>
public class Embedding : IEquatable<Embedding>
{
/// <summary>
/// Gets or sets a string containing the path of the vector index.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,7 @@ public IndexingPolicy()
/// ]]>
/// </example>
[JsonProperty(PropertyName = "vectorIndexes", NullValueHandling = NullValueHandling.Ignore)]
#if PREVIEW

public
#else
internal
#endif
Collection<VectorIndexPath> VectorIndexes { get; set; } = new Collection<VectorIndexPath>();
public Collection<VectorIndexPath> VectorIndexes { get; set; } = new Collection<VectorIndexPath>();

/// <summary>
/// Gets the full text indexes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ namespace Microsoft.Azure.Cosmos
/// <summary>
/// Defines the target data type of a vector index specification in the Azure Cosmos DB service.
/// </summary>
#if PREVIEW
public
#else
internal
#endif
enum VectorDataType
public enum VectorDataType
{
/// <summary>
/// Represent a float32 data type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ namespace Microsoft.Azure.Cosmos
/// Represents the vector embedding policy configuration for specifying the vector embeddings on documents in the collection in the Azure Cosmos DB service.
/// </summary>
/// <seealso cref="ContainerProperties"/>
#if PREVIEW
public
#else
internal
#endif
sealed class VectorEmbeddingPolicy
public sealed class VectorEmbeddingPolicy
{
/// <summary>
/// Initializes a new instance of the <see cref="VectorEmbeddingPolicy"/> class.
Expand Down
28 changes: 19 additions & 9 deletions Microsoft.Azure.Cosmos/src/Resource/Settings/VectorIndexPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ namespace Microsoft.Azure.Cosmos
/// }
/// ]]>
/// </example>
#if PREVIEW
public
#else
internal
#endif
sealed class VectorIndexPath
public sealed class VectorIndexPath
{
[JsonProperty(PropertyName = "indexingSearchListSize", NullValueHandling = NullValueHandling.Ignore)]
private int? indexingSearchListSizeInternal;
Expand All @@ -78,7 +73,12 @@ sealed class VectorIndexPath
/// The allowed range for this parameter is between 1 and 3.
/// </summary>
[JsonIgnore]
public int QuantizationByteSize
#if PREVIEW
public
#else
internal
#endif
int QuantizationByteSize
{
get => this.quantizationByteSizeInternal == null ? 0 : this.quantizationByteSizeInternal.Value;
set => this.quantizationByteSizeInternal = value;
Expand All @@ -89,7 +89,12 @@ public int QuantizationByteSize
/// The allowed range for this parameter is between 25 and 500.
/// </summary>
[JsonIgnore]
public int IndexingSearchListSize
#if PREVIEW
public
#else
internal
#endif
int IndexingSearchListSize
{
get => this.indexingSearchListSizeInternal == null ? 0 : this.indexingSearchListSizeInternal.Value;
set => this.indexingSearchListSizeInternal = value;
Expand All @@ -99,7 +104,12 @@ public int IndexingSearchListSize
/// Gets or sets the vector index shard key for the vector index path. This is only applicable for the quantizedFlat and diskann vector index types.
/// </summary>
[JsonProperty(PropertyName = "vectorIndexShardKey", NullValueHandling = NullValueHandling.Ignore)]
public string[] VectorIndexShardKey { get; set; }
#if PREVIEW
public
#else
internal
#endif
string[] VectorIndexShardKey { get; set; }

/// <summary>
/// This contains additional values for scenarios where the SDK is not aware of new fields.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ namespace Microsoft.Azure.Cosmos
/// <summary>
/// Defines the target index type of an vector index path specification in the Azure Cosmos DB service.
/// </summary>
#if PREVIEW
public
#else
internal
#endif
enum VectorIndexType
public enum VectorIndexType
{
/// <summary>
/// Represents a flat vector index type.
Expand Down
Loading

0 comments on commit ed75a42

Please sign in to comment.