public void initQueryDataSource(List<IFullPath> sourcePaths) throws QueryProcessException {
    long startTime = System.nanoTime();
    if (sourcePaths == null || sourcePaths.isEmpty()) {
      this.sharedQueryDataSource = EMPTY_QUERY_DATA_SOURCE;
      return;
    }

    IDeviceID singleDeviceId = null;
    if (sourcePaths.size() == 1) {
      singleDeviceId = sourcePaths.get(0).getDeviceId();
    } else {
      Set<IDeviceID> selectedDeviceIdSet = new HashSet<>();
      for (IFullPath sourcePath : sourcePaths) {
        if (sourcePath instanceof AlignedFullPath) {
          singleDeviceId = null;
          break;
        } else {
          singleDeviceId = sourcePath.getDeviceId();
          selectedDeviceIdSet.add(singleDeviceId);
          if (selectedDeviceIdSet.size() > 1) {
            singleDeviceId = null;
            break;
          }
        }
      }
    }

    dataRegion.readLock();
    try {

      this.sharedQueryDataSource =
          dataRegion.query(
              sourcePaths,
              // when all the selected series are under the same device, the QueryDataSource will be
              // filtered according to timeIndex
              singleDeviceId,
              this,
              // time filter may be stateful, so we need to copy it
              globalTimeFilter != null ? globalTimeFilter.copy() : null,
              timePartitions);

      // used files should be added before mergeLock is unlocked, or they may be deleted by
      // running merge
      if (sharedQueryDataSource != null) {
        closedFilePaths = new HashSet<>();
        unClosedFilePaths = new HashSet<>();
        addUsedFilesForQuery((QueryDataSource) sharedQueryDataSource);
        ((QueryDataSource) sharedQueryDataSource).setSingleDevice(singleDeviceId != null);
      }
    } finally {
      setInitQueryDataSourceCost(System.nanoTime() - startTime);
      dataRegion.readUnlock();
    }
  }
return List of specific throwable and stack trace
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceContext.java