Skip to content

Commit 400ea16

Browse files
committed
Improving performance of bulk_get. When retrieving an object with a name ending in '.json', perform the slightly less expensive GetObjectsDetails (plural) call as opposed to the GetObjectsWithFullDetails call. When retrieving all other objects, perform the inexpensive GetObjectDetails (singular) call. Retrieving objects whose name ends in '.json' will incur a performance hit, but this bypasses the json payload format issue that otherwise prevents response payload unmarshaling.
1 parent 955872b commit 400ea16

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ buildscript {
3232
}
3333

3434
allprojects {
35-
version = '5.1.3'
35+
version = '5.1.4'
3636
group = 'com.spectralogic'
3737

3838
repositories {

ds3_java_cli/src/main/kotlin/com/spectralogic/ds3cli/PipeUtils.kt

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ package com.spectralogic.ds3cli
1818
import com.google.common.collect.ImmutableList
1919
import com.spectralogic.ds3cli.exceptions.CommandException
2020
import com.spectralogic.ds3client.Ds3Client
21-
import com.spectralogic.ds3client.commands.spectrads3.GetObjectsWithFullDetailsSpectraS3Request
21+
import com.spectralogic.ds3client.commands.spectrads3.GetObjectDetailsSpectraS3Request
22+
import com.spectralogic.ds3client.commands.spectrads3.GetObjectsDetailsSpectraS3Request
2223
import com.spectralogic.ds3client.models.Contents
2324
import com.spectralogic.ds3client.networking.FailedRequestException
2425
import kotlinx.coroutines.*
@@ -38,17 +39,28 @@ object PipeUtils {
3839
pipedFileNames.map { objName ->
3940
async(Dispatchers.IO) {
4041
try {
41-
val result = client.getObjectsWithFullDetailsSpectraS3(
42-
GetObjectsWithFullDetailsSpectraS3Request().withBucketId(bucketName).withName(objName));
43-
44-
if (result.detailedS3ObjectListResult.detailedS3Objects == null || result.detailedS3ObjectListResult.detailedS3Objects.size == 0) {
45-
GetObjectResponse.NotFound(objName)
46-
} else if (result.detailedS3ObjectListResult.detailedS3Objects.size > 1) {
47-
GetObjectResponse.Error(IOException("There are multiple versions of object with name: $objName"))
42+
if (objName.endsWith(".json", ignoreCase = true)) {
43+
// If this is an object that ends in .json, then perform the more expensive call that
44+
// bypasses the json formatting feature of response payloads in BP
45+
val result = client.getObjectsDetailsSpectraS3(
46+
GetObjectsDetailsSpectraS3Request().withBucketId(bucketName).withName(objName).withLatest(true))
47+
48+
if (result.s3ObjectListResult.s3Objects == null || result.s3ObjectListResult.s3Objects.size == 0) {
49+
GetObjectResponse.NotFound(objName)
50+
} else if (result.s3ObjectListResult.s3Objects.size > 1) {
51+
GetObjectResponse.Error(IOException("There are multiple versions of object with name: $objName"))
52+
} else {
53+
GetObjectResponse.Success(Contents().apply {
54+
key = result.s3ObjectListResult.s3Objects[0].name
55+
lastModified = result.s3ObjectListResult.s3Objects[0].creationDate
56+
})
57+
}
4858
} else {
59+
val result = client.getObjectDetailsSpectraS3(GetObjectDetailsSpectraS3Request(objName, bucketName)).s3ObjectResult
60+
4961
GetObjectResponse.Success(Contents().apply {
50-
key = result.detailedS3ObjectListResult.detailedS3Objects[0].name
51-
lastModified = result.detailedS3ObjectListResult.detailedS3Objects[0].creationDate
62+
key = result.name
63+
lastModified = result.creationDate
5264
})
5365
}
5466
} catch (f: FailedRequestException) {

0 commit comments

Comments
 (0)