@Override
    public Optional<QueryId> chooseQueryToKill(List<QueryMemoryInfo> runningQueries, List<MemoryInfo> nodes)
    {
        QueryId biggestQuery = null;
        long maxMemory = 0;
        for (QueryMemoryInfo query : runningQueries) {
            long bytesUsed = query.getMemoryReservation();
            if (bytesUsed > maxMemory && GENERAL_POOL.equals(query.getMemoryPoolId())) {
                biggestQuery = query.getQueryId();
                maxMemory = bytesUsed;
            }
        }
        return Optional.ofNullable(biggestQuery);
    }
@Test
    public void testSkewedQuery()
    {
        int reservePool = 10;
        int generalPool = 12;
        // q2 is the query with the most total memory reservation, but not the query with the max memory reservation.
        // This also tests the corner case where a node doesn't have a general pool.
        Map<String, Map<String, Long>> queries = ImmutableMap.<String, Map<String, Long>>builder()
                .put("q_1", ImmutableMap.of("n1", 0L, "n2", 8L, "n3", 0L, "n4", 0L, "n5", 0L))
                .put("q_2", ImmutableMap.of("n1", 3L, "n2", 5L, "n3", 2L, "n4", 4L, "n5", 0L))
                .put("q_3", ImmutableMap.of("n1", 0L, "n2", 0L, "n3", 9L, "n4", 0L, "n5", 0L))
                .put("q_r", ImmutableMap.of("n1", 6L, "n2", 6L, "n3", 6L, "n4", 6L, "n5", 6L))
                .build();
        assertEquals(
                lowMemoryKiller.chooseQueryToKill(
                        toQueryMemoryInfoList("q_r", queries),
                        toNodeMemoryInfoList(reservePool, generalPool, "q_r", queries)),
                Optional.of(new QueryId("q_2")));
    }