@Test public void testDiagnosisService() throws IOException { BadQueryHistory history = BadQueryHistoryManager.getInstance(getTestConfig()) .getBadQueriesForProject("default"); List<BadQueryEntry> allEntries = new ArrayList<>(); allEntries.addAll(history.getEntries()); DiagnosisService diagnosisService = new DiagnosisService(); Object obj = diagnosisService.getQueries(0, 10, BadQueryEntry.ADJ_PUSHDOWN, allEntries).get("badQueries"); List<BadQueryEntry> pushDownList = (List<BadQueryEntry>) obj; Assert.assertEquals(1, pushDownList.size()); obj = diagnosisService.getQueries(0, 10, BadQueryEntry.ADJ_SLOW, allEntries).get("badQueries"); List<BadQueryEntry> slowList = (List<BadQueryEntry>) obj; Assert.assertEquals(2, slowList.size()); }
public Map<String, Object> getQueries(Integer pageOffset, Integer pageSize, String queryType, List<BadQueryEntry> allBadEntries) throws IOException { HashMap<String, Object> data = new HashMap<>(); List<BadQueryEntry> filteredEntries = getQueriesByType(allBadEntries, queryType); int offset = pageOffset * pageSize; int limit = pageSize; if (filteredEntries.size() <= offset) { offset = filteredEntries.size(); limit = 0; } if ((filteredEntries.size() - offset) < limit) { limit = filteredEntries.size() - offset; } data.put("badQueries", filteredEntries.subList(offset, offset + limit)); data.put("size", filteredEntries.size()); return data; }
DiagnosisService extends BasicService { public Map<String, Object> getQueries(Integer pageOffset, Integer pageSize, String queryType, List<BadQueryEntry> allBadEntries) throws IOException { HashMap<String, Object> data = new HashMap<>(); List<BadQueryEntry> filteredEntries = getQueriesByType(allBadEntries, queryType); int offset = pageOffset * pageSize; int limit = pageSize; if (filteredEntries.size() <= offset) { offset = filteredEntries.size(); limit = 0; } if ((filteredEntries.size() - offset) < limit) { limit = filteredEntries.size() - offset; } data.put("badQueries", filteredEntries.subList(offset, offset + limit)); data.put("size", filteredEntries.size()); return data; } }
DiagnosisService extends BasicService { public Map<String, Object> getQueries(Integer pageOffset, Integer pageSize, String queryType, List<BadQueryEntry> allBadEntries) throws IOException { HashMap<String, Object> data = new HashMap<>(); List<BadQueryEntry> filteredEntries = getQueriesByType(allBadEntries, queryType); int offset = pageOffset * pageSize; int limit = pageSize; if (filteredEntries.size() <= offset) { offset = filteredEntries.size(); limit = 0; } if ((filteredEntries.size() - offset) < limit) { limit = filteredEntries.size() - offset; } data.put("badQueries", filteredEntries.subList(offset, offset + limit)); data.put("size", filteredEntries.size()); return data; }  }
DiagnosisService extends BasicService { public Map<String, Object> getQueries(Integer pageOffset, Integer pageSize, String queryType, List<BadQueryEntry> allBadEntries) throws IOException { HashMap<String, Object> data = new HashMap<>(); List<BadQueryEntry> filteredEntries = getQueriesByType(allBadEntries, queryType); int offset = pageOffset * pageSize; int limit = pageSize; if (filteredEntries.size() <= offset) { offset = filteredEntries.size(); limit = 0; } if ((filteredEntries.size() - offset) < limit) { limit = filteredEntries.size() - offset; } data.put("badQueries", filteredEntries.subList(offset, offset + limit)); data.put("size", filteredEntries.size()); return data; }  BadQueryHistory getProjectBadQueryHistory(String project); String dumpProjectDiagnosisInfo(String project, File exportPath); String dumpJobDiagnosisInfo(String jobId, File exportPath); List<BadQueryEntry> getQueriesByType(List<BadQueryEntry> allBadEntries, String queryType); Map<String, Object> getQueries(Integer pageOffset, Integer pageSize, String queryType,
            List<BadQueryEntry> allBadEntries); }
DiagnosisService extends BasicService { public Map<String, Object> getQueries(Integer pageOffset, Integer pageSize, String queryType, List<BadQueryEntry> allBadEntries) throws IOException { HashMap<String, Object> data = new HashMap<>(); List<BadQueryEntry> filteredEntries = getQueriesByType(allBadEntries, queryType); int offset = pageOffset * pageSize; int limit = pageSize; if (filteredEntries.size() <= offset) { offset = filteredEntries.size(); limit = 0; } if ((filteredEntries.size() - offset) < limit) { limit = filteredEntries.size() - offset; } data.put("badQueries", filteredEntries.subList(offset, offset + limit)); data.put("size", filteredEntries.size()); return data; }  BadQueryHistory getProjectBadQueryHistory(String project); String dumpProjectDiagnosisInfo(String project, File exportPath); String dumpJobDiagnosisInfo(String jobId, File exportPath); List<BadQueryEntry> getQueriesByType(List<BadQueryEntry> allBadEntries, String queryType); Map<String, Object> getQueries(Integer pageOffset, Integer pageSize, String queryType,
            List<BadQueryEntry> allBadEntries);  }