Skip to content

Add Queryable Encryption V2 support #1445

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
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ext {
zstdVersion = '1.5.5-3'
awsSdkV2Version = '2.18.9'
awsSdkV1Version = '1.12.337'
mongoCryptVersion = '1.10.0-SNAPSHOT'
mongoCryptVersion = '1.11.0-SNAPSHOT'
projectReactorVersion = '2022.0.0'
junitBomVersion = '5.8.2'
logbackVersion = '1.3.14'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public EncryptOptions(final String algorithm) {
* <li>AEAD_AES_256_CBC_HMAC_SHA_512-Random</li>
* <li>Indexed</li>
* <li>Unindexed</li>
* <li>RangePreview</li>
* <li>Range</li>
* Note: The Range algorithm is experimental only. It is subject to breaking changes.
* </ul>
*
* @return the encryption algorithm
Expand Down Expand Up @@ -115,7 +116,7 @@ public EncryptOptions keyAltName(final String keyAltName) {
/**
* The contention factor.
*
* <p>It is an error to set contentionFactor when algorithm is not "Indexed" or "RangePreview".
* <p>It is an error to set contentionFactor when algorithm is not "Indexed" or "Range".
* <p>Note: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.</p>
* @param contentionFactor the contention factor, which must be {@code >= 0} or null.
* @return this
Expand Down Expand Up @@ -143,8 +144,8 @@ public Long getContentionFactor() {
/**
* The QueryType.
*
* <p>Currently, we support only "equality" or "RangePreview" queryType.</p>
* <p>It is an error to set queryType when the algorithm is not "Indexed" or "RangePreview".</p>
* <p>Currently, we support only "equality" or "range" queryType.</p>
* <p>It is an error to set queryType when the algorithm is not "Indexed" or "Range".</p>
* <p>Note: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.</p>
* @param queryType the query type
* @return this
Expand All @@ -159,7 +160,8 @@ public EncryptOptions queryType(@Nullable final String queryType) {
/**
* Gets the QueryType.
*
* <p>Currently, we support only "equality" or "RangePreview" queryType.</p>
* <p>Currently, we support only "equality" or "range" queryType.</p>
* <p>Note: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
* @see #queryType(String)
* @return the queryType or null
* @since 4.7
Expand All @@ -173,12 +175,12 @@ public String getQueryType() {
/**
* The RangeOptions
*
* <p>It is an error to set RangeOptions when the algorithm is not "RangePreview".
* <p>It is an error to set RangeOptions when the algorithm is not "Range".
* <p>Note: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
* @param rangeOptions the range options
* @return this
* @since 4.9
* @mongodb.server.release 6.2
* @mongodb.server.release 8.0
* @mongodb.driver.manual /core/queryable-encryption/ queryable encryption
*/
@Beta(Beta.Reason.SERVER)
Expand All @@ -191,7 +193,7 @@ public EncryptOptions rangeOptions(@Nullable final RangeOptions rangeOptions) {
* Gets the RangeOptions
* @return the range options or null if not set
* @since 4.9
* @mongodb.server.release 6.2
* @mongodb.server.release 8.0
* @mongodb.driver.manual /core/queryable-encryption/ queryable encryption
*/
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import org.bson.BsonValue;

/**
* Range options specifies index options for a Queryable Encryption field supporting "rangePreview" queries.
* Range options specifies index options for a Queryable Encryption field supporting "range" queries.
*
* <p>{@code min}, {@code max}, {@code sparsity}, and {@code precision} must match the values set in the {@code encryptedFields}
* of the destination collection.
*
* <p>For {@code double} and {@code decimal128}, {@code min}/{@code max}/{@code precision} must all be set, or all be unset.
*
* <p>Note: The Range algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
* <p>Note: The "Range" algorithm is experimental only. It is not intended for public use. It is subject to breaking changes.
* @since 4.9
* @mongodb.server.release 6.2
* @mongodb.driver.manual /core/queryable-encryption/ queryable encryption
Expand All @@ -38,6 +38,7 @@ public class RangeOptions {

private BsonValue min;
private BsonValue max;
private Integer trimFactor;
private Long sparsity;
private Integer precision;

Expand Down Expand Up @@ -75,6 +76,24 @@ public RangeOptions max(@Nullable final BsonValue max) {
return this;
}

/**
* @return the trim factor value if set
*/
public Integer getTrimFactor() {
return trimFactor;
}

/**
* Set the number of top-level edges stored per record by setting a trim factor, reducing write conflicts during simultaneous inserts
* and optimizing queries by excluding seldom-used high-level edges.
* @param trimFactor the trim factor
* @return this
*/
public RangeOptions setTrimFactor(final Integer trimFactor) {
this.trimFactor = trimFactor;
return this;
}

/**
* @return the maximum value if set
*/
Expand Down Expand Up @@ -124,6 +143,7 @@ public String toString() {
return "RangeOptions{"
+ "min=" + min
+ ", max=" + max
+ ", trimFactor=" + trimFactor
+ ", sparsity=" + sparsity
+ ", precision=" + precision
+ '}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public static MongoExplicitEncryptOptions asMongoExplicitEncryptOptions(final En
if (sparsity != null) {
rangeOptionsBsonDocument.put("sparsity", new BsonInt64(sparsity));
}
Integer trimFactor = rangeOptions.getTrimFactor();
if (trimFactor != null) {
rangeOptionsBsonDocument.put("trimFactor", new BsonInt32(trimFactor));
}
Integer precision = rangeOptions.getPrecision();
if (precision != null) {
rangeOptionsBsonDocument.put("precision", new BsonInt32(precision));
Expand Down
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The encryptedFields-Range-* files have been deleted as per the specification change outlined in "DRIVERS-2604 deduplicate encrypted fields files #14".

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading