zoukankan      html  css  js  c++  java
  • HIVE Thrift Server使用总结

    因为报表前端用dot NET MVC写的,要想从HIVE中获取详细数据,目前的方案是使用hive thriftserver。

    1. 生成HIVE Thrift对应的C#类文件

    遇到的问题是找不到thriftserver.thrift中引用的fb303.thrift文件。解决方案:从thrift源码目录中复制一份过来。然后利用thriftserver.thrift生成了4个类文件,复制到项目中编译报错,不得不将引用的其他三个文件分别利用thrift生成C#类,最后将几十个类文件复制到项目中,修改项目属性,将framework 4 client profile修改为framework 4,编译通过。

    client代码如下:

    static void Main(string[] args)
            {
                TTransport transport = new TSocket("192.168.1.1"10000);
                TProtocol protocol = new TBinaryProtocol(transport);
                ThriftHive.Client client = new ThriftHive.Client(protocol);

                transport.Open();
                //client.execute("add file /data/home/script/ad_resolve2.py;");
                client.execute("select * from web_pv_log_detail3 where dt = '2012-09-10' limit 10");
                Console.WriteLine("the result is:");

                
                var items = client.fetchAll();
                foreach (var item in items)
                {
                    Console.WriteLine(item);
                }
                transport.Close();

                Console.ReadLine();
            }

    2. 启动服务端服务:

    hive --service hiveserver

    3. 测试。发现多次调用execute之后调用fetch,每次会获取到最后一个execute的结果,对于多线程调用的可用性持怀疑态度。

  • 相关阅读:
    Spring shiro学习(二)
    Spring shiro学习(一)
    Redis/zookeeper/ActiveMQ在Mac下的安装配置
    Mac下利用brew安装Intellij IDEA
    MySQL服务相关
    Ruby变量常量
    Web性能测试工具:Siege安装&使用简介
    无限级分类功能实践
    Ubuntu Bash and Dash
    安装好的虚拟机,外部通过ssh工具连接,报connection failed
  • 原文地址:https://www.cnblogs.com/end/p/2683815.html
Copyright © 2011-2022 走看看