public Pair<ListenableFuture<Void>, Boolean> reserve(
      String queryId,
      String fragmentInstanceId,
      String planNodeId,
      long bytesToReserve,
      long maxBytesCanReserve) {
    Validate.notNull(queryId, "queryId can not be null.");
    Validate.notNull(fragmentInstanceId, "fragmentInstanceId can not be null.");
    Validate.notNull(planNodeId, "planNodeId can not be null.");
    Validate.isTrue(
        bytesToReserve > 0L && bytesToReserve <= maxBytesPerFragmentInstance,
        "bytesToReserve should be in (0,maxBytesPerFI]. maxBytesPerFI: %d, bytesToReserve: %d",
        maxBytesPerFragmentInstance,
        bytesToReserve);
    if (bytesToReserve > maxBytesCanReserve) {
      LOGGER.warn(
          "Cannot reserve {}(Max: {}) bytes memory from MemoryPool for planNodeId{}",
          bytesToReserve,
          maxBytesCanReserve,
          planNodeId);
      throw new IllegalArgumentException(
          String.format(
              "Query is aborted since it requests more memory than can be allocated, bytesToReserve: %sB, maxBytesCanReserve: %sB",
              bytesToReserve, maxBytesCanReserve));
    }

    ListenableFuture<Void> result;
    if (tryReserve(queryId, fragmentInstanceId, planNodeId, bytesToReserve, maxBytesCanReserve)) {
      result = Futures.immediateFuture(null);
      return new Pair<>(result, Boolean.TRUE);
    } else {
      LOGGER.debug(
          "Blocked reserve request: {} bytes memory for planNodeId{}", bytesToReserve, planNodeId);
      rollbackReserve(queryId, fragmentInstanceId, planNodeId, bytesToReserve);
      result =
          MemoryReservationFuture.create(
              queryId, fragmentInstanceId, planNodeId, bytesToReserve, maxBytesCanReserve);
      memoryReservationFutures.add((MemoryReservationFuture<Void>) result);
      return new Pair<>(result, Boolean.FALSE);
    }
  }
Reserve memory with bytesToReserve.

@return if reserve succeed, pair.right will be true, otherwise false
@throws IllegalArgumentException throw exception if current query requests more memory than can
    be allocated.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/MemoryPool.java