private List<TRegionReplicaSet> getDeviceReplicaSets(
      DataPartition dataPartition,
      Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionReplicaSet>>> seriesSlotMap,
      IDeviceID deviceId,
      Filter timeFilter,
      Map<Integer, List<TRegionReplicaSet>> cachedSeriesSlotWithRegions) {

    // given seriesPartitionSlot has already been calculated
    final TSeriesPartitionSlot seriesPartitionSlot = dataPartition.calculateDeviceGroupId(deviceId);
    List<TRegionReplicaSet> regionReplicaSets =
        cachedSeriesSlotWithRegions.get(seriesPartitionSlot.getSlotId());
    if (regionReplicaSets != null) {
      return regionReplicaSets;
    }

    // given seriesPartitionSlot has not been calculated
    Map<TTimePartitionSlot, List<TRegionReplicaSet>> timeSlotMap =
        seriesSlotMap.get(seriesPartitionSlot);
    if (timeSlotMap == null) {
      List<TRegionReplicaSet> cachedReplicaSets = Collections.singletonList(NOT_ASSIGNED);
      cachedSeriesSlotWithRegions.put(seriesPartitionSlot.getSlotId(), cachedReplicaSets);
      return cachedReplicaSets;
    }
    if (timeSlotMap.size() == 1) {
      TTimePartitionSlot timePartitionSlot = timeSlotMap.keySet().iterator().next();
      if (TimePartitionUtils.satisfyPartitionStartTime(timeFilter, timePartitionSlot.startTime)) {
        cachedSeriesSlotWithRegions.put(
            seriesPartitionSlot.getSlotId(), timeSlotMap.values().iterator().next());
        return timeSlotMap.values().iterator().next();
      } else {
        cachedSeriesSlotWithRegions.put(seriesPartitionSlot.getSlotId(), Collections.emptyList());
        return Collections.emptyList();
      }
    }

    Set<TRegionReplicaSet> resultSet = new HashSet<>();
    for (Map.Entry<TTimePartitionSlot, List<TRegionReplicaSet>> entry : timeSlotMap.entrySet()) {
      TTimePartitionSlot timePartitionSlot = entry.getKey();
      if (TimePartitionUtils.satisfyPartitionStartTime(timeFilter, timePartitionSlot.startTime)) {
        resultSet.addAll(entry.getValue());
      }
    }
    List<TRegionReplicaSet> resultList = new ArrayList<>(resultSet);
    cachedSeriesSlotWithRegions.put(seriesPartitionSlot.getSlotId(), resultList);
    return resultList;
  }
This class is used to generate distributed plan for table model.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/distribute/TableDistributedPlanGenerator.java