All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.snowflake.client.jdbc.cloud.storage.StorageObjectSummaryCollection Maven / Gradle / Ivy

/*
 * Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
 */
package net.snowflake.client.jdbc.cloud.storage;

import com.amazonaws.services.s3.model.S3ObjectSummary;
import com.google.api.gax.paging.Page;
import com.google.cloud.storage.Blob;
import com.microsoft.azure.storage.blob.ListBlobItem;

import java.util.Iterator;
import java.util.List;


/**
 * Provides and iterator over storage object summaries
 * from all supported cloud storage providers
 *
 * @author lgiakoumakis
 */
public class StorageObjectSummaryCollection implements Iterable
{

  private enum storageType
  {
    S3,
    AZURE,
    GCS
  }

  ;
  private final storageType sType;
  private List s3ObjSummariesList = null;
  private Iterable azCLoudBlobIterable = null;
  private Page gcsIterablePage = null;

  // Constructs platform-agnostic collection of object summaries from S3 object summaries
  public StorageObjectSummaryCollection(List s3ObjectSummaries)
  {
    this.s3ObjSummariesList = s3ObjectSummaries;
    sType = storageType.S3;
  }

  // Constructs platform-agnostic collection of object summaries from an Azure CloudBlobDirectory object
  public StorageObjectSummaryCollection(Iterable azCLoudBlobIterable)
  {
    this.azCLoudBlobIterable = azCLoudBlobIterable;
    sType = storageType.AZURE;
  }

  public StorageObjectSummaryCollection(Page gcsIterablePage)
  {
    this.gcsIterablePage = gcsIterablePage;
    sType = storageType.GCS;
  }

  @Override
  public Iterator iterator()
  {
    switch (sType)
    {
      case S3:
        return new S3ObjectSummariesIterator(s3ObjSummariesList);
      case AZURE:
        return new AzureObjectSummariesIterator(azCLoudBlobIterable);
      case GCS:
        return new GcsObjectSummariesIterator(this.gcsIterablePage);
      default:
        throw new IllegalArgumentException("Unspecified storage provider");
    }
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy