concept string in category apache thrift

appears as: string, string, strings, The string
Programmer's Guide to Apache Thrift

This is an excerpt from Manning's book Programmer's Guide to Apache Thrift.

Our hello.thrift IDL file declares a single service interface called HelloSvc 1 with a single function, hello_func() 2. The function accepts no parameters and returns a string. To use this interface we can compile it with the Apache Thrift IDL compiler. The IDL compiler binary is named “thrift” on UNIX-like systems and “thrift.exe” on Windows. The compiler expects two command line arguments, an IDL file to compile and one (or more) target languages to generate code for. Here’s an example session that generates Python stubs for HelloSvc:

To get an understanding of protocols from the C++ perspective, we’ll build a simple Apache Thrift C++ program to serialize a string, as shown in the following listing.

  • Protocols support the serialization of
    • RPC messages
    • Structs
    • Collections—List, set, and map
    • Base types—Ints, doubles, strings, and so on
  • Listing 6.2. ~/ThriftBook/part2/IDL/literals.thrift
      const bool b0 = 0          //same as false      #1
      const bool b1 = 1          //same as true
      const bool b2 = false
      const bool b3 = true
    
      const i8 i1 = 42      #2
      const i16 i2 = -42
      const i32 i3 = +42
      const i64 i4 = 0x4f//Hex (lower case x only)
      const i64 i5 = 0x4F
      const i64 i6 = 042//Decimal 42(!), no octal support
      const i32 i7 =i6//A const can be initialized with another const
    
      const double d1 = 123.456    #3
      const double d2 = -123.456
      const double d3 = 123.456e6
      const double d4 = -123.456E-6 //Expressions (e.g. 4.5/7.2) not supported
      const double d5 = +123.456e+6
    
      const string s1 = "hello"         #4
      const string s2 = 'hello'
      const string s3 = "\"Thrift\\hello\tworld\'\r\n" //6 escape sequences
      const binary s4 = 'hello world\n'  //Binaries are initialized like strings