public List<TRegionReplicaSet> getDataRegionReplicaSetForWriting(
      final IDeviceID deviceID,
      final List<TTimePartitionSlot> timePartitionSlotList,
      String databaseName) {
    if (databaseName == null) {
      databaseName = getDatabaseNameByDevice(deviceID);
    }
    // A list of data region replica sets will store data in a same time partition.
    // We will insert data to the last set in the list.
    // TODO return the latest dataRegionReplicaSet for each time partition
    final TSeriesPartitionSlot seriesPartitionSlot = calculateDeviceGroupId(deviceID);
    // IMPORTANT TODO: (xingtanzjr) need to handle the situation for write operation that there are
    // more than 1 Regions for one timeSlot
    final List<TRegionReplicaSet> dataRegionReplicaSets = new ArrayList<>();
    final Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionReplicaSet>>>
        dataBasePartitionMap = dataPartitionMap.get(databaseName);
    final Map<TTimePartitionSlot, List<TRegionReplicaSet>> slotReplicaSetMap =
        dataBasePartitionMap.get(seriesPartitionSlot);
    for (final TTimePartitionSlot timePartitionSlot : timePartitionSlotList) {
      final List<TRegionReplicaSet> targetRegionList = slotReplicaSetMap.get(timePartitionSlot);
      if (targetRegionList == null || targetRegionList.isEmpty()) {
        throw new RuntimeException(
            String.format(
                "targetRegionList is empty. device: %s, timeSlot: %s",
                deviceID, timePartitionSlot));
      } else {
        dataRegionReplicaSets.add(targetRegionList.get(targetRegionList.size() - 1));
      }
    }
    return dataRegionReplicaSets;
  }
For table model usage.

<p>The database shall start with "root.". Concat this to a user-provided db name if necessary.

<p>The device id shall be [table, seg1, ....]
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartition.java