public Set<Partition> getAllPartitionsWithSpecsInBatches(Table tbl, int batchSize, int decayingFactor,
      int maxRetries, GetPartitionsRequest request) throws HiveException, TException {
    if (!tbl.isPartitioned()) {
      return Sets.newHashSet(new Partition(tbl));
    }
    Set<Partition> result = new LinkedHashSet<>();
    RetryUtilities.ExponentiallyDecayingBatchWork batchTask = new RetryUtilities
        .ExponentiallyDecayingBatchWork<Void>(batchSize, decayingFactor, maxRetries) {
      @Override
      public Void execute(int size) throws HiveException, TException {
        result.clear();
        PartitionIterable partitionIterable = new PartitionIterable(Hive.get(), request, size);
        partitionIterable.forEach(result::add);
        return null;
      }
    };
    try {
      batchTask.run();
    } catch (Exception e) {
      throw new HiveException(e);
    }
    return result;
  }
Main method which fetches the partitions in batches
@param tbl table for which partitions are needed
@param batchSize Number of partitions to be fectehd in one batched call
@param decayingFactor the value by which batchSize decays in the next retry in case it faces an exception
@param maxRetries Number of retries allowed for this operation
@param partialPartitionSpec partialPartitionSpec for the table
@param isAuthRequired If auth information is required along with partitions
@param userName name of the calling user
@param groupNames groups the call
@return list of partition objects
ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java