GetPartitionResult.cc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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/openanalytics-open/model/GetPartitionResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Openanalytics_open;
  19. using namespace AlibabaCloud::Openanalytics_open::Model;
  20. GetPartitionResult::GetPartitionResult() :
  21. ServiceResult()
  22. {}
  23. GetPartitionResult::GetPartitionResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetPartitionResult::~GetPartitionResult()
  29. {}
  30. void GetPartitionResult::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 partitionModelNode = value["PartitionModel"];
  37. if(!partitionModelNode["TableName"].isNull())
  38. partitionModel_.tableName = partitionModelNode["TableName"].asString();
  39. if(!partitionModelNode["Parameters"].isNull())
  40. partitionModel_.parameters = partitionModelNode["Parameters"].asString();
  41. if(!partitionModelNode["CreateTime"].isNull())
  42. partitionModel_.createTime = std::stol(partitionModelNode["CreateTime"].asString());
  43. if(!partitionModelNode["DbName"].isNull())
  44. partitionModel_.dbName = partitionModelNode["DbName"].asString();
  45. auto storageDescriptorModelNode = partitionModelNode["StorageDescriptorModel"];
  46. if(!storageDescriptorModelNode["Parameters"].isNull())
  47. partitionModel_.storageDescriptorModel.parameters = storageDescriptorModelNode["Parameters"].asString();
  48. if(!storageDescriptorModelNode["InputFormat"].isNull())
  49. partitionModel_.storageDescriptorModel.inputFormat = storageDescriptorModelNode["InputFormat"].asString();
  50. if(!storageDescriptorModelNode["OutputFormat"].isNull())
  51. partitionModel_.storageDescriptorModel.outputFormat = storageDescriptorModelNode["OutputFormat"].asString();
  52. if(!storageDescriptorModelNode["Location"].isNull())
  53. partitionModel_.storageDescriptorModel.location = storageDescriptorModelNode["Location"].asString();
  54. auto allColsNode = storageDescriptorModelNode["Cols"]["FieldSchemaModel"];
  55. for (auto storageDescriptorModelNodeColsFieldSchemaModel : allColsNode)
  56. {
  57. PartitionModel::StorageDescriptorModel::FieldSchemaModel fieldSchemaModelObject;
  58. if(!storageDescriptorModelNodeColsFieldSchemaModel["Comment"].isNull())
  59. fieldSchemaModelObject.comment = storageDescriptorModelNodeColsFieldSchemaModel["Comment"].asString();
  60. if(!storageDescriptorModelNodeColsFieldSchemaModel["Type"].isNull())
  61. fieldSchemaModelObject.type = storageDescriptorModelNodeColsFieldSchemaModel["Type"].asString();
  62. if(!storageDescriptorModelNodeColsFieldSchemaModel["Name"].isNull())
  63. fieldSchemaModelObject.name = storageDescriptorModelNodeColsFieldSchemaModel["Name"].asString();
  64. partitionModel_.storageDescriptorModel.cols.push_back(fieldSchemaModelObject);
  65. }
  66. auto serDeInfoModelNode = storageDescriptorModelNode["SerDeInfoModel"];
  67. if(!serDeInfoModelNode["SerializationLib"].isNull())
  68. partitionModel_.storageDescriptorModel.serDeInfoModel.serializationLib = serDeInfoModelNode["SerializationLib"].asString();
  69. if(!serDeInfoModelNode["Parameters"].isNull())
  70. partitionModel_.storageDescriptorModel.serDeInfoModel.parameters = serDeInfoModelNode["Parameters"].asString();
  71. if(!serDeInfoModelNode["Name"].isNull())
  72. partitionModel_.storageDescriptorModel.serDeInfoModel.name = serDeInfoModelNode["Name"].asString();
  73. auto allValues = partitionModelNode["Values"]["Values"];
  74. for (auto value : allValues)
  75. partitionModel_.values.push_back(value.asString());
  76. if(!value["Message"].isNull())
  77. message_ = value["Message"].asString();
  78. if(!value["Code"].isNull())
  79. code_ = value["Code"].asString();
  80. if(!value["Success"].isNull())
  81. success_ = value["Success"].asString() == "true";
  82. }
  83. std::string GetPartitionResult::getMessage()const
  84. {
  85. return message_;
  86. }
  87. GetPartitionResult::PartitionModel GetPartitionResult::getPartitionModel()const
  88. {
  89. return partitionModel_;
  90. }
  91. std::string GetPartitionResult::getCode()const
  92. {
  93. return code_;
  94. }
  95. bool GetPartitionResult::getSuccess()const
  96. {
  97. return success_;
  98. }