• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-2022 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_RENAME_NODE_H_
18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_RENAME_NODE_H_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "minddata/dataset/engine/ir/datasetops/dataset_node.h"
25 
26 namespace mindspore {
27 namespace dataset {
28 class RenameNode : public DatasetNode {
29  public:
30   /// \brief Constructor
31   explicit RenameNode(std::shared_ptr<DatasetNode> child, const std::vector<std::string> &input_columns,
32                       const std::vector<std::string> &output_columns);
33 
34   /// \brief Destructor
35   ~RenameNode() override = default;
36 
37   /// \brief Node name getter
38   /// \return Name of the current node
Name()39   std::string Name() const override { return kRenameNode; }
40 
41   /// \brief Base-class override for accepting IRNodePass visitor
42   /// \param[in] p The node to visit
43   /// \param[out] modified Indicator if the node was modified
44   /// \return Status of the node visit
45   Status Accept(IRNodePass *const p, bool *const modified) override;
46 
47   /// \brief Base-class override for accepting IRNodePass visitor
48   /// \param[in] p The node to visit
49   /// \param[out] modified Indicator if the node was modified
50   /// \return Status of the node visit
51   Status AcceptAfter(IRNodePass *const p, bool *const modified) override;
52 
53   /// \brief Print the description
54   /// \param out - The output stream to write output to
55   void Print(std::ostream &out) const override;
56 
57   /// \brief Copy the node to a new object
58   /// \return A shared pointer to the new copy
59   std::shared_ptr<DatasetNode> Copy() override;
60 
61   /// \brief a base class override function to create the required runtime dataset op objects for this class
62   /// \param node_ops - A vector containing shared pointer to the Dataset Ops that this object will create
63   /// \return Status Status::OK() if build successfully
64   Status Build(std::vector<std::shared_ptr<DatasetOp>> *const node_ops) override;
65 
66   /// \brief Parameters validation
67   /// \return Status Status::OK() if all the parameters are valid
68   Status ValidateParams() override;
69 
70   /// \brief Getter functions
InputColumns()71   const std::vector<std::string> &InputColumns() const { return input_columns_; }
OutputColumns()72   const std::vector<std::string> &OutputColumns() const { return output_columns_; }
73 
74   /// \brief Get the arguments of node
75   /// \param[out] out_json JSON string of all attributes
76   /// \return Status of the function
77   Status to_json(nlohmann::json *out_json) override;
78 
79   /// \brief Function for read dataset operation from json
80   /// \param[in] json_obj The JSON object to be deserialized
81   /// \param[in] ds dataset node constructed
82   /// \param[out] result Deserialized dataset after the operation
83   /// \return Status The status code returned
84   static Status from_json(nlohmann::json json_obj, std::shared_ptr<DatasetNode> ds,
85                           std::shared_ptr<DatasetNode> *result);
86 
87  private:
88   std::vector<std::string> input_columns_;
89   std::vector<std::string> output_columns_;
90 };
91 }  // namespace dataset
92 }  // namespace mindspore
93 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_DATASETOPS_RENAME_NODE_H_
94