Skip to content

Commit a650416

Browse files
authored
PERF-3287 YCSB should only generate QE data keys when collection is first created
1 parent f70bd0c commit a650416

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

ycsb-mongodb/mongodb/src/main/java/com/yahoo/ycsb/db/MongoDbClient.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,16 @@ private static AutoEncryptionSettings generateEncryptionSettings(String url, Boo
290290
BsonDocument.parse(generateSchema(base64DataKeyId, numFields))));
291291
}
292292
else if (encryptionType == Encryption.QUERYABLE) {
293-
autoEncryptionSettingsBuilder.encryptedFieldsMap(Collections.singletonMap(collNamespace,
294-
generateEncryptedFieldsDocument(keyCollection, clientEncryption, numFields)));
295-
}
296-
297-
AutoEncryptionSettings autoEncryptionSettings = autoEncryptionSettingsBuilder.build();
298-
299-
if (encryptionType == Encryption.QUERYABLE) {
300293
MongoClient client = MongoClients.create(clientSettings);
301294

302295
if (!isCollectionCreated(client, database, collName)) {
303296
CreateCollectionOptions options = new CreateCollectionOptions();
304-
options.encryptedFields(generateEncryptedFieldsDocument(keyCollection, clientEncryption, numFields));
297+
BsonDocument encryptedFieldsDocument = generateEncryptedFieldsDocument(keyCollection, clientEncryption, numFields);
298+
299+
autoEncryptionSettingsBuilder.encryptedFieldsMap(
300+
Collections.singletonMap(collNamespace, encryptedFieldsDocument));
301+
302+
options.encryptedFields(encryptedFieldsDocument);
305303

306304
// This creates the encrypted data collection (EDC) and the auxilliary
307305
// collections, as well as the index on the __safeContent__ field.
@@ -316,7 +314,7 @@ else if (encryptionType == Encryption.QUERYABLE) {
316314
client.getDatabase("admin").runCommand(shardCollCmd);
317315
}
318316
}
319-
return autoEncryptionSettings;
317+
return autoEncryptionSettingsBuilder.build();
320318
}
321319

322320
if (remote_schema) {
@@ -336,7 +334,7 @@ else if (encryptionType == Encryption.QUERYABLE) {
336334
}
337335
}
338336

339-
return autoEncryptionSettings;
337+
return autoEncryptionSettingsBuilder.build();
340338
}
341339

342340
private static ArrayList<Long> parseCommaSeparatedIntegers(String toParse, long defaultValue) {

0 commit comments

Comments
 (0)