You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2019/01/30 05:59:35 UTC
[jclouds-labs] branch 2.1.x updated: JCLOUDS-1371: JCLOUDS-1488:
list optimize prefix
This is an automated email from the ASF dual-hosted git repository.
gaul pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/jclouds-labs.git
The following commit(s) were added to refs/heads/2.1.x by this push:
new 30b2ee9 JCLOUDS-1371: JCLOUDS-1488: list optimize prefix
30b2ee9 is described below
commit 30b2ee9016a9f296a7e7ff5e219972f32db385dd
Author: Andrew Gaul <ga...@apache.org>
AuthorDate: Tue Jan 29 21:57:45 2019 -0800
JCLOUDS-1371: JCLOUDS-1488: list optimize prefix
Previously getBlobKeysInsideContainer returned all keys and filtered
in LocalBlobStore. Now getBlobKeysInsideContainer filters via prefix
which can dramatically decrease the number of keys returned,
especially for the filesystem provider. Further optimizations are
possible for delimiter.
---
.../main/java/org/jclouds/jdbc/strategy/JdbcStorageStrategy.java | 5 ++++-
.../java/org/jclouds/jdbc/strategy/BaseJdbcStorageStrategyTest.java | 6 +++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/jdbc/src/main/java/org/jclouds/jdbc/strategy/JdbcStorageStrategy.java b/jdbc/src/main/java/org/jclouds/jdbc/strategy/JdbcStorageStrategy.java
index 1dc33b8..5cad097 100644
--- a/jdbc/src/main/java/org/jclouds/jdbc/strategy/JdbcStorageStrategy.java
+++ b/jdbc/src/main/java/org/jclouds/jdbc/strategy/JdbcStorageStrategy.java
@@ -236,10 +236,13 @@ public class JdbcStorageStrategy implements LocalStorageStrategy {
* @return the blob keys inside the container
*/
@Override
- public Iterable<String> getBlobKeysInsideContainer(String container) throws IOException {
+ public Iterable<String> getBlobKeysInsideContainer(String container, String prefix) throws IOException {
List<BlobEntity> blobEntities = jdbcService.findBlobsByContainer(container);
ImmutableList.Builder<String> result = ImmutableList.builder();
for (BlobEntity blobEntity : blobEntities) {
+ if (prefix != null && !blobEntity.getKey().startsWith(prefix)) {
+ continue;
+ }
result.add(blobEntity.getKey());
}
return result.build();
diff --git a/jdbc/src/test/java/org/jclouds/jdbc/strategy/BaseJdbcStorageStrategyTest.java b/jdbc/src/test/java/org/jclouds/jdbc/strategy/BaseJdbcStorageStrategyTest.java
index 019f709..7e636cb 100644
--- a/jdbc/src/test/java/org/jclouds/jdbc/strategy/BaseJdbcStorageStrategyTest.java
+++ b/jdbc/src/test/java/org/jclouds/jdbc/strategy/BaseJdbcStorageStrategyTest.java
@@ -148,7 +148,7 @@ public abstract class BaseJdbcStorageStrategyTest {
.name(BLOB_NAME + "3")
.payload(randomByteSource().slice(0, 4 * 1024 * 1024))
.build());
- assertThat(storageStrategy.getBlobKeysInsideContainer(CONTAINER_NAME))
+ assertThat(storageStrategy.getBlobKeysInsideContainer(CONTAINER_NAME, null))
.containsExactly(BLOB_NAME + "1", BLOB_NAME + "2", BLOB_NAME + "3");
}
@@ -195,10 +195,10 @@ public abstract class BaseJdbcStorageStrategyTest {
new BlobBuilderImpl().name(BLOB_NAME + "2").payload(randomByteSource().slice(0, 4 * 1024 * 1024)).build());
storageStrategy.putBlob(CONTAINER_NAME,
new BlobBuilderImpl().name(BLOB_NAME + "3").payload(randomByteSource().slice(0, 4 * 1024 * 1024)).build());
- assertThat(storageStrategy.getBlobKeysInsideContainer(CONTAINER_NAME))
+ assertThat(storageStrategy.getBlobKeysInsideContainer(CONTAINER_NAME, null))
.containsExactly(BLOB_NAME + "1", BLOB_NAME + "2", BLOB_NAME + "3");
storageStrategy.clearContainer(CONTAINER_NAME);
- assertThat(storageStrategy.getBlobKeysInsideContainer(CONTAINER_NAME)).isEmpty();
+ assertThat(storageStrategy.getBlobKeysInsideContainer(CONTAINER_NAME, null)).isEmpty();
storageStrategy.deleteContainer(CONTAINER_NAME);
assertThat(storageStrategy.containerExists(CONTAINER_NAME)).isFalse();
}