Skip to content

Commit 7184f14

Browse files
committed
Code changes to upgrade direct version to 3.34.2
1 parent d64b12c commit 7184f14

File tree

5 files changed

+54
-64
lines changed

5 files changed

+54
-64
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ClientOfficialVersion>3.39.1</ClientOfficialVersion>
44
<ClientPreviewVersion>3.40.0</ClientPreviewVersion>
55
<ClientPreviewSuffixVersion>preview.1</ClientPreviewSuffixVersion>
6-
<DirectVersion>3.34.0</DirectVersion>
6+
<DirectVersion>3.34.2</DirectVersion>
77
<EncryptionOfficialVersion>2.0.4</EncryptionOfficialVersion>
88
<EncryptionPreviewVersion>2.1.0</EncryptionPreviewVersion>
99
<EncryptionPreviewSuffixVersion>preview4</EncryptionPreviewSuffixVersion>

Microsoft.Azure.Cosmos/src/Resource/Settings/IndexingPolicy.cs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ public IndexingPolicy()
111111
[JsonProperty(PropertyName = Constants.Properties.CompositeIndexes)]
112112
public Collection<Collection<CompositePath>> CompositeIndexes { get; internal set; } = new Collection<Collection<CompositePath>>();
113113

114+
/// <summary>
115+
/// Collection of spatial index definitions to be used
116+
/// </summary>
117+
[JsonProperty(PropertyName = Constants.Properties.SpatialIndexes)]
118+
public Collection<SpatialPath> SpatialIndexes { get; internal set; } = new Collection<SpatialPath>();
119+
114120
/// <summary>
115121
/// Gets the vector indexes for additional indexes
116122
/// </summary>
@@ -132,30 +138,14 @@ public IndexingPolicy()
132138
/// ]
133139
/// ]]>
134140
/// </example>
135-
[JsonIgnore]
141+
[JsonProperty(PropertyName = "vectorIndexes", NullValueHandling = NullValueHandling.Ignore)]
136142
#if PREVIEW
143+
137144
public
138145
#else
139146
internal
140147
#endif
141-
// Remove this place holder for VectorIndexes once the new Cosmos.Direct version 3.34.2 is released and rename the VectorIndexesInternal to VectorIndexes.
142-
Collection<VectorIndexPath> VectorIndexes
143-
{
144-
get => this.VectorIndexesInternal ??= new Collection<VectorIndexPath>();
145-
set => this.VectorIndexesInternal = value;
146-
}
147-
148-
/// <summary>
149-
/// Collection of spatial index definitions to be used
150-
/// </summary>
151-
[JsonProperty(PropertyName = Constants.Properties.SpatialIndexes)]
152-
public Collection<SpatialPath> SpatialIndexes { get; internal set; } = new Collection<SpatialPath>();
153-
154-
/// <summary>
155-
/// Gets or Sets an internal placeholder collection to hold the vector indexes.
156-
/// </summary>
157-
[JsonProperty(PropertyName = "vectorIndexes", NullValueHandling = NullValueHandling.Ignore)]
158-
internal Collection<VectorIndexPath> VectorIndexesInternal { get; set; }
148+
Collection<VectorIndexPath> VectorIndexes { get; set; } = new Collection<VectorIndexPath>();
159149

160150
/// <summary>
161151
/// This contains additional values for scenarios where the SDK is not aware of new fields.

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -618,21 +618,25 @@
618618
"Microsoft.Azure.Cosmos.IndexingPolicy;System.Object;IsAbstract:False;IsSealed:True;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": {
619619
"Subclasses": {},
620620
"Members": {
621-
"System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] get_VectorIndexes()": {
621+
"System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] get_VectorIndexes()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
622622
"Type": "Method",
623-
"Attributes": [],
623+
"Attributes": [
624+
"CompilerGeneratedAttribute"
625+
],
624626
"MethodInfo": "System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] get_VectorIndexes();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
625627
},
626-
"System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] VectorIndexes[Newtonsoft.Json.JsonIgnoreAttribute()]": {
628+
"System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] VectorIndexes[Newtonsoft.Json.JsonPropertyAttribute(NullValueHandling = 1, PropertyName = \"vectorIndexes\")]": {
627629
"Type": "Property",
628630
"Attributes": [
629-
"JsonIgnoreAttribute"
631+
"JsonPropertyAttribute"
630632
],
631633
"MethodInfo": "System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] VectorIndexes;CanRead:True;CanWrite:True;System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] get_VectorIndexes();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_VectorIndexes(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
632634
},
633-
"Void set_VectorIndexes(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath])": {
635+
"Void set_VectorIndexes(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath])[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
634636
"Type": "Method",
635-
"Attributes": [],
637+
"Attributes": [
638+
"CompilerGeneratedAttribute"
639+
],
636640
"MethodInfo": "Void set_VectorIndexes(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
637641
}
638642
},

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosContainerSettingsTests.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -183,31 +183,31 @@ public void SettingPKShouldNotResetVersion()
183183
[TestMethod]
184184
public void ValidateVectorEmbeddingsAndIndexes()
185185
{
186-
Embedding embedding1 = new ()
186+
Cosmos.Embedding embedding1 = new ()
187187
{
188188
Path = "/vector1",
189-
DataType = VectorDataType.Int8,
190-
DistanceFunction = DistanceFunction.DotProduct,
189+
DataType = Cosmos.VectorDataType.Int8,
190+
DistanceFunction = Cosmos.DistanceFunction.DotProduct,
191191
Dimensions = 1200,
192192
};
193193

194-
Embedding embedding2 = new ()
194+
Cosmos.Embedding embedding2 = new ()
195195
{
196196
Path = "/vector2",
197-
DataType = VectorDataType.Uint8,
198-
DistanceFunction = DistanceFunction.Cosine,
197+
DataType = Cosmos.VectorDataType.Uint8,
198+
DistanceFunction = Cosmos.DistanceFunction.Cosine,
199199
Dimensions = 3,
200200
};
201201

202-
Embedding embedding3 = new ()
202+
Cosmos.Embedding embedding3 = new ()
203203
{
204204
Path = "/vector3",
205-
DataType = VectorDataType.Float32,
206-
DistanceFunction = DistanceFunction.Euclidean,
205+
DataType = Cosmos.VectorDataType.Float32,
206+
DistanceFunction = Cosmos.DistanceFunction.Euclidean,
207207
Dimensions = 400,
208208
};
209209

210-
Collection<Embedding> embeddings = new Collection<Embedding>()
210+
Collection<Cosmos.Embedding> embeddings = new Collection<Cosmos.Embedding>()
211211
{
212212
embedding1,
213213
embedding2,
@@ -216,25 +216,25 @@ public void ValidateVectorEmbeddingsAndIndexes()
216216

217217
ContainerProperties containerSettings = new ContainerProperties(id: "TestContainer", partitionKeyPath: "/partitionKey")
218218
{
219-
VectorEmbeddingPolicy = new(embeddings),
219+
VectorEmbeddingPolicy = new (embeddings),
220220
IndexingPolicy = new Cosmos.IndexingPolicy()
221221
{
222222
VectorIndexes = new()
223223
{
224-
new VectorIndexPath()
224+
new Cosmos.VectorIndexPath()
225225
{
226226
Path = "/vector1",
227-
Type = VectorIndexType.Flat,
227+
Type = Cosmos.VectorIndexType.Flat,
228228
},
229-
new VectorIndexPath()
229+
new Cosmos.VectorIndexPath()
230230
{
231231
Path = "/vector2",
232-
Type = VectorIndexType.Flat,
232+
Type = Cosmos.VectorIndexType.Flat,
233233
},
234-
new VectorIndexPath()
234+
new Cosmos.VectorIndexPath()
235235
{
236236
Path = "/vector3",
237-
Type = VectorIndexType.Flat,
237+
Type = Cosmos.VectorIndexType.Flat,
238238
}
239239
},
240240

@@ -245,18 +245,18 @@ public void ValidateVectorEmbeddingsAndIndexes()
245245
Assert.IsNotNull(containerSettings.VectorEmbeddingPolicy);
246246
Assert.IsNotNull(containerSettings.IndexingPolicy.VectorIndexes);
247247

248-
VectorEmbeddingPolicy embeddingPolicy = containerSettings.VectorEmbeddingPolicy;
248+
Cosmos.VectorEmbeddingPolicy embeddingPolicy = containerSettings.VectorEmbeddingPolicy;
249249
Assert.IsNotNull(embeddingPolicy.Embeddings);
250250
Assert.AreEqual(embeddings.Count, embeddingPolicy.Embeddings.Count());
251251
CollectionAssert.AreEquivalent(embeddings, embeddingPolicy.Embeddings.ToList());
252252

253-
Collection<VectorIndexPath> vectorIndexes = containerSettings.IndexingPolicy.VectorIndexes;
253+
Collection<Cosmos.VectorIndexPath> vectorIndexes = containerSettings.IndexingPolicy.VectorIndexes;
254254
Assert.AreEqual("/vector1", vectorIndexes[0].Path);
255-
Assert.AreEqual(VectorIndexType.Flat, vectorIndexes[0].Type);
255+
Assert.AreEqual(Cosmos.VectorIndexType.Flat, vectorIndexes[0].Type);
256256
Assert.AreEqual("/vector2", vectorIndexes[1].Path);
257-
Assert.AreEqual(VectorIndexType.Flat, vectorIndexes[1].Type);
257+
Assert.AreEqual(Cosmos.VectorIndexType.Flat, vectorIndexes[1].Type);
258258
Assert.AreEqual("/vector3", vectorIndexes[2].Path);
259-
Assert.AreEqual(VectorIndexType.Flat, vectorIndexes[2].Type);
259+
Assert.AreEqual(Cosmos.VectorIndexType.Flat, vectorIndexes[2].Type);
260260
}
261261

262262
private static string SerializeDocumentCollection(DocumentCollection collection)

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/SettingsContractTests.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,9 @@ public void ContainerPropertiesDeserializeWithAdditionalDataTest()
400400
Assert.IsNotNull(containerProperties.VectorEmbeddingPolicy);
401401
Assert.AreEqual(3, containerProperties.VectorEmbeddingPolicy.Embeddings.Count);
402402
Assert.AreEqual("/vector1", containerProperties.VectorEmbeddingPolicy.Embeddings[0].Path);
403-
Assert.AreEqual(VectorDataType.Float32, containerProperties.VectorEmbeddingPolicy.Embeddings[0].DataType);
403+
Assert.AreEqual(Cosmos.VectorDataType.Float32, containerProperties.VectorEmbeddingPolicy.Embeddings[0].DataType);
404404
Assert.AreEqual((ulong)1200, containerProperties.VectorEmbeddingPolicy.Embeddings[0].Dimensions);
405-
Assert.AreEqual(DistanceFunction.Cosine, containerProperties.VectorEmbeddingPolicy.Embeddings[0].DistanceFunction);
405+
Assert.AreEqual(Cosmos.DistanceFunction.Cosine, containerProperties.VectorEmbeddingPolicy.Embeddings[0].DistanceFunction);
406406

407407
Assert.AreEqual(2, containerProperties.ComputedProperties.Count);
408408
Assert.AreEqual("lowerName", containerProperties.ComputedProperties[0].Name);
@@ -805,11 +805,7 @@ public void ContainerSettingsDefaults()
805805
[TestMethod]
806806
public async Task ContainerSettingsIndexTest()
807807
{
808-
#if PREVIEW
809808
string containerJsonString = "{\"indexingPolicy\":{\"automatic\":true,\"indexingMode\":\"Consistent\",\"includedPaths\":[{\"path\":\"/*\",\"indexes\":[{\"dataType\":\"Number\",\"precision\":-1,\"kind\":\"Range\"},{\"dataType\":\"String\",\"precision\":-1,\"kind\":\"Range\"}]}],\"excludedPaths\":[{\"path\":\"/\\\"_etag\\\"/?\"}],\"compositeIndexes\":[],\"spatialIndexes\":[],\"vectorIndexes\":[]},\"id\":\"MigrationTest\",\"partitionKey\":{\"paths\":[\"/id\"],\"kind\":\"Hash\"}}";
810-
#else
811-
string containerJsonString = "{\"indexingPolicy\":{\"automatic\":true,\"indexingMode\":\"Consistent\",\"includedPaths\":[{\"path\":\"/*\",\"indexes\":[{\"dataType\":\"Number\",\"precision\":-1,\"kind\":\"Range\"},{\"dataType\":\"String\",\"precision\":-1,\"kind\":\"Range\"}]}],\"excludedPaths\":[{\"path\":\"/\\\"_etag\\\"/?\"}],\"compositeIndexes\":[],\"spatialIndexes\":[]},\"id\":\"MigrationTest\",\"partitionKey\":{\"paths\":[\"/id\"],\"kind\":\"Hash\"}}";
812-
#endif
813809

814810
CosmosJsonDotNetSerializer serializerCore = new CosmosJsonDotNetSerializer();
815811
ContainerProperties containerProperties = null;
@@ -1082,29 +1078,29 @@ public void VectorEmbeddingPolicySerialization()
10821078
string serialization = JsonConvert.SerializeObject(containerSettings);
10831079
Assert.IsFalse(serialization.Contains("vectorEmbeddingPolicy"), "Vector Embedding Policy should not be included by default");
10841080

1085-
Embedding embedding1 = new()
1081+
Cosmos.Embedding embedding1 = new()
10861082
{
10871083
Path = "/vector1",
1088-
DataType = VectorDataType.Int8,
1089-
DistanceFunction = DistanceFunction.DotProduct,
1084+
DataType = Cosmos.VectorDataType.Int8,
1085+
DistanceFunction = Cosmos.DistanceFunction.DotProduct,
10901086
Dimensions = 1200,
10911087
};
10921088

1093-
Embedding embedding2 = new()
1089+
Cosmos.Embedding embedding2 = new()
10941090
{
10951091
Path = "/vector2",
1096-
DataType = VectorDataType.Uint8,
1097-
DistanceFunction = DistanceFunction.Cosine,
1092+
DataType = Cosmos.VectorDataType.Uint8,
1093+
DistanceFunction = Cosmos.DistanceFunction.Cosine,
10981094
Dimensions = 3,
10991095
};
11001096

1101-
Collection<Embedding> embeddings = new ()
1097+
Collection<Cosmos.Embedding> embeddings = new ()
11021098
{
11031099
embedding1,
11041100
embedding2,
11051101
};
11061102

1107-
containerSettings.VectorEmbeddingPolicy = new VectorEmbeddingPolicy(embeddings);
1103+
containerSettings.VectorEmbeddingPolicy = new Cosmos.VectorEmbeddingPolicy(embeddings);
11081104

11091105
string serializationWithValues = JsonConvert.SerializeObject(containerSettings);
11101106
Assert.IsTrue(serializationWithValues.Contains("vectorEmbeddingPolicy"), "Vector Embedding Policy should be included.");
@@ -1113,8 +1109,8 @@ public void VectorEmbeddingPolicySerialization()
11131109
JObject parsed = JObject.Parse(serializationWithValues);
11141110
JToken vectorEmbeddings = parsed["vectorEmbeddingPolicy"]["vectorEmbeddings"];
11151111
Assert.AreEqual(JTokenType.Array, vectorEmbeddings.Type, "Vector Embedding Policy serialized vectorEmbeddings should be an array.");
1116-
Assert.IsTrue(embedding1.Equals(vectorEmbeddings.Value<JArray>()[0].ToObject<Embedding>()));
1117-
Assert.IsTrue(embedding2.Equals(vectorEmbeddings.Value<JArray>()[1].ToObject<Embedding>()));
1112+
Assert.IsTrue(embedding1.Equals(vectorEmbeddings.Value<JArray>()[0].ToObject<Cosmos.Embedding>()));
1113+
Assert.IsTrue(embedding2.Equals(vectorEmbeddings.Value<JArray>()[1].ToObject<Cosmos.Embedding>()));
11181114
}
11191115

11201116
private static T CosmosDeserialize<T>(string payload)

0 commit comments

Comments
 (0)