Impala thrift API接口使用事例
来源:互联网 发布:windows键是哪个键 编辑:程序博客网 时间:2024/06/10 14:43
直接看代码
public void impalaQuery() throws Exception {TSocket transport = new TSocket("10.17.36.93", 21000);transport.open();TProtocol protocol = new TBinaryProtocol(transport);// connect to clientImpalaService.Client client = new ImpalaService.Client(protocol);client.PingImpalaService();// send the queryQuery query = new Query(); query.setQuery("SELECT * FROM wux_test_10000 limit 1000");// fetch the resultsclient.send_query(query); queryHandle = client.recv_query();String log = client.get_log(queryHandle.getLog_context());System.out.println(log);//查询结果Results results = client.fetch(queryHandle, false, 5);List<String> data = results.data;for (int i = 0; i < data.size(); i++) {System.out.println(data.get(i));}}public void impalaGetLog() throws Exception {System.out.println("获取日志");TSocket transport = new TSocket(host, port);transport.open();TProtocol protocol = new TBinaryProtocol(transport);// connect to clientImpalaService.Client client = new ImpalaService.Client(protocol);client.PingImpalaService();String log = client.get_log(queryHandle.getLog_context());System.out.println(log);}public void impalaGetStatu() throws Exception {System.out.println("获取状态:");TSocket transport = new TSocket(host, port);transport.open();TProtocol protocol = new TBinaryProtocol(transport);// connect to clientImpalaService.Client client = new ImpalaService.Client(protocol);client.PingImpalaService();QueryState qs = client.get_state(queryHandle);System.out.println(qs);}public void canel() throws Exception {TSocket transport = new TSocket(host, port);transport.open();TProtocol protocol = new TBinaryProtocol(transport);// connect to clientImpalaService.Client client = new ImpalaService.Client(protocol);client.PingImpalaService();TStatus ts = client.Cancel(queryHandle);System.out.println(ts);}
以上代码是impala自己的thrift接口,但是这套接口有个问题,就是不支持异步查询,而另外一套是基于hiveserver2的,可以支持异步查询,只要修改以下代码就行
TCLIService.Client client = new ImpalaHiveServer2Service.Client(protocol);
这样就可以用hiveserver2的api来操作impala了
0 0
- Impala thrift API接口使用事例
- hiveserver2 java thrift api 接口使用事例
- API登录接口文档事例
- Impala实践之六:使用Rest Api
- 手机话费充值API事例_话费接口DEMO
- 使用Thrift API监控Storm集群
- 通过Python使用HBase Thrift接口 url
- impala使用
- 012_Eclipse中使用 HDFS URL API 事例介绍
- Impala Rest Api
- 编写接口事例
- NC65接口事例
- 短信平台接口事例
- 使用Thrift API监控Storm集群和Topology
- 使用Thrift API监控Storm集群和Topology
- 使用Thrift API监控Storm集群和Topology
- 使用Python通过Thrift接口访问HBase和Hive
- 在Azure HDInsight HBase集群中使用Thrift接口
- Core Animation 编程指南
- 播放剪短音频
- IOS 获取应用程序的路径
- wake up alarm
- 减小App包的大小
- Impala thrift API接口使用事例
- 理解产品、交互和运营
- 图片上传和显示
- Android中EditText的设置02
- 照猫画虎学gnuplot之简介
- ant入门
- Practical Difference between Const & ReadOnly
- android导入项目常见问题解决
- epoll、select、poll比较及其epoll的实现原理