HiveContext hv=new HiveContext (sc);
DataFrame data=https://bbs.csdn.net/topics/hv.sql (" select * from url_pending limit 10 ");
The data show (2);
Data. ToJavaRDD (.) foreachPartition (new VoidFunction
@ Override
Public void call (Iterator
The Row Row;
The Configuration conf=conf=HBaseConfiguration. The create ();
Conf. Set (" hbase. Rootdir ", "hdfs://archive.cloudera.com: 9000/hbase");
Zookeeper. Znode. Conf. Set (" parent ", "/hbase");
The conf. Set (" hbase. Zookeeper. Quorum ", "GDLT10471");
HConnection connection;
Try {
The connection=HConnectionManager. The createConnection (conf);
HTableInterface table=connection. GetTable (" url_matched ");
Table. SetAutoFlush (true);
List
Put the Put;
While (rows. HasNext ()) {
The row=rows. The next ();
Put=new put (Bytes. ToBytes (UUID. RandomUUID (), toString ()));
The String url=row. Get String (0);
Put the add (Bytes. ToBytes (" baseData "), Bytes. ToBytes (" url "), Bytes. ToBytes (url));
Put. The add (Bytes. ToBytes (" baseData "), Bytes. ToBytes (" phone "), Bytes. ToBytes (row. Get string (1)));
System. The out. Println (" URL: "+ row. Get string (0) +" phone: "+ row. Get string (1));
List. Add (put);
}
Table. The put (list);
Table. The close ();
} the catch (IOException e) {
//TODO Auto - generated the catch block,
e.printStackTrace();
}
}
});