private void getAllRoleAncestors(Map<String, HiveRoleGrant> processedRolesMap, List<RolePrincipalGrant> roleGrants)
      throws MetaException, HiveAuthzPluginException, TException {
    for (RolePrincipalGrant parentRoleGrant : roleGrants) {
      String parentRoleName = parentRoleGrant.getRoleName();
      if (processedRolesMap.get(parentRoleName) == null) {
        // unprocessed role: get its parents, add it to processed, and call this
        // function recursively

        List<RolePrincipalGrant> nextParentRoles = getRoleGrants(parentRoleName, PrincipalType.ROLE);
        processedRolesMap.put(parentRoleName, new HiveRoleGrant(parentRoleGrant));
        getAllRoleAncestors(processedRolesMap, nextParentRoles);
      }
    }
  }
Add role names of parentRoles and its parents to processedRolesMap

@param processedRolesMap
@param roleGrants
@throws TException
@throws HiveAuthzPluginException
@throws MetaException
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/SQLStdHiveAccessController.java