You can use non-Java languages such as C++, Python, and Go to access ApsaraDB for Lindorm wide tables if Thrift supports these languages. The ApsaraDB for Lindorm server supports Thrift version 0.12.0. Although Thrift is backward compatible, we recommend that you download the version 0.12.0. Click thrift to download this version. Some languages provide specific methods to manage dependencies. You can install Thrift based on relevant syntax. For example, you can run the pip install thrift command if you use Python and run the import {"github.com/apache/thrift/lib/go/thrift"} command if you use Go.

ApsaraDB for Lindorm wide tables use Thrift 2 as the interface definition language (IDL) file. You must download the Thrift 2 to generate the API for the specified language. Compared with Thrift 1, Thrift 2 provides clearer definitions for API operations. You can perform the operations in a similar way as you call Java API operations. The earlier versions of Thrift 2 are not widely used because they do not support some data definition language (DDL) operations such as creating and deleting tables. The Thrift 2 API definitions have been provided by Alibaba Cloud and released to the community. For more information, see HBASE-21649. Thrift 2 provides more comprehensive and easy-to-use features than Thrift 1.


  1. Click thrift to download the Thrift installation package.
  2. Download the Thrift 2 definition file of HBase.


The following sections describe how to get started with Thrift. For more information, see Apache Thrift Tutorial.

  1. Generate the interface definition file for the specified programming language.
    Download the interface definition file and use the following syntax to generate the corresponding interface definition files.
    thrift --gen <language> Hbase.thrift
    1. thrift --gen php Hbase.thrift
    2. thrift --gen cpp Hbase.thrift
    3. thrift --gen py Hbase.thrift
  2. Initialize a client to access ApsaraDB for Lindorm
    The Thrift server of ApsaraDB for Lindorm uses HTTP in the transport layer. Therefore, the ThttpClient of Thrift is required when you initialize a client. The client initialization method varies based on the languages. When the Access Control List (ACL) is enabled, you must specify the username and password headers in the ThttpClient for authentication. The username and password are not required if ACL is disabled. Thrift allows you to call a function for a language to customize a header in ThttpClient. The following example shows how to initialize the client and set the connection string, username, and password based on Python. For more information, see the Demos for multiple languages section in this topic.
    1.  # -*- coding: utf-8  -*-
    2.  # You can run the pip install thrift command to retrieve the following modules.
    3.  from thrift.protocol import TBinaryProtocol
    4.  from thrift.transport import THttpClient
    6.  # The following module is generated by the thrift --gen py hbase.thrift command.
    7.  from hbase import THBaseService
    8.  from hbase.ttypes import TColumnValue, TColumn, TTableName, TTableDescriptor, TColumnFamilyDescriptor, TNamespaceDescriptor, TGet, TPut, TScan
    10. # The endpoint of the ApsaraDB for Lindorm instance.
    11. url = "http://host:9190"
    12. transport = THttpClient.THttpClient(url)
    13. headers = {}
    14. # The username that is used to access the ApsaraDB for Lindorm instance.
    15. headers["ACCESSKEYID"]="root";
    16. # The password that is used to access the ApsaraDB for Lindorm instance.
    17. headers["ACCESSSIGNATURE"]="root"
    18. transport.setCustomHeaders(headers)
    19. protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport)
    20. client = THBaseService.Client(protocol)
    21. transport.open()
    22. # The operations. The connection is finally closed.
    23. transport.close()

Demos for multiple languages

All the demo code has been uploaded to GitHub. The code includes the Thrift definition files and dependencies that are supported by some languages. You can download the code for a language from Github.

More languages

For more information, see Apache Thrift Tutorial.