DescribeIndexRecommendationResult.cc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud All rights reserved.
  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. #include <alibabacloud/dds/model/DescribeIndexRecommendationResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Dds;
  19. using namespace AlibabaCloud::Dds::Model;
  20. DescribeIndexRecommendationResult::DescribeIndexRecommendationResult() :
  21. ServiceResult()
  22. {}
  23. DescribeIndexRecommendationResult::DescribeIndexRecommendationResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeIndexRecommendationResult::~DescribeIndexRecommendationResult()
  29. {}
  30. void DescribeIndexRecommendationResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto allAnalyzationsNode = value["Analyzations"]["Analyzation"];
  37. for (auto valueAnalyzationsAnalyzation : allAnalyzationsNode)
  38. {
  39. Analyzation analyzationsObject;
  40. if(!valueAnalyzationsAnalyzation["Database"].isNull())
  41. analyzationsObject.database = valueAnalyzationsAnalyzation["Database"].asString();
  42. if(!valueAnalyzationsAnalyzation["Namespace"].isNull())
  43. analyzationsObject._namespace = valueAnalyzationsAnalyzation["Namespace"].asString();
  44. if(!valueAnalyzationsAnalyzation["Operation"].isNull())
  45. analyzationsObject.operation = valueAnalyzationsAnalyzation["Operation"].asString();
  46. if(!valueAnalyzationsAnalyzation["Query"].isNull())
  47. analyzationsObject.query = valueAnalyzationsAnalyzation["Query"].asString();
  48. if(!valueAnalyzationsAnalyzation["Sort"].isNull())
  49. analyzationsObject.sort = valueAnalyzationsAnalyzation["Sort"].asString();
  50. if(!valueAnalyzationsAnalyzation["Count"].isNull())
  51. analyzationsObject.count = std::stol(valueAnalyzationsAnalyzation["Count"].asString());
  52. if(!valueAnalyzationsAnalyzation["TotalExecutionTime"].isNull())
  53. analyzationsObject.totalExecutionTime = std::stol(valueAnalyzationsAnalyzation["TotalExecutionTime"].asString());
  54. if(!valueAnalyzationsAnalyzation["AverageExecutionTime"].isNull())
  55. analyzationsObject.averageExecutionTime = std::stol(valueAnalyzationsAnalyzation["AverageExecutionTime"].asString());
  56. if(!valueAnalyzationsAnalyzation["AverageReturnRowCount"].isNull())
  57. analyzationsObject.averageReturnRowCount = std::stol(valueAnalyzationsAnalyzation["AverageReturnRowCount"].asString());
  58. if(!valueAnalyzationsAnalyzation["AverageDocsExaminedCount"].isNull())
  59. analyzationsObject.averageDocsExaminedCount = std::stol(valueAnalyzationsAnalyzation["AverageDocsExaminedCount"].asString());
  60. if(!valueAnalyzationsAnalyzation["AverageKeysExaminedCount"].isNull())
  61. analyzationsObject.averageKeysExaminedCount = std::stol(valueAnalyzationsAnalyzation["AverageKeysExaminedCount"].asString());
  62. if(!valueAnalyzationsAnalyzation["InMemorySort"].isNull())
  63. analyzationsObject.inMemorySort = valueAnalyzationsAnalyzation["InMemorySort"].asString();
  64. if(!valueAnalyzationsAnalyzation["LastExecutionTime"].isNull())
  65. analyzationsObject.lastExecutionTime = valueAnalyzationsAnalyzation["LastExecutionTime"].asString();
  66. if(!valueAnalyzationsAnalyzation["ExecutionPlan"].isNull())
  67. analyzationsObject.executionPlan = valueAnalyzationsAnalyzation["ExecutionPlan"].asString();
  68. auto allIndexRecommendationsNode = allAnalyzationsNode["IndexRecommendations"]["Recommendation"];
  69. for (auto allAnalyzationsNodeIndexRecommendationsRecommendation : allIndexRecommendationsNode)
  70. {
  71. Analyzation::Recommendation indexRecommendationsObject;
  72. if(!allAnalyzationsNodeIndexRecommendationsRecommendation["RecmdType"].isNull())
  73. indexRecommendationsObject.recmdType = allAnalyzationsNodeIndexRecommendationsRecommendation["RecmdType"].asString();
  74. if(!allAnalyzationsNodeIndexRecommendationsRecommendation["Content"].isNull())
  75. indexRecommendationsObject.content = allAnalyzationsNodeIndexRecommendationsRecommendation["Content"].asString();
  76. analyzationsObject.indexRecommendations.push_back(indexRecommendationsObject);
  77. }
  78. auto allIndexCombines = value["IndexCombines"]["IndexCombine"];
  79. for (auto value : allIndexCombines)
  80. analyzationsObject.indexCombines.push_back(value.asString());
  81. analyzations_.push_back(analyzationsObject);
  82. }
  83. if(!value["TotalRecordCount"].isNull())
  84. totalRecordCount_ = std::stoi(value["TotalRecordCount"].asString());
  85. if(!value["PageNumber"].isNull())
  86. pageNumber_ = std::stoi(value["PageNumber"].asString());
  87. if(!value["PageRecordCount"].isNull())
  88. pageRecordCount_ = std::stoi(value["PageRecordCount"].asString());
  89. }
  90. int DescribeIndexRecommendationResult::getTotalRecordCount()const
  91. {
  92. return totalRecordCount_;
  93. }
  94. int DescribeIndexRecommendationResult::getPageRecordCount()const
  95. {
  96. return pageRecordCount_;
  97. }
  98. std::vector<DescribeIndexRecommendationResult::Analyzation> DescribeIndexRecommendationResult::getAnalyzations()const
  99. {
  100. return analyzations_;
  101. }
  102. int DescribeIndexRecommendationResult::getPageNumber()const
  103. {
  104. return pageNumber_;
  105. }