@Override
  public List<PlanNode> visitTopK(TopKNode node, PlanContext context) {
    context.setExpectedOrderingScheme(node.getOrderingScheme());
    nodeOrderingMap.put(node.getPlanNodeId(), node.getOrderingScheme());

    checkArgument(
        node.getChildren().size() == 1, "Size of TopKNode can only be 1 in logical plan.");
    List<PlanNode> childrenNodes = node.getChildren().get(0).accept(this, context);
    if (childrenNodes.size() == 1) {
      if (canTopKEliminated(node.getOrderingScheme(), node.getCount(), childrenNodes.get(0))) {
        return childrenNodes;
      }
      node.setChildren(Collections.singletonList(childrenNodes.get(0)));
      return Collections.singletonList(node);
    }

    TopKNode newTopKNode = (TopKNode) node.clone();
    for (PlanNode child : childrenNodes) {
      PlanNode newChild;
      if (canTopKEliminated(node.getOrderingScheme(), node.getCount(), child)) {
        newChild = child;
      } else {
        newChild =
            new TopKNode(
                queryId.genPlanNodeId(),
                Collections.singletonList(child),
                node.getOrderingScheme(),
                node.getCount(),
                node.getOutputSymbols(),
                node.isChildrenDataInOrder());
      }
      newTopKNode.addChild(newChild);
    }
    nodeOrderingMap.put(newTopKNode.getPlanNodeId(), newTopKNode.getOrderingScheme());

    return Collections.singletonList(newTopKNode);
  }
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