presto-main/src/main/java/io/prestosql/memory/TotalReservationOnBlockedNodesLowMemoryKiller.java/TotalReservationOnBlockedNodesLowMemoryKiller/chooseQueryToKill
class TotalReservationOnBlockedNodesLowMemoryKiller:    @Override
    public Optional<QueryId> chooseQueryToKill(List<QueryMemoryInfo> runningQueries, List<MemoryInfo> nodes)
    {
        Map<QueryId, Long> memoryReservationOnBlockedNodes = new HashMap<>();
        for (MemoryInfo node : nodes) {
            MemoryPoolInfo generalPool = node.getPools().get(GENERAL_POOL);
            if (generalPool == null) {
                continue;
            }
            if (generalPool.getFreeBytes() + generalPool.getReservedRevocableBytes() > 0) {
                continue;
            }
            Map<QueryId, Long> queryMemoryReservations = generalPool.getQueryMemoryReservations();
            queryMemoryReservations.forEach((queryId, memoryReservation) -> {
                memoryReservationOnBlockedNodes.compute(queryId, (id, oldValue) -> oldValue == null ? memoryReservation : oldValue + memoryReservation);
            });
        }

        return memoryReservationOnBlockedNodes.entrySet().stream()
                .max(comparingLong(Map.Entry::getValue))
                .map(Map.Entry::getKey);
    }