public TreeTopKOperator emptyTopKOperatorTest(
      Ordering timeOrdering, Ordering deviceOrdering, int limitValue) {
    ExecutorService instanceNotificationExecutor =
        IoTDBThreadPoolFactory.newFixedThreadPool(1, "test-instance-notification");
    // Construct operator tree
    QueryId queryId = new QueryId("stub_query");

    FragmentInstanceId instanceId =
        new FragmentInstanceId(new PlanFragmentId(queryId, 0), "stub-instance");
    FragmentInstanceStateMachine stateMachine =
        new FragmentInstanceStateMachine(instanceId, instanceNotificationExecutor);
    FragmentInstanceContext fragmentInstanceContext =
        createFragmentInstanceContext(instanceId, stateMachine);
    DriverContext driverContext = new DriverContext(fragmentInstanceContext, 0);
    PlanNodeId planNodeId1 = new PlanNodeId("1");
    driverContext.addOperatorContext(1, planNodeId1, SeriesScanOperator.class.getSimpleName());
    PlanNodeId planNodeId2 = new PlanNodeId("2");
    driverContext.addOperatorContext(2, planNodeId2, SeriesScanOperator.class.getSimpleName());
    PlanNodeId planNodeId3 = new PlanNodeId("3");
    driverContext.addOperatorContext(3, planNodeId3, SeriesScanOperator.class.getSimpleName());
    PlanNodeId planNodeId4 = new PlanNodeId("4");
    driverContext.addOperatorContext(4, planNodeId4, SeriesScanOperator.class.getSimpleName());
    PlanNodeId planNodeId5 = new PlanNodeId("5");
    driverContext.addOperatorContext(5, planNodeId5, SeriesScanOperator.class.getSimpleName());
    driverContext.addOperatorContext(
        6, new PlanNodeId("6"), SingleDeviceViewOperator.class.getSimpleName());
    driverContext.addOperatorContext(
        7, new PlanNodeId("7"), FullOuterTimeJoinOperator.class.getSimpleName());
    driverContext.addOperatorContext(
        8, new PlanNodeId("8"), SingleDeviceViewOperator.class.getSimpleName());
    driverContext.addOperatorContext(
        9, new PlanNodeId("9"), FullOuterTimeJoinOperator.class.getSimpleName());
    driverContext.addOperatorContext(
        10, new PlanNodeId("10"), SingleDeviceViewOperator.class.getSimpleName());
    driverContext.addOperatorContext(
        11, new PlanNodeId("11"), TreeTopKOperator.class.getSimpleName());

    NonAlignedFullPath measurementPath1 =
        new NonAlignedFullPath(
            IDeviceID.Factory.DEFAULT_FACTORY.create(TOP_K_OPERATOR_TEST_SG + ".device0"),
            new MeasurementSchema("sensor0", TSDataType.INT32));
    SeriesScanOperator seriesScanOperator1 =
        new SeriesScanOperator(
            driverContext.getOperatorContexts().get(0),
            planNodeId1,
            measurementPath1,
            timeOrdering,
            SeriesScanOptions.getDefaultSeriesScanOptions(measurementPath1));
    seriesScanOperator1.initQueryDataSource(
        new QueryDataSource(Collections.emptyList(), Collections.emptyList()));
    OperatorContext.setMaxRunTime(new Duration(500, TimeUnit.MILLISECONDS));

    NonAlignedFullPath measurementPath2 =
        new NonAlignedFullPath(
            IDeviceID.Factory.DEFAULT_FACTORY.create(TOP_K_OPERATOR_TEST_SG + ".device1"),
            new MeasurementSchema("sensor0", TSDataType.INT32));
    SeriesScanOperator seriesScanOperator2 =
        new SeriesScanOperator(
            driverContext.getOperatorContexts().get(1),
            planNodeId2,
            measurementPath2,
            timeOrdering,
            SeriesScanOptions.getDefaultSeriesScanOptions(measurementPath2));
    seriesScanOperator2.initQueryDataSource(
        new QueryDataSource(Collections.emptyList(), Collections.emptyList()));
    OperatorContext.setMaxRunTime(new Duration(500, TimeUnit.MILLISECONDS));

    NonAlignedFullPath measurementPath3 =
        new NonAlignedFullPath(
            IDeviceID.Factory.DEFAULT_FACTORY.create(TOP_K_OPERATOR_TEST_SG + ".device1"),
            new MeasurementSchema("sensor1", TSDataType.INT32));
    SeriesScanOperator seriesScanOperator3 =
        new SeriesScanOperator(
            driverContext.getOperatorContexts().get(2),
            planNodeId3,
            measurementPath3,
            timeOrdering,
            SeriesScanOptions.getDefaultSeriesScanOptions(measurementPath3));
    seriesScanOperator3.initQueryDataSource(
        new QueryDataSource(Collections.emptyList(), Collections.emptyList()));
    OperatorContext.setMaxRunTime(new Duration(500, TimeUnit.MILLISECONDS));

    NonAlignedFullPath measurementPath4 =
        new NonAlignedFullPath(
            IDeviceID.Factory.DEFAULT_FACTORY.create(TOP_K_OPERATOR_TEST_SG + ".device2"),
            new MeasurementSchema("sensor0", TSDataType.INT32));
    SeriesScanOperator seriesScanOperator4 =
        new SeriesScanOperator(
            driverContext.getOperatorContexts().get(3),
            planNodeId4,
            measurementPath4,
            timeOrdering,
            SeriesScanOptions.getDefaultSeriesScanOptions(measurementPath4));
    seriesScanOperator4.initQueryDataSource(
        new QueryDataSource(Collections.emptyList(), Collections.emptyList()));
    OperatorContext.setMaxRunTime(new Duration(500, TimeUnit.MILLISECONDS));

    NonAlignedFullPath measurementPath5 =
        new NonAlignedFullPath(
            IDeviceID.Factory.DEFAULT_FACTORY.create(TOP_K_OPERATOR_TEST_SG + ".device2"),
            new MeasurementSchema("sensor1", TSDataType.INT32));
    SeriesScanOperator seriesScanOperator5 =
        new SeriesScanOperator(
            driverContext.getOperatorContexts().get(4),
            planNodeId5,
            measurementPath5,
            timeOrdering,
            SeriesScanOptions.getDefaultSeriesScanOptions(measurementPath5));
    seriesScanOperator5.initQueryDataSource(
        new QueryDataSource(Collections.emptyList(), Collections.emptyList()));
    OperatorContext.setMaxRunTime(new Duration(500, TimeUnit.MILLISECONDS));

    List<TSDataType> tsDataTypes =
        new LinkedList<>(
            Arrays.asList(
                TSDataType.TEXT,
                TSDataType.INT32,
                TSDataType.INT32,
                TSDataType.INT32,
                TSDataType.INT32,
                TSDataType.INT32));
    SingleDeviceViewOperator singleDeviceViewOperator1 =
        new SingleDeviceViewOperator(
            driverContext.getOperatorContexts().get(5),
            DEVICE0,
            seriesScanOperator1,
            Collections.singletonList(1),
            tsDataTypes);

    FullOuterTimeJoinOperator timeJoinOperator1 =
        new FullOuterTimeJoinOperator(
            driverContext.getOperatorContexts().get(6),
            Arrays.asList(seriesScanOperator2, seriesScanOperator3),
            timeOrdering,
            Arrays.asList(TSDataType.INT32, TSDataType.INT32),
            Arrays.asList(
                new SingleColumnMerger(
                    new InputLocation(0, 0),
                    timeOrdering == Ordering.ASC
                        ? new AscTimeComparator()
                        : new DescTimeComparator()),
                new SingleColumnMerger(
                    new InputLocation(1, 0),
                    timeOrdering == Ordering.ASC
                        ? new AscTimeComparator()
                        : new DescTimeComparator())),
            timeOrdering == Ordering.ASC ? new AscTimeComparator() : new DescTimeComparator());
    OperatorContext.setMaxRunTime(new Duration(500, TimeUnit.MILLISECONDS));

    SingleDeviceViewOperator singleDeviceViewOperator2 =
        new SingleDeviceViewOperator(
            driverContext.getOperatorContexts().get(7),
            DEVICE1,
            timeJoinOperator1,
            Arrays.asList(2, 3),
            tsDataTypes);

    FullOuterTimeJoinOperator timeJoinOperator2 =
        new FullOuterTimeJoinOperator(
            driverContext.getOperatorContexts().get(8),
            Arrays.asList(seriesScanOperator4, seriesScanOperator5),
            timeOrdering,
            Arrays.asList(TSDataType.INT32, TSDataType.INT32),
            Arrays.asList(
                new SingleColumnMerger(
                    new InputLocation(0, 0),
                    timeOrdering == Ordering.ASC
                        ? new AscTimeComparator()
                        : new DescTimeComparator()),
                new SingleColumnMerger(
                    new InputLocation(1, 0),
                    timeOrdering == Ordering.ASC
                        ? new AscTimeComparator()
                        : new DescTimeComparator())),
            timeOrdering == Ordering.ASC ? new AscTimeComparator() : new DescTimeComparator());
    OperatorContext.setMaxRunTime(new Duration(500, TimeUnit.MILLISECONDS));

    SingleDeviceViewOperator singleDeviceViewOperator3 =
        new SingleDeviceViewOperator(
            driverContext.getOperatorContexts().get(9),
            DEVICE2,
            timeJoinOperator2,
            Arrays.asList(4, 5),
            tsDataTypes);

    TreeTopKOperator topKOperator =
        new TreeTopKOperator(
            driverContext.getOperatorContexts().get(10),
            Arrays.asList(
                singleDeviceViewOperator1, singleDeviceViewOperator2, singleDeviceViewOperator3),
            tsDataTypes,
            MergeSortComparator.getComparator(
                Arrays.asList(
                    new SortItem(OrderByKey.TIME, timeOrdering),
                    new SortItem(OrderByKey.DEVICE, deviceOrdering)),
                Arrays.asList(-1, 0),
                Arrays.asList(TSDataType.INT64, TSDataType.TEXT)),
            limitValue,
            true);
    OperatorContext.setMaxRunTime(new Duration(500, TimeUnit.MILLISECONDS));
    return topKOperator;
  }
The original data and structure of this test is same as {@link MergeTreeSortOperatorTest}.
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/TreeTopKOperatorTest.java