|
@@ -1,5 +1,7 @@
|
|
|
package com.winhc.bigdata.spark.utils
|
|
|
|
|
|
+import java.util.Properties
|
|
|
+
|
|
|
import com.winhc.bigdata.spark.utils.BaseUtil.isWindows
|
|
|
|
|
|
/**
|
|
@@ -8,7 +10,22 @@ import com.winhc.bigdata.spark.utils.BaseUtil.isWindows
|
|
|
* @Description:
|
|
|
*/
|
|
|
object PhoenixUtil {
|
|
|
- def getPhoenixUrl: String = {
|
|
|
+ private val DB_PHOENIX_DRIVER = "org.apache.phoenix.queryserver.client.Driver"
|
|
|
+ private val DB_PHOENIX_USER = ""
|
|
|
+ private val DB_PHOENIX_PASS = ""
|
|
|
+ private val DB_PHOENIX_FETCHSIZE = "10000"
|
|
|
+
|
|
|
+ def getPhoenixProperties: Properties = {
|
|
|
+ val connProp = new Properties
|
|
|
+ connProp.put("driver", DB_PHOENIX_DRIVER)
|
|
|
+ connProp.put("user", DB_PHOENIX_USER)
|
|
|
+ connProp.put("password", DB_PHOENIX_PASS)
|
|
|
+ connProp.put("fetchsize", DB_PHOENIX_FETCHSIZE)
|
|
|
+ connProp
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ def getPhoenixJDBCUrl: String = {
|
|
|
var queryServerAddress: String = null
|
|
|
if (isWindows) {
|
|
|
queryServerAddress = "http://hb-proxy-pub-uf6as8i6h85k02092-001.hbase.rds.aliyuncs.com:8765"
|
|
@@ -19,12 +36,12 @@ object PhoenixUtil {
|
|
|
url
|
|
|
}
|
|
|
|
|
|
- def getPhoenixTempView(tempViewTableName: String, phoenixTableName: String, fetchsize: Int = 100): String =
|
|
|
+ def getPhoenixTempView(tempViewTableName: String, phoenixTableName: String, fetchsize: Int = 1000): String =
|
|
|
s"""
|
|
|
|CREATE TABLE $tempViewTableName USING org.apache.spark.sql.jdbc
|
|
|
|OPTIONS (
|
|
|
| 'driver' 'org.apache.phoenix.queryserver.client.Driver',
|
|
|
- | 'url' '${getPhoenixUrl}',
|
|
|
+ | 'url' '${getPhoenixJDBCUrl}',
|
|
|
| 'dbtable' '$phoenixTableName',
|
|
|
| 'fetchsize' '$fetchsize'
|
|
|
|)
|