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的结果,对于多线程调用的可用性持怀疑态度。

  • 相关阅读:
    无重复字符的最长子串
    有效的括号
    最长公共前缀
    罗马数字转整数
    Android解析JSON数据异步加载新闻图片
    回文数
    Java从Json获得数据的四种方式
    JavaMD5加密工具类
    div模仿select效果二:带搜索框
    BG雪碧图制作要求
  • 原文地址:https://www.cnblogs.com/end/p/2683815.html
Copyright © 2011-2022 走看看