presto-main/src/main/java/io/prestosql/memory/MemoryPool.java/MemoryPool/moveQuery
class MemoryPool:    synchronized ListenableFuture<?> moveQuery(QueryId queryId, MemoryPool targetMemoryPool)
    {
        long originalReserved = getQueryMemoryReservation(queryId);
        long originalRevocableReserved = getQueryRevocableMemoryReservation(queryId);
        // Get the tags before we call free() as that would remove the tags and we will lose the tags.
        Map<String, Long> taggedAllocations = taggedMemoryAllocations.remove(queryId);
        if (taggedAllocations == null) {
            // query is not registered (likely a race with query completion)
            return Futures.immediateFuture(null);
        }
        ListenableFuture<?> future = targetMemoryPool.reserve(queryId, MOVE_QUERY_TAG, originalReserved);
        free(queryId, MOVE_QUERY_TAG, originalReserved);
        targetMemoryPool.reserveRevocable(queryId, originalRevocableReserved);
        freeRevocable(queryId, originalRevocableReserved);
        targetMemoryPool.taggedMemoryAllocations.put(queryId, taggedAllocations);
        return future;
    }