Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mobvista-dmp
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王金锋
mobvista-dmp
Commits
8c7555e2
Commit
8c7555e2
authored
Nov 02, 2021
by
WangJinfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix dmp_install_list
parent
ba8366b1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
10 deletions
+39
-10
CommonInstallListOrc.scala
...main/scala/mobvista/dmp/common/CommonInstallListOrc.scala
+20
-3
InstallListDailyV2.scala
src/main/scala/mobvista/dmp/common/InstallListDailyV2.scala
+11
-5
MobvistaConstant.scala
src/main/scala/mobvista/dmp/common/MobvistaConstant.scala
+2
-0
Constant.scala
src/main/scala/mobvista/dmp/datasource/dm/Constant.scala
+6
-2
No files found.
src/main/scala/mobvista/dmp/common/CommonInstallListOrc.scala
View file @
8c7555e2
...
@@ -138,7 +138,19 @@ abstract class CommonInstallListOrc extends CommonSparkJob with Serializable {
...
@@ -138,7 +138,19 @@ abstract class CommonInstallListOrc extends CommonSparkJob with Serializable {
if
(
dailyOpt
.
isEmpty
&&
totalOpt
.
isDefined
)
{
if
(
dailyOpt
.
isEmpty
&&
totalOpt
.
isDefined
)
{
val
installListDate
=
MRUtils
.
SPLITTER
.
split
(
totalOpt
.
get
,
-
1
)
val
installListDate
=
MRUtils
.
SPLITTER
.
split
(
totalOpt
.
get
,
-
1
)
pkgs
=
installListDate
(
0
)
pkgs
=
installListDate
(
0
)
ext_data
=
installListDate
(
1
)
val
old_ext_data_json
=
JSON
.
parseObject
(
installListDate
(
1
))
val
region_list
=
if
(
old_ext_data_json
.
containsKey
(
"region"
))
{
JSON
.
parseArray
(
old_ext_data_json
.
getString
(
"region"
),
classOf
[
String
])
/*
.filter(r => {
MobvistaConstant.regionSet.contains(r)
}).asJava
*/
}
else
{
new
util
.
ArrayList
[
String
]()
}
old_ext_data_json
.
put
(
"region"
,
new
util
.
HashSet
(
region_list
))
ext_data
=
old_ext_data_json
.
toJSONString
updateDate
=
installListDate
(
2
)
updateDate
=
installListDate
(
2
)
country
=
installListDate
(
3
)
country
=
installListDate
(
3
)
}
else
if
(
dailyOpt
.
isDefined
&&
totalOpt
.
isEmpty
)
{
}
else
if
(
dailyOpt
.
isDefined
&&
totalOpt
.
isEmpty
)
{
...
@@ -205,12 +217,17 @@ abstract class CommonInstallListOrc extends CommonSparkJob with Serializable {
...
@@ -205,12 +217,17 @@ abstract class CommonInstallListOrc extends CommonSparkJob with Serializable {
}
}
val
region_list
=
if
(
old_ext_data_json
.
containsKey
(
"region"
))
{
val
region_list
=
if
(
old_ext_data_json
.
containsKey
(
"region"
))
{
JSON
.
parseArray
(
old_ext_data_json
.
getString
(
"region"
),
classOf
[
String
])
JSON
.
parseArray
(
old_ext_data_json
.
getString
(
"region"
),
classOf
[
String
])
/*
.filter(r => {
MobvistaConstant.regionSet.contains(r)
}).asJava
*/
}
else
{
}
else
{
new
util
.
ArrayList
[
String
]()
new
util
.
ArrayList
[
String
]()
}
}
if
(
daily_ext_data_json
.
containsKey
(
"region"
))
{
if
(
daily_ext_data_json
.
containsKey
(
"region"
))
{
ext_data
_list
.
addAll
(
JSON
.
parseArray
(
daily_ext_data_json
.
getString
(
"region"
),
classOf
[
String
]))
region
_list
.
addAll
(
JSON
.
parseArray
(
daily_ext_data_json
.
getString
(
"region"
),
classOf
[
String
]))
old_ext_data_json
.
put
(
"region"
,
new
util
.
HashSet
(
ext_data
_list
))
old_ext_data_json
.
put
(
"region"
,
new
util
.
HashSet
(
region
_list
))
}
}
ext_data
=
old_ext_data_json
.
toJSONString
ext_data
=
old_ext_data_json
.
toJSONString
...
...
src/main/scala/mobvista/dmp/common/InstallListDailyV2.scala
View file @
8c7555e2
package
mobvista.dmp.common
package
mobvista.dmp.common
import
java.net.URI
import
com.alibaba.fastjson.JSONObject
import
com.alibaba.fastjson.JSONObject
import
mobvista.dmp.util.DateUtil
import
mobvista.dmp.util.DateUtil
import
org.apache.commons.cli.
{
BasicParser
,
Options
}
import
org.apache.commons.cli.
{
BasicParser
,
Options
}
import
org.apache.hadoop.fs.
{
FileSystem
,
Path
}
import
org.apache.hadoop.fs.
{
FileSystem
,
Path
}
import
org.apache.spark.sql.
{
SaveMode
,
SparkSession
}
import
org.apache.spark.sql.
{
SaveMode
,
SparkSession
}
import
java.net.URI
import
scala.collection.mutable
import
scala.collection.mutable
/**
/**
...
@@ -65,10 +64,12 @@ class InstallListDailyV2 extends CommonSparkJob with Serializable {
...
@@ -65,10 +64,12 @@ class InstallListDailyV2 extends CommonSparkJob with Serializable {
activeDev
.
createOrReplaceTempView
(
"active_dev"
)
activeDev
.
createOrReplaceTempView
(
"active_dev"
)
spark
.
udf
.
register
(
"merge"
,
merge
_
)
spark
.
udf
.
register
(
"merge"
,
merge
_
)
spark
.
udf
.
register
(
"filterInstall"
,
filterInstall
_
)
spark
.
udf
.
register
(
"udf_mergeExtData"
,
mobvista
.
dmp
.
datasource
.
dm
.
Constant
.
mergeExtData
_
)
spark
.
udf
.
register
(
"udf_mergeExtData"
,
mobvista
.
dmp
.
datasource
.
dm
.
Constant
.
mergeExtData
_
)
sql
=
sql
.
replace
(
"@date"
,
date
).
replace
(
"@before_date"
,
before_date
)
sql
=
sql
.
replace
(
"@date"
,
date
).
replace
(
"@before_date"
,
before_date
)
val
df
=
spark
.
sql
(
sql
).
filter
(
val
df
=
spark
.
sql
(
sql
)
"filterInstall(install_list)"
)
df
.
repartition
(
coalesce
.
toInt
)
df
.
repartition
(
coalesce
.
toInt
)
.
write
.
write
.
mode
(
SaveMode
.
Overwrite
)
.
mode
(
SaveMode
.
Overwrite
)
...
@@ -126,12 +127,17 @@ class InstallListDailyV2 extends CommonSparkJob with Serializable {
...
@@ -126,12 +127,17 @@ class InstallListDailyV2 extends CommonSparkJob with Serializable {
val
installJSONObject
=
new
JSONObject
val
installJSONObject
=
new
JSONObject
installList
.
iterator
.
foreach
(
install
=>
{
installList
.
iterator
.
foreach
(
install
=>
{
val
installMap
=
MobvistaConstant
.
String2JSONObject
(
install
).
asInstanceOf
[
java.util.Map
[
String
,
String
]].
asScala
val
installMap
=
MobvistaConstant
.
String2JSONObject
(
install
).
asInstanceOf
[
java.util.Map
[
String
,
String
]].
asScala
installMap
.
retain
((
k
,
v
)
=>
!
installJSONObject
.
containsKey
(
k
)
||
installJSONObject
.
getString
(
k
).
compareTo
(
v
)
<
0
).
foreach
(
kv
=>
{
installMap
.
retain
((
k
,
v
)
=>
(!
installJSONObject
.
containsKey
(
k
)
||
installJSONObject
.
getString
(
k
).
compareTo
(
v
)
<
0
)
&&
!
k
.
equalsIgnoreCase
(
"0000000000"
)
&&
!
k
.
equalsIgnoreCase
(
"com.nonepkg.nonepkg"
)).
foreach
(
kv
=>
{
installJSONObject
.
put
(
kv
.
_1
,
kv
.
_2
)
installJSONObject
.
put
(
kv
.
_1
,
kv
.
_2
)
})
})
})
})
installJSONObject
.
toJSONString
installJSONObject
.
toJSONString
}
}
def
filterInstall
(
installList
:
String
)
:
Boolean
=
{
MobvistaConstant
.
String2JSONObject
(
installList
).
size
()
>
0
}
}
}
object
InstallListDailyV2
{
object
InstallListDailyV2
{
...
...
src/main/scala/mobvista/dmp/common/MobvistaConstant.scala
View file @
8c7555e2
...
@@ -312,6 +312,8 @@ object MobvistaConstant {
...
@@ -312,6 +312,8 @@ object MobvistaConstant {
}
}
}
}
val
regionSet
:
mutable.Set
[
String
]
=
mutable
.
Set
(
"virginia"
,
"frankfurt"
,
"singapore"
,
"seoul"
)
val
countryPtn
=
"^([A-Z]{2,3})$"
val
countryPtn
=
"^([A-Z]{2,3})$"
// IDFA/GAID
// IDFA/GAID
...
...
src/main/scala/mobvista/dmp/datasource/dm/Constant.scala
View file @
8c7555e2
...
@@ -759,12 +759,16 @@ object Constant {
...
@@ -759,12 +759,16 @@ object Constant {
val
regionSet
=
new
mutable
.
HashSet
[
String
]()
val
regionSet
=
new
mutable
.
HashSet
[
String
]()
import
scala.collection.JavaConversions._
import
scala.collection.JavaConversions._
if
(
data_1
.
containsKey
(
"region"
))
{
if
(
data_1
.
containsKey
(
"region"
))
{
data_1
.
getJSONArray
(
"region"
).
foreach
(
v
=>
{
data_1
.
getJSONArray
(
"region"
).
filter
(
r
=>
{
StringUtils
.
isNotBlank
(
r
.
toString
)
}).
foreach
(
v
=>
{
regionSet
.
add
(
v
.
toString
)
regionSet
.
add
(
v
.
toString
)
})
})
}
}
if
(
data_2
.
containsKey
(
"region"
))
{
if
(
data_2
.
containsKey
(
"region"
))
{
data_2
.
getJSONArray
(
"region"
).
foreach
(
v
=>
{
data_2
.
getJSONArray
(
"region"
).
filter
(
r
=>
{
StringUtils
.
isNotBlank
(
r
.
toString
)
}).
foreach
(
v
=>
{
regionSet
.
add
(
v
.
toString
)
regionSet
.
add
(
v
.
toString
)
})
})
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment