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:03 UTC

[jclouds-labs] branch master 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 master
in repository https://gitbox.apache.org/repos/asf/jclouds-labs.git


The following commit(s) were added to refs/heads/master by this push:
     new aad98e6  JCLOUDS-1371: JCLOUDS-1488: list optimize prefix
aad98e6 is described below

commit aad98e6f9660fd7a4dd30fa72a2c16a41e1d8584
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();
    }