1818#include  " presto_cpp/main/common/tests/test_json.h" 
1919#include  " presto_cpp/main/connectors/PrestoToVeloxConnector.h" 
2020
21- using  namespace  facebook ; 
22- using  namespace  facebook ::presto::protocol; 
21+ using  namespace  facebook ::presto; 
2322
24- class  TaskInfoTest  : public ::testing::Test {};
23+ class  TaskInfoTest  : public ::testing::Test {
24+   protected: 
25+   void  SetUp () override  {
26+     registerPrestoToVeloxConnector (
27+         std::make_unique<facebook::presto::HivePrestoToVeloxConnector>(" hive" 
28+   }
29+ 
30+   void  TearDown () override  {
31+     unregisterPrestoToVeloxConnector (" hive" 
32+   }
33+ };
2534
2635const  std::string BASE_DATA_PATH = " /github/presto-trunk/presto-native-execution/presto_cpp/main/tests/data/" 
2736
2837TEST_F (TaskInfoTest, duration) {
2938  double  thrift = 0 ;
30-   facebook::presto:: thrift::toThriftDuration (123 , TimeUnit::MILLISECONDS), thrift);
39+   thrift::toThrift (protocol:: Duration123 , protocol:: TimeUnit::MILLISECONDS), thrift);
3140  ASSERT_EQ (thrift, 123 );
3241}
3342
3443TEST_F (TaskInfoTest, binaryMetadataUpdates) {
3544  std::string str = slurp (getDataPath (BASE_DATA_PATH, " MetadataUpdates.json" 
3645  json j = json::parse (str);
37-   registerPrestoToVeloxConnector (std::make_unique<facebook::presto::HivePrestoToVeloxConnector>(" hive" 
38-   MetadataUpdates metadataUpdates = j;
46+   protocol::MetadataUpdates metadataUpdates = j;
3947  std::unique_ptr<std::string> thriftMetadataUpdates = std::make_unique<std::string>();
40-   facebook::presto:: thrift::toThrift
48+   thrift::toThrift (metadataUpdates, *thriftMetadataUpdates);
4149
4250  json thriftJson = json::parse (*thriftMetadataUpdates);
4351  ASSERT_EQ (j, thriftJson);
44- 
45-   presto::unregisterPrestoToVeloxConnector (" hive" 
4652}
4753
4854TEST_F (TaskInfoTest, taskInfo) {
4955  std::string str = slurp (getDataPath (BASE_DATA_PATH, " TaskInfo.json" 
5056  json j = json::parse (str);
51-   registerPrestoToVeloxConnector (std::make_unique<facebook::presto::HivePrestoToVeloxConnector>(" hive" 
52-   TaskInfo taskInfo = j;
53-   facebook::presto::thrift::TaskInfo thriftTaskInfo;
54-   facebook::presto::thrift::toThrift (taskInfo, thriftTaskInfo);
57+   protocol::TaskInfo taskInfo = j;
58+   thrift::TaskInfo thriftTaskInfo;
59+   thrift::toThrift (taskInfo, thriftTaskInfo);
5560
5661  json thriftJson = json::parse (*thriftTaskInfo.metadataUpdates ()->metadataUpdates ());
5762  ASSERT_EQ (taskInfo.metadataUpdates , thriftJson);
5863  ASSERT_EQ (thriftTaskInfo.needsPlan (), false );
5964  ASSERT_EQ (thriftTaskInfo.outputBuffers ()->buffers ()->size (), 2 );
6065  ASSERT_EQ (thriftTaskInfo.outputBuffers ()->buffers ()[0 ].bufferId ()->id (), 100 );
6166  ASSERT_EQ (thriftTaskInfo.outputBuffers ()->buffers ()[1 ].bufferId ()->id (), 200 );
62-   ASSERT_EQ (thriftTaskInfo.stats ()->blockedReasons ()->count (facebook::presto:: thrift::BlockedReason::WAITING_FOR_MEMORY), 1 );
67+   ASSERT_EQ (thriftTaskInfo.stats ()->blockedReasons ()->count (thrift::BlockedReason::WAITING_FOR_MEMORY), 1 );
6368  ASSERT_EQ (thriftTaskInfo.stats ()->runtimeStats ()->metrics ()->size (), 2 );
6469  ASSERT_EQ (thriftTaskInfo.stats ()->runtimeStats ()->metrics ()[" test_metric1" sum (), 123 );
6570  ASSERT_EQ (thriftTaskInfo.stats ()->runtimeStats ()->metrics ()[" test_metric2" name (), " test_metric2" 
66- 
67-   presto::unregisterPrestoToVeloxConnector (" hive" 
6871}
6972
7073TEST_F (TaskInfoTest, taskId) {
71-   TaskId taskId = " queryId.1.2.3.4" 
72-   facebook::presto:: thrift::TaskId thriftTaskId;
73-   facebook::presto:: thrift::toThrift
74+   protocol:: TaskId taskId = " queryId.1.2.3.4" 
75+   thrift::TaskId thriftTaskId;
76+   thrift::toThrift (taskId, thriftTaskId);
7477
7578  ASSERT_EQ (thriftTaskId.stageExecutionId ()->stageId ()->queryId (), " queryId" 
7679  ASSERT_EQ (thriftTaskId.stageExecutionId ()->stageId ()->id (), 1 );
@@ -83,9 +86,9 @@ TEST_F(TaskInfoTest, taskId) {
8386TEST_F (TaskInfoTest, operatorStatsEmptyBlockedReason) {
8487  std::string str = slurp (getDataPath (BASE_DATA_PATH, " OperatorStatsEmptyBlockedReason.json" 
8588  json j = json::parse (str);
86-   OperatorStats operatorStats = j;
87-   facebook::presto:: thrift::OperatorStats thriftOperatorStats;
88-   facebook::presto:: thrift::toThrift
89+   protocol:: OperatorStats operatorStats = j;
90+   thrift::OperatorStats thriftOperatorStats;
91+   thrift::toThrift (operatorStats, thriftOperatorStats);
8992
9093  ASSERT_EQ (thriftOperatorStats.blockedReason ().has_value (), false );
9194  ASSERT_EQ (thriftOperatorStats.blockedWall (), 80 );
@@ -95,9 +98,9 @@ TEST_F(TaskInfoTest, operatorStatsEmptyBlockedReason) {
9598TEST_F (TaskInfoTest, operatorStats) {
9699  std::string str = slurp (getDataPath (BASE_DATA_PATH, " OperatorStats.json" 
97100  json j = json::parse (str);
98-   OperatorStats operatorStats = j;
99-   facebook::presto:: thrift::OperatorStats thriftOperatorStats;
100-   facebook::presto:: thrift::toThrift
101+   protocol:: OperatorStats operatorStats = j;
102+   thrift::OperatorStats thriftOperatorStats;
103+   thrift::toThrift (operatorStats, thriftOperatorStats);
101104
102-   ASSERT_EQ (thriftOperatorStats.blockedReason (), facebook::presto:: thrift::BlockedReason::WAITING_FOR_MEMORY);
105+   ASSERT_EQ (thriftOperatorStats.blockedReason (), thrift::BlockedReason::WAITING_FOR_MEMORY);
103106}
0 commit comments