Impala thrift API接口使用事例

本文通过代码示例介绍了Impala的Thrift API接口使用,但指出该接口不支持异步查询。同时提到,基于HiveServer2的接口能够支持异步查询,只需对代码进行相应修改。
摘要由CSDN通过智能技术生成

直接看代码

        public void impalaQuery() throws Exception {
		TSocket transport = new TSocket("10.17.36.93", 21000);
		transport.open();
		TProtocol protocol = new TBinaryProtocol(transport);
		// connect to client
		ImpalaService.Client client = new ImpalaService.Client(protocol);
		client.PingImpalaService();
		// send the query
		Query query = new Query(); 

		query.setQuery("SELECT * FROM wux_test_10000 limit 1000");
		// fetch the results

		client.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("获取日志"
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值