mirror of https://github.com/apache/jclouds.git
JCLOUDS-1390: Use FULL projection for list blobs
This avoids a per-object call during detailed listings.
This commit is contained in:
parent
22cfbb86f2
commit
f6d95d0fda
|
@ -45,7 +45,6 @@ import org.jclouds.blobstore.options.CreateContainerOptions;
|
|||
import org.jclouds.blobstore.options.GetOptions;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.options.PutOptions;
|
||||
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
||||
import org.jclouds.blobstore.util.BlobUtils;
|
||||
import org.jclouds.collect.Memoized;
|
||||
import org.jclouds.domain.Location;
|
||||
|
@ -79,7 +78,6 @@ import com.google.common.base.Supplier;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.hash.HashCode;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
public final class GoogleCloudStorageBlobStore extends BaseBlobStore {
|
||||
|
||||
|
@ -87,7 +85,6 @@ public final class GoogleCloudStorageBlobStore extends BaseBlobStore {
|
|||
private final BucketToStorageMetadata bucketToStorageMetadata;
|
||||
private final ObjectToBlobMetadata objectToBlobMetadata;
|
||||
private final ObjectListToStorageMetadata objectListToStorageMetadata;
|
||||
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
||||
private final BlobMetadataToObjectTemplate blobMetadataToObjectTemplate;
|
||||
private final BlobStoreListContainerOptionsToListObjectOptions listContainerOptionsToListObjectOptions;
|
||||
private final Supplier<String> projectId;
|
||||
|
@ -97,7 +94,6 @@ public final class GoogleCloudStorageBlobStore extends BaseBlobStore {
|
|||
@Memoized Supplier<Set<? extends Location>> locations, PayloadSlicer slicer, GoogleCloudStorageApi api,
|
||||
BucketToStorageMetadata bucketToStorageMetadata, ObjectToBlobMetadata objectToBlobMetadata,
|
||||
ObjectListToStorageMetadata objectListToStorageMetadata,
|
||||
Provider<FetchBlobMetadata> fetchBlobMetadataProvider,
|
||||
BlobMetadataToObjectTemplate blobMetadataToObjectTemplate,
|
||||
BlobStoreListContainerOptionsToListObjectOptions listContainerOptionsToListObjectOptions,
|
||||
@CurrentProject Supplier<String> projectId,
|
||||
|
@ -107,7 +103,6 @@ public final class GoogleCloudStorageBlobStore extends BaseBlobStore {
|
|||
this.bucketToStorageMetadata = bucketToStorageMetadata;
|
||||
this.objectToBlobMetadata = objectToBlobMetadata;
|
||||
this.objectListToStorageMetadata = objectListToStorageMetadata;
|
||||
this.fetchBlobMetadataProvider = checkNotNull(fetchBlobMetadataProvider, "fetchBlobMetadataProvider");
|
||||
this.blobMetadataToObjectTemplate = blobMetadataToObjectTemplate;
|
||||
this.listContainerOptionsToListObjectOptions = listContainerOptionsToListObjectOptions;
|
||||
this.projectId = projectId;
|
||||
|
@ -192,8 +187,7 @@ public final class GoogleCloudStorageBlobStore extends BaseBlobStore {
|
|||
public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
|
||||
ListObjectOptions listOptions = listContainerOptionsToListObjectOptions.apply(options);
|
||||
ListPageWithPrefixes<GoogleCloudStorageObject> gcsList = api.getObjectApi().listObjects(container, listOptions);
|
||||
PageSet<? extends StorageMetadata> list = objectListToStorageMetadata.apply(gcsList);
|
||||
return options.isDetailed() ? fetchBlobMetadataProvider.get().setContainerName(container).apply(list) : list;
|
||||
return objectListToStorageMetadata.apply(gcsList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.jclouds.googlecloudstorage.blobstore.functions;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection;
|
||||
import org.jclouds.googlecloudstorage.options.ListObjectOptions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -53,6 +54,9 @@ public class BlobStoreListContainerOptionsToListObjectOptions implements
|
|||
if (from.getMaxResults() != null) {
|
||||
httpOptions = httpOptions.maxResults(from.getMaxResults());
|
||||
}
|
||||
if (from.isDetailed()) {
|
||||
httpOptions = httpOptions.projection(Projection.FULL);
|
||||
}
|
||||
return httpOptions;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue