Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
data-dqmonitor
Project
Project
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
薛鹏飞
data-dqmonitor
Commits
8c384665
Commit
8c384665
authored
Jun 20, 2019
by
Pengfei Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cal stats
parent
cf6dc463
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
143 additions
and
17 deletions
+143
-17
.classpath
.classpath
+49
-0
.gitignore
.gitignore
+1
-0
.project
.project
+23
-0
org.eclipse.jdt.apt.core.prefs
.settings/org.eclipse.jdt.apt.core.prefs
+2
-0
org.eclipse.jdt.core.prefs
.settings/org.eclipse.jdt.core.prefs
+9
-0
org.eclipse.m2e.core.prefs
.settings/org.eclipse.m2e.core.prefs
+4
-0
pom.xml
pom.xml
+15
-0
pvCheker.scala
src/main/scala/com/gmei/data/dq/pvCheker.scala
+40
-17
No files found.
.classpath
0 → 100644
View file @
8c384665
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"src"
output=
"target/classes"
path=
"src/main/java"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
excluding=
"**"
kind=
"src"
output=
"target/classes"
path=
"src/main/resources"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
output=
"target/test-classes"
path=
"src/test/java"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"test"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
path=
"target/generated-sources/annotations"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"ignore_optional_problems"
value=
"true"
/>
<attribute
name=
"m2e-apt"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
output=
"target/test-classes"
path=
"target/generated-test-sources/test-annotations"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"ignore_optional_problems"
value=
"true"
/>
<attribute
name=
"m2e-apt"
value=
"true"
/>
<attribute
name=
"test"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"output"
path=
"target/classes"
/>
</classpath>
.gitignore
View file @
8c384665
*.class
*.class
run.sh
*.log
*.log
target/
target/
.project
0 → 100644
View file @
8c384665
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
dq
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.m2e.core.maven2Builder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
<nature>
org.eclipse.m2e.core.maven2Nature
</nature>
</natures>
</projectDescription>
.settings/org.eclipse.jdt.apt.core.prefs
0 → 100644
View file @
8c384665
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
.settings/org.eclipse.jdt.core.prefs
0 → 100644
View file @
8c384665
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
.settings/org.eclipse.m2e.core.prefs
0 → 100644
View file @
8c384665
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
pom.xml
View file @
8c384665
...
@@ -32,6 +32,21 @@
...
@@ -32,6 +32,21 @@
<version>
${spark.version}
</version>
<version>
${spark.version}
</version>
</dependency>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-mllib -->
<dependency>
<groupId>
org.apache.spark
</groupId>
<artifactId>
spark-mllib_${scala.version}
</artifactId>
<version>
${spark.version}
</version>
</dependency>
<!--
<dependency>
<groupId>frl.driesprong</groupId>
<artifactId>spark-stochastic-outlier-selection_${scala.version}</artifactId>
<version>0.1.0</version>
</dependency>
-->
</dependencies>
</dependencies>
<repositories>
<repositories>
...
...
src/main/scala/com/gmei/data/dq/pvCheker.scala
View file @
8c384665
package
com.gmei.data.dq
package
com.gmei.data.dq
import
org.apache.spark.sql.SparkSession
import
org.apache.spark.sql.
{
Row
,
SparkSession
}
import
org.apache.spark.mllib.linalg.Vectors
import
org.apache.spark.mllib.stat.
{
MultivariateStatisticalSummary
,
Statistics
}
case
class
Record
(
cl_id
:
String
,
action
:
String
,
app_version
:
String
,
page_name
:
String
,
extra
:
Int
,
referrer
:
Int
,
is_push
:
Int
,
in
:
Int
,
out
:
Int
,
referrer_id
:
Int
,
referrer_tab_name
:
Int
,
bz_id
:
Int
,
fake
:
Int
,
pv
:
Int
)
object
pvCheker
{
object
pvCheker
{
...
@@ -10,33 +20,46 @@ object pvCheker {
...
@@ -10,33 +20,46 @@ object pvCheker {
* extra_param referrer is_push in out referrer_id referrer_tab_name business_id fake page_name
* extra_param referrer is_push in out referrer_id referrer_tab_name business_id fake page_name
*/
*/
val
df
=
sc
.
sql
(
s
"""
val
df
=
sc
.
sql
(
s
"""
select
select
cl_id, action, cl_type, app_version, params['page_name'],
cl_id, action, cl_type, app_version, params['page_name']
as page_name
,
case when params['extra_param'] is null then 0 else 1 end as extra,
case when params['extra_param'] is null then 0 else 1 end as extra,
case when params['referrer'] is null or params['referrer'] = '' then 0 else 1 end as referrer,
case
when params['referrer'] is null then -1
else if (params['referrer'] = '', 0, 1)
end as referrer,
case when params['is_push'] is null then 0 else 1 end as is_push,
case when params['is_push'] is null then 0 else 1 end as is_push,
case when params['in'] is null then 0 else 1 end as in,
case when params['in'] is null then 0 else 1 end as in,
case when params['out'] is null then 0 else 1 end as out,
case when params['out'] is null then 0 else 1 end as out,
case when params['referrer_id'] is null then 0 else 1 end as referrer_id,
case
case when params['referrer_tab_name'] is null then 0 else 1 end as referrer_tab_name,
when params['referrer_id'] is null then -1
case when params['business_id'] is null then 0 else 1 end as bz_id,
else if(params['referrer_id'] = '', 0, 1)
end as referrer_id,
case
when params['referrer_tab_name'] is null then -1
else if(params['referrer_tab_name'] = '', 0, 1)
end as referrer_tab_name,
case
when params['business_id'] is null then -1
else if(params['bussiness_id'] = '', 0, 1)
end as bz_id,
case when params['fake'] is null then 0 else 1 end as fake,
case when params['fake'] is null then 0 else 1 end as fake,
1 as pv
1 as pv
from tl_hdfs_maidian_materialized
from tl_hdfs_maidian_materialized
where partition_date=$partition_date and action = 'page_view'
where partition_date=$partition_date and action = 'page_view'
"""
)
"""
)
val
x
=
df
.
createOrReplaceTempView
(
"maidian_pv"
)
import
sc.implicits._
import
sc.sqlContext.implicits._
val
y
=
sc
.
sql
(
"""
val
y
=
df
.
as
[
Record
].
map
{
select t.page_name, t.cl_type, 1.0 * count(1) / t.pv as percent
case
r
=>
Seq
(
r
.
extra
,
r
.
referrer
,
r
.
is_push
,
r
.
in
,
r
.
out
,
r
.
referrer_id
,
r
.
referrer_tab_name
,
r
.
bz_id
)
from (
}.
rdd
select page_name, cl_type, sum(pv) over (partition by page_name) as pv
from maidian_pv
val
z
=
y
map
{
i
=>
Vectors
.
dense
(
i
.
toArray
[
Double
])}
) t
val
summary
:
MultivariateStatisticalSummary
=
Statistics
.
colStats
(
z
)
group by t.page_name, t.cl_type
println
(
summary
.
mean
)
// a dense vector containing the mean value for each column
"""
)
println
(
summary
.
variance
)
// column-wise variance
y
.
show
()
println
(
summary
.
numNonzeros
)
// number of nonzeros in each column
}
}
}
}
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