HIVE JOIN:http://blog.csdn.net/yfkiss/article/details/8073608
HIVE资料:
一条记录map阶段输出KV,shuffle sort,输出KV,最后reduce输出结果
RCFILE:http://www.csdn.net/article/2011-04-29/296900
http://www.slideshare.net/OReillyStrata/large-scale-etl-with-hadoop
HIVE DDL:https://cwiki.apache.org/Hive/languagemanual-ddl.html
删除带有表的数据库:
DROP DATABASE IF EXISTS db1 CASCADE;
删除空的数据库:
DROP DATABASE IF EXISTS db1 ;
启动hive服务:
hive --service hiveserver
上面的开启服务是针对hive0.9版本的
0.11版本的hive是如下命令:
hive --service hiveserver2(协议不一样)
JDBC链接HIVE:
https://cwiki.apache.org/Hive/hiveclient.html
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager; public class HiveJdbcClient {
private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver"; /**
* @param args
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(1);
}
Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
Statement stmt = con.createStatement();
// String tableName = "testHiveDriverTable";
// stmt.executeQuery("drop table " + tableName);
// ResultSet res = stmt.executeQuery("create table " + tableName + " (key int, value string)");
// show tables
// String sql = "show tables '" + tableName + "'";
// System.out.println("Running: " + sql);
// res = stmt.executeQuery(sql);
// if (res.next()) {
// System.out.println(res.getString(1));
// }
stmt.executeQuery("use etl_sales_db");
// describe table
// sql = "describe " + tableName;
// System.out.println("Running: " + sql);
// res = stmt.executeQuery(sql);
// while (res.next()) {
// System.out.println(res.getString(1) + "\t" + res.getString(2));
// } // load data into table
// NOTE: filepath has to be local to the hive server
// NOTE: /tmp/a.txt is a ctrl-A separated file with two fields per line
/* String filepath = "/tmp/a.txt";
sql = "load data local inpath '" + filepath + "' into table " + tableName;
System.out.println("Running: " + sql);
res = stmt.executeQuery(sql); */ // select * query
String sql = "select count(*) from " + "item";
System.out.println("Running: " + sql);
ResultSet res = stmt.executeQuery(sql);
// while (res.next()) {
// System.out.println(String.valueOf(res.getInt(1)) + "\t" + res.getString(2));
// }
if (res.next()) {
System.out.println(res.getString(1));
} // regular hive query
// sql = "select count(1) from " + tableName;
// System.out.println("Running: " + sql);
// res = stmt.executeQuery(sql);
// while (res.next()) {
// System.out.println(res.getString(1));
// }
}
}