-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[Cosmos][VectorSearch] Non Streaming Order By Query #39897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kushagraThapar
merged 46 commits into
Azure:main
from
aayush3011:users/akataria/nonStreamingOrderBy
May 20, 2024
Merged
Changes from 3 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
540a16d
Initial changes
aayush3011 6f49c75
Initial changes
aayush3011 97509eb
Merge branch 'main' into users/akataria/nonStreamingOrderBy
aayush3011 528a0eb
[Cosmos][VectorIndex]Adding changes for vectorIndex and vectorEmbeddi…
aayush3011 86b36d3
Merge branch 'main' into users/akataria/nonStreamingOrderBy
aayush3011 a979c11
Initial changes
aayush3011 e2756a5
Initial changes
aayush3011 8be2277
Initial changes
aayush3011 e491b9d
Resolving comments
aayush3011 151bb50
Fixing build issues
aayush3011 73afd5b
Merge branch 'Azure:main' into users/akataria/nonStreamingOrderBy
aayush3011 148cba5
[Cosmos][VectorSearch] Non Streaming Order By Query (#40085)
aayush3011 3b0d751
Merge branch 'Azure:main' into users/akataria/nonStreamingOrderBy
aayush3011 87572f7
Merge branch 'feature/vector_search' into users/akataria/nonStreaming…
aayush3011 df7e838
[Cosmos][VectorSearch] Non Streaming Order By Query (#40096)
aayush3011 179f904
Initial changes
aayush3011 5602e33
Merge branch 'users/akataria/nonStreamingOrderBy' of github.com:aayus…
aayush3011 36ab9b7
Merge branch 'feature/vector_search' into users/akataria/nonStreaming…
aayush3011 70639b5
Initial changes
aayush3011 c45c3a5
Fixes
aayush3011 6c255ee
Merge branch 'Azure:main' into users/akataria/nonStreamingOrderBy
aayush3011 9d427e6
Users/akataria/vectorindexing (#40117)
aayush3011 1cadb1b
Merge branch 'feature/VectorSearch' into users/akataria/nonStreamingO…
aayush3011 0f1be0c
Users/akataria/non streaming order by (#40118)
aayush3011 d4dcad2
Fixing some merge issues
aayush3011 cdaa5bc
Fixing some merge issues
aayush3011 dfa8b64
Fixing some merge issues
aayush3011 7549cbe
Resolving comments
aayush3011 c6e2376
Merge branch 'feature/VectorSearch' into users/akataria/nonStreamingO…
aayush3011 30d8370
Users/akataria/vectorindexing (#40158)
aayush3011 8279358
Users/akataria/non streaming order by (#40159)
aayush3011 dd9d13b
Fixing build issue
aayush3011 d966af4
Merge branch 'feature/VectorSearch' into users/akataria/nonStreamingO…
aayush3011 9eb9208
Fixing build issue
aayush3011 1aaecef
Merge branch 'users/akataria/nonStreamingOrderBy' of github.com:aayus…
aayush3011 8bf4f8d
Merge branch 'main' into users/akataria/nonStreamingOrderBy
aayush3011 943cc4c
Adding tests
aayush3011 1db9b31
Adding capability for CI pipeline
aayush3011 2770b0f
Updating the PQ logic
aayush3011 7002362
Resolving comments, adding new test cases
aayush3011 508e94a
Adding argument to run emulator tests
aayush3011 822bd67
fixing emulator test pipeline
aayush3011 46fe7cb
fixing emulator test pipeline
aayush3011 5657b75
Adding logging for variable AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY
aayush3011 015a77c
Adding logging for variable AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY
aayush3011 f87be45
fixing emulator test pipeline
aayush3011 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
345 changes: 345 additions & 0 deletions
345
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosVectorDataType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.cosmos.models; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonValue; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| /** | ||
| * Data types for the embeddings in Cosmos DB database service. | ||
| */ | ||
| public enum CosmosVectorDataType { | ||
| /** | ||
| * Represents a int8 data type. | ||
| */ | ||
| INT8("int8"), | ||
|
|
||
| /** | ||
| * Represents a uint8 data type. | ||
| */ | ||
| UINT8("uint8"), | ||
|
|
||
| /** | ||
| * Represents a float16 data type. | ||
| */ | ||
| FLOAT16("float16"), | ||
|
|
||
| /** | ||
| * Represents a float32 data type. | ||
| */ | ||
| FLOAT32("float32"); | ||
|
|
||
| private final String overWireValue; | ||
|
|
||
| CosmosVectorDataType(String overWireValue) { | ||
| this.overWireValue = overWireValue; | ||
| } | ||
|
|
||
| @JsonValue | ||
| @Override | ||
| public String toString() { | ||
| return this.overWireValue; | ||
| } | ||
|
|
||
| /** | ||
| * Method to retrieve the enum constant by its overWireValue. | ||
| * @param value the overWire value of the enum constant | ||
| * @return the matching CosmosVectorDataType | ||
| * @throws IllegalArgumentException if no matching enum constant is found | ||
| */ | ||
| public static CosmosVectorDataType fromString(String value) { | ||
| return Arrays.stream(CosmosVectorDataType.values()) | ||
| .filter(vectorDataType -> vectorDataType.toString().equalsIgnoreCase(value)) | ||
| .findFirst() | ||
| .orElseThrow(() -> new IllegalArgumentException("Invalid vector data type for the vector embedding policy.")); | ||
| } | ||
| } |
53 changes: 53 additions & 0 deletions
53
...smos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosVectorDistanceFunction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.cosmos.models; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonValue; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| /** | ||
| * Distance Function for the embeddings in the Cosmos DB database service. | ||
| */ | ||
| public enum CosmosVectorDistanceFunction { | ||
aayush3011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * Represents the euclidean distance function. | ||
| */ | ||
| EUCLIDEAN("euclidean"), | ||
|
|
||
| /** | ||
| * Represents the cosine distance function. | ||
| */ | ||
| COSINE("cosine"), | ||
|
|
||
| /** | ||
| * Represents the dot product distance function. | ||
| */ | ||
| DOT_PRODUCT("dotproduct"); | ||
|
|
||
| private final String overWireValue; | ||
|
|
||
| CosmosVectorDistanceFunction(String overWireValue) { | ||
| this.overWireValue = overWireValue; | ||
| } | ||
|
|
||
| @JsonValue | ||
| @Override | ||
| public String toString() { | ||
| return this.overWireValue; | ||
| } | ||
|
|
||
| /** | ||
| * Method to retrieve the enum constant by its overWireValue. | ||
| * @param value the overWire value of the enum constant | ||
| * @return the matching CosmosVectorDataType | ||
| * @throws IllegalArgumentException if no matching enum constant is found | ||
| */ | ||
| public static CosmosVectorDistanceFunction fromString(String value) { | ||
| return Arrays.stream(CosmosVectorDistanceFunction.values()) | ||
| .filter(vectorDistanceFunction -> vectorDistanceFunction.toString().equalsIgnoreCase(value)) | ||
| .findFirst() | ||
| .orElseThrow(() -> new IllegalArgumentException("Invalid distance function for the vector embedding policy.")); | ||
| } | ||
| } | ||
128 changes: 128 additions & 0 deletions
128
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosVectorEmbedding.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.cosmos.models; | ||
|
|
||
| import com.azure.cosmos.implementation.Constants; | ||
| import com.azure.cosmos.implementation.JsonSerializable; | ||
| import com.azure.cosmos.implementation.apachecommons.lang.StringUtils; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import static com.azure.cosmos.implementation.guava25.base.Preconditions.checkNotNull; | ||
|
|
||
| /** | ||
| * Embedding settings within {@link CosmosVectorEmbeddingPolicy} | ||
| */ | ||
| public final class CosmosVectorEmbedding { | ||
| @JsonProperty(Constants.Properties.PATH) | ||
| private String path; | ||
| @JsonProperty(Constants.Properties.VECTOR_DATA_TYPE) | ||
| private String dataType; | ||
| @JsonProperty(Constants.Properties.VECTOR_DIMENSIONS) | ||
| private Long dimensions; | ||
| @JsonProperty(Constants.Properties.DISTANCE_FUNCTION) | ||
| private String distanceFunction; | ||
| private JsonSerializable jsonSerializable; | ||
|
|
||
| /** | ||
| * Constructor | ||
| */ | ||
| public CosmosVectorEmbedding() { | ||
| this.jsonSerializable = new JsonSerializable(); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the path for the cosmosVectorEmbedding. | ||
| * | ||
| * @return path | ||
| */ | ||
| public String getPath() { | ||
| return path; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the path for the cosmosVectorEmbedding. | ||
| * | ||
| * @param path the path for the cosmosVectorEmbedding | ||
| * @return CosmosVectorEmbedding | ||
| */ | ||
| public CosmosVectorEmbedding setPath(String path) { | ||
| if (StringUtils.isEmpty(path)) { | ||
| throw new NullPointerException("embedding path is empty"); | ||
aayush3011 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| if (path.charAt(0) != '/' || path.lastIndexOf('/') != 0) { | ||
| throw new IllegalArgumentException(""); | ||
| } | ||
|
|
||
| this.path = path; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the data type for the cosmosVectorEmbedding. | ||
| * | ||
| * @return dataType | ||
| */ | ||
| public CosmosVectorDataType getDataType() { | ||
| return CosmosVectorDataType.fromString(dataType); | ||
| } | ||
|
|
||
| /** | ||
| * Sets the data type for the cosmosVectorEmbedding. | ||
| * | ||
| * @param dataType the data type for the cosmosVectorEmbedding | ||
| * @return CosmosVectorEmbedding | ||
| */ | ||
| public CosmosVectorEmbedding setDataType(CosmosVectorDataType dataType) { | ||
| checkNotNull(dataType, "cosmosVectorDataType cannot be null"); | ||
| this.dataType = dataType.toString(); | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the dimensions for the cosmosVectorEmbedding. | ||
| * | ||
| * @return dimensions | ||
| */ | ||
| public Long getDimensions() { | ||
| return dimensions; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the dimensions for the cosmosVectorEmbedding. | ||
| * | ||
| * @param dimensions the dimensions for the cosmosVectorEmbedding | ||
| * @return CosmosVectorEmbedding | ||
| */ | ||
| public CosmosVectorEmbedding setDimensions(Long dimensions) { | ||
| checkNotNull(dimensions, "dimensions cannot be null"); | ||
| if (dimensions < 1) { | ||
| throw new IllegalArgumentException("Dimensions for the embedding has to be a long value greater than 0 " + | ||
| "for the vector embedding policy"); | ||
| } | ||
|
|
||
| this.dimensions = dimensions; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the distanceFunction for the cosmosVectorEmbedding. | ||
| * | ||
| * @return distanceFunction | ||
| */ | ||
| public CosmosVectorDistanceFunction getDistanceFunction() { | ||
| return CosmosVectorDistanceFunction.fromString(distanceFunction); | ||
| } | ||
|
|
||
| /** | ||
| * Sets the distanceFunction for the cosmosVectorEmbedding. | ||
| * | ||
| * @param distanceFunction the distanceFunction for the cosmosVectorEmbedding | ||
| * @return CosmosVectorEmbedding | ||
| */ | ||
| public CosmosVectorEmbedding setDistanceFunction(CosmosVectorDistanceFunction distanceFunction) { | ||
| checkNotNull(distanceFunction, "cosmosVectorDistanceFunction cannot be empty"); | ||
aayush3011 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this.distanceFunction = distanceFunction.toString(); | ||
| return this; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.