protected Path getLatestSnapshot(Path path) throws IOException {
    FileStatus statuses[] = this.fs.listStatus(path, new PathFilter() {

      @Override
      public boolean accept(Path p) {
        try {
          if (!HiveSnapshotRegistrationPolicy.this.fs.isDirectory(p)) {
            return false;
          }
        } catch (IOException e) {
          throw Throwables.propagate(e);
        }

        return !HiveSnapshotRegistrationPolicy.this.snapshotPathPattern.isPresent()
            || HiveSnapshotRegistrationPolicy.this.snapshotPathPattern.get().matcher(p.toString()).matches();
      }
    });

    if (statuses.length == 0) {
      return null;
    }

    Arrays.sort(statuses, new Comparator<FileStatus>() {

      @Override
      public int compare(FileStatus o1, FileStatus o2) {
        return o2.getPath().getName().compareTo(o1.getPath().getName());
      }

    });

    return statuses[0].getPath();
  }
protected Path getLatestSnapshot ( Path path ) throws IOException { FileStatus statuses [ ] = this . fs . listStatus ( path , new PathFilter ( ) { @ Override public boolean accept ( Path p ) { try { if ( ! HiveSnapshotRegistrationPolicy . this . fs . isDirectory ( p ) ) { return false ; } } catch ( IOException e ) { throw Throwables . propagate ( e ) ; } return ! HiveSnapshotRegistrationPolicy . this . snapshotPathPattern . isPresent ( ) || HiveSnapshotRegistrationPolicy . this . snapshotPathPattern . get ( ) . matcher ( p . toString ( ) ) . matches ( ) ; } } ) ; if ( statuses . length == 0 ) { return null ; } Arrays . sort ( statuses , new Comparator < FileStatus > ( ) { @ Override public int compare ( FileStatus o1 , FileStatus o2 ) { return o2 . getPath ( ) . getName ( ) . compareTo ( o1 . getPath ( ) . getName ( ) ) ; } } ) ; return statuses [ 0 ] . getPath ( ) ; }
Get the latest snapshot in the given {@link Path}.

<p>
The lastest snapshot is a sub-directory of the input {@link Path} that has the largest folder
name alphabetically. If property {@link #SNAPSHOT_PATH_PATTERN} is set, only those sub-directories
whose full path matches the given pattern are considered.
</p>