public boolean shouldPrefetch() {
    // 1. reject conditions
    // 1.1. option
    if (!SubscriptionConfig.getInstance().getSubscriptionPrefetchEnabled()) {
      return false;
    }

    // 1.2. memory usage
    if (!isMemoryEnough()) {
      return false;
    }

    // 1.3. local event count
    if (hasTooManyPrefetchedLocalEvent()) {
      return false;
    }

    // 1.4. global event count
    if (hasTooManyPrefetchedGlobalEvent()) {
      return false;
    }

    // 1.5. disorder history
    if (hasDisorderCause()) {
      return false;
    }

    // 2. permissive conditions
    // 2.1. missing rate
    if (isMissingRateTooHigh()) {
      return true;
    }

    // 2.2. prefetch statistics
    // the delta between the prefetch timestamp and the timestamp of the last poll request > poll
    // request frequency
    return (System.currentTimeMillis() - lastPollRequestTimestamp) * pollRate() > 1000;
  }
The {@link SubscriptionPrefetchingQueueStates} manages the state of a {@link
SubscriptionPrefetchingQueue}. It determines whether prefetching should occur based on memory
availability, poll request rates, and missing prefetch rates.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingQueueStates.java