Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
thrift-enc-test.cc
Go to the documentation of this file.
1 #include "common/logging.h"
2 #include "rpc/thrift-util.h"
3 
4 #include <vector>
5 
6 #include "gen-cpp/Types_types.h"
7 
8 using namespace impala;
9 using namespace std;
10 
11 int main(int argc, char** argv) {
12  google::InitGoogleLogging(argv[0]);
13  LOG(INFO) << "Hello world";
14 
15  ThriftSerializer s(false);
16  TColumnType tpe;
17  vector<uint8_t> result;
18  s.Serialize(&tpe, &result);
19  LOG(INFO) << "One TTypeNode: " << result.size() << " bytes";
20 
21  tpe.__set_types(vector<TTypeNode>());
22  s.Serialize(&tpe, &result);
23  LOG(INFO) << "One TTypeNode (with empty types vector: " << result.size() << " bytes";
24 
25  TTypeNode node;
26  node.__set_scalar_type(TScalarType());
27  tpe.types.push_back(node);
28  s.Serialize(&tpe, &result);
29  LOG(INFO) << "One TTypeNode (with one-entry types vector: " << result.size() << " bytes";
30 
31  TColumnType tpe2;
32  tpe2.__set_scalar_type(TScalarType());
33  s.Serialize(&tpe2, &result);
34  LOG(INFO) << "One TTypeNode (with a dedicated scalar type): " << result.size() << " bytes";
35 
36  TScalarType sct;
37  s.Serialize(&sct, &result);
38  LOG(INFO) << "Sizeof scalar type: " << result.size() << " bytes";
39 
40 }
int main(int argc, char **argv)
Status Serialize(T *obj, std::vector< uint8_t > *result)
Serializes obj into result. Result will contain a copy of the memory.
Definition: thrift-util.h:48