HIVE Thrift Server使用总结
2012-09-13 18:19
501 查看
因为报表前端用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的结果,对于多线程调用的可用性持怀疑态度。
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的结果,对于多线程调用的可用性持怀疑态度。
相关文章推荐
- hiveserver2 java thrift api 接口使用事例
- Spark SQL读取Hive数据配置及使用Thrift JDBC/ODBC Server访问Spark SQL
- MS SQLSERVER使用问题总结
- ArcGIS Server GP服务使用常见错误总结
- hive使用新的总结
- Hive之 hive的三种使用方式(CLI、HWI、Thrift)
- 有关hive 中默认的用控制符作为分隔符的使用总结
- bigdata_hiveserver2报错_thrift
- Thrift 使用TNonblockingServer模型时调用PosixThreadFactory出错。
- spark基础之Spark SQL和Hive的集成以及ThriftServer配置
- Server 2008 使用总结
- sql server中分布式查询随笔(链接服务器(sp_addlinkedserver)和远程登录映射(sp_addlinkedsrvlogin)使用小总结)
- SparkSQL使用之JDBC代码访问Thrift JDBC Server
- HiveServer2中使用jdbc访问hbase时导致ZooKeeper连接持续增加的解决
- [Spark]Django项目使用Spark(thrift-server)
- Hive Metastore Thrift Server Partition压力测试
- 海洋工作室——网站建设专家:MS Sql Server临时表和游标的使用小总结【转】
- 在java应用中使用JDBC连接Spark SQL(HiveServer2)
- sql server中分布式查询随笔(链接服务器(sp_addlinkedserver)和远程登录映射(sp_addlinkedsrvlogin)使用小总结)
- CDH5 中使用HIVE的问题总结 return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask