博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
clientcontainerThrift Types
阅读量:4638 次
发布时间:2019-06-09

本文共 4252 字,大约阅读时间需要 14 分钟。

首先声明,我是一个菜鸟。一下文章中出现技术误导情况盖不负责

    来自Apache Thrift官网:

    

Thrift Types

    

The Thrift type system is intended to allow programmers to use native types as much as possible, no matter what programming language they are working in. This information is based on, and supersedes, the information in the . The  provides descriptions of the types which are used to generate code for each target language.

    

Base Types

    

The base types were selected with the goal of simplicity and clarity rather than abundance, focusing on the key types available in all programming languages.

    

  • bool: A boolean value (true or false)
  • byte: An 8-bit signed integer
  • i16: A 16-bit signed integer
  • i32: A 32-bit signed integer
  • i64: A 64-bit signed integer
  • double: A 64-bit floating point number
  • string: A text string encoded using UTF-8 encoding

    

Note the absence of unsigned integer types. This is due to the fact that there are no native unsigned integer types in many programming languages.

    

Special Types

    

binary: a sequence of unencoded bytes

    

N.B.: This is currently a specialized form of the string type above, added to provide better interoperability with Java. The current plan-of-record is to elevate this to a base type at some point.

    

Structs

    

Thrift structs define a common object – they are essentially equivalent to classes in OOP languages, but without inheritance. A struct has a set of strongly typed fields, each with a unique name identifier. Fields may have various annotations (numeric field IDs, optional default values, etc.) that are described in the .

    

Containers

    每日一道理
青春是用意志的血滴和拼搏的汗水酿成的琼浆——历久弥香;青春是用不凋的希望和不灭的向往编织的彩虹——绚丽辉煌;青春是用永恒的执著和顽强的韧劲筑起的一道铜墙铁壁——固若金汤。

    

Thrift containers are strongly typed containers that map to commonly used and commonly available container types in most programming languages.

    

There are three container types:

    

list: An ordered list of elements. Translates to an STL vector, Java ArrayList, native arrays in scripting languages, etc. set: An unordered set of unique elements. Translates to an STL set, Java HashSet, set in Python, etc. Note: PHP does not support sets, so it is treated similar to a List map: A map of strictly unique keys to values. Translates to an STL map, Java HashMap, PHP associative array, Python/Ruby dictionary, etc. While defaults are provided, the type mappings are not explicitly fixed. Custom code generator directives have been added to allow substitution of custom types in various destination languages.

    

Container elements may be of any valid Thrift Type.

    

N.B.: For maximal compatibility, the key type for map should be a basic type rather than a struct or container type. There are some languages which do not support more complex key types in their native map types. In addition the JSON protocol only supports key types that are base types.

    

Exceptions

    

Exceptions are functionally equivalent to structs, except that they inherit from the native exception base class as appropriate in each target programming language, in order to seamlessly integrate with the native exception handling in any given language.

    

Services

    

Services are defined using Thrift types. Definition of a service is semantically equivalent to defining an interface (or a pure virtual abstract class) in object oriented programming. The Thrift compiler generates fully functional client and server stubs that implement the interface.

    

A service consists of a set of named functions, each with a list of parameters and a return type.

    

Note that void is a valid type for a function return, in addition to all other defined Thrift types. Additionally, an async modifier keyword may be added to a void function, which will generate code that does not wait for a response. Note that a pure void function will return a response to the client which guarantees that the operation has completed on the server side. With async method calls the client will only be guaranteed that the request succeeded at the transport layer. Async method calls of the same client may be executed in parallel/out of order by the server.

文章结束给大家分享下程序员的一些笑话语录: 问:你觉得让你女朋友(或者任何一个女的)从你和李彦宏之间选一个,你觉得她会选谁?  

  答:因为李艳红这种败类,所以我没女友!

--------------------------------- 原创文章 By

client和container
---------------------------------

转载于:https://www.cnblogs.com/jiangu66/archive/2013/05/24/3098111.html

你可能感兴趣的文章
通过注入DLL后使用热补丁钩取API
查看>>
欧拉筛(线性筛)
查看>>
C 语言指针怎么理解
查看>>
Go基础1
查看>>
删除数据库所有表数据
查看>>
kali下搭建WiFi钓鱼热点
查看>>
【Java】 剑指offer(32) 从上往下打印二叉树
查看>>
二十三、连接mysql数据库,创建用户模型
查看>>
leetcode--844:(队列类)比较含退格的字符串
查看>>
判断字符串是否全为空格和去掉字符串中的空格
查看>>
OO第一阶段纪实
查看>>
实验二
查看>>
ASP.NET Web API 2系列(一):初识Web API及手动搭建基本框架
查看>>
抄袭的用Jsp+JavaBean+Mysql实现的登录和注册
查看>>
jquery显示隐藏操作
查看>>
还是畅通工程(hdu1233)并查集应用
查看>>
导入.sql文件入数据库
查看>>
I/O模型
查看>>
EMQ --集成搭建
查看>>
对poi-Excel导入的浅层理解
查看>>