public TRegionReplicaSet getDataRegionReplicaSetForWriting(
      final IDeviceID deviceID, final TTimePartitionSlot timePartitionSlot, String databaseName) {
    // 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);
    if (databaseName == null) {
      databaseName = getDatabaseNameByDevice(deviceID);
    }
    final Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionReplicaSet>>>
        databasePartitionMap = dataPartitionMap.get(databaseName);
    if (databasePartitionMap == null) {
      throw new RuntimeException(
          "Database "
              + databaseName
              + " not exists and failed to create automatically because enable_auto_create_schema is FALSE.");
    }
    final List<TRegionReplicaSet> regions =
        databasePartitionMap.get(seriesPartitionSlot).get(timePartitionSlot);
    // IMPORTANT TODO: (xingtanzjr) need to handle the situation for write operation that there
    // are more than 1 Regions for one timeSlot
    return regions.get(0);
  }
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