private List<RuntimeStat> getMRuntimeStats(int maxEntries, int maxCreateTime) {
    try (QueryWrapper query = new QueryWrapper(pm.newQuery(MRuntimeStat.class))) {
      query.setOrdering("createTime descending");
      if (maxCreateTime > 0) {
        query.setFilter("createTime < " + maxCreateTime);
      }
      if (maxEntries < 0) {
        maxEntries = Integer.MAX_VALUE;
      }
      List<RuntimeStat> ret = new ArrayList<>();
      List<MRuntimeStat> res = (List<MRuntimeStat>) query.execute();
      int totalEntries = 0;
      for (MRuntimeStat mRuntimeStat : res) {
        pm.retrieve(mRuntimeStat);
        totalEntries += mRuntimeStat.getWeight();
        ret.add(MRuntimeStat.toThrift(mRuntimeStat));
        if (totalEntries >= maxEntries) {
          break;
        }
      }
      return ret;
    }
  }
This is a cleanup method which is used to rollback a active transaction
if the success flag is false and close the associated Query object. This method is used
internally and visible for testing purposes only
@param success Rollback the current active transaction if false
@param query Query object which needs to be closed
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java