private void checkPartitionDirs(Path basePath, Set<Path> allDirs, final List<String> partColNames)
      throws IOException, MetastoreException {
    // Here we just reuse the THREAD_COUNT configuration for
    // METASTORE_FS_HANDLER_THREADS_COUNT since this results in better performance
    // The number of missing partitions discovered are later added by metastore using a
    // threadpool of size METASTORE_FS_HANDLER_THREADS_COUNT. If we have different sized
    // pool here the smaller sized pool of the two becomes a bottleneck
    int poolSize = MetastoreConf.getIntVar(conf, MetastoreConf.ConfVars.FS_HANDLER_THREADS_COUNT);

    ExecutorService executor;
    if (poolSize <= 1) {
      LOG.debug("Using single-threaded version of MSCK-GetPaths");
      executor = MoreExecutors.newDirectExecutorService();
    } else {
      LOG.debug("Using multi-threaded version of MSCK-GetPaths with number of threads " + poolSize);
      ThreadFactory threadFactory =
          new ThreadFactoryBuilder().setDaemon(true).setNameFormat("MSCK-GetPaths-%d").build();
      executor = Executors.newFixedThreadPool(poolSize, threadFactory);
    }
    checkPartitionDirs(executor, basePath, allDirs, basePath.getFileSystem(conf), partColNames);

    executor.shutdown();
  }
Assume that depth is 2, i.e., partition columns are a and b
tblPath/a=1  => throw exception
tblPath/a=1/file => throw exception
tblPath/a=1/b=2/file => return a=1/b=2
tblPath/a=1/b=2/c=3 => return a=1/b=2
tblPath/a=1/b=2/c=3/file => return a=1/b=2

@param basePath
         Start directory
@param allDirs
         This set will contain the leaf paths at the end.
@param partColNames
         Partition column names
@throws IOException
          Thrown if we can't get lists from the fs.
@throws MetastoreException ex
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java