Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
strategy_embedding
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
rank
strategy_embedding
Commits
1f5bd146
Commit
1f5bd146
authored
Nov 16, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get data from es
parent
b767b8ac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
0 deletions
+49
-0
get_data.py
personas_vector/get_data.py
+9
-0
date.py
utils/date.py
+14
-0
spark.py
utils/spark.py
+26
-0
No files found.
personas_vector/get_data.py
0 → 100644
View file @
1f5bd146
import
os
import
pandas
as
pd
from
utils.date
import
get_ndays_before
,
get_ndays_before_no_minus
from
utils.es
import
es_scan
from
utils.spark
import
get_spark
if
__name__
==
"__main__"
:
print
(
get_ndays_before
(
10
))
utils/date.py
0 → 100644
View file @
1f5bd146
from
datetime
import
date
,
timedelta
def
get_ndays_before_with_format
(
n
,
format
):
yesterday
=
(
date
.
today
()
+
timedelta
(
days
=-
n
))
.
strftime
(
format
)
return
yesterday
def
get_ndays_before_no_minus
(
n
):
return
get_ndays_before_with_format
(
n
,
"
%
Y
%
m
%
d"
)
def
get_ndays_before
(
n
):
return
get_ndays_before_with_format
(
n
,
"
%
Y-
%
m-
%
d"
)
utils/spark.py
0 → 100644
View file @
1f5bd146
from
pyspark
import
SparkConf
from
pyspark.sql
import
SparkSession
from
pytispark
import
pytispark
as
pti
def
get_spark
(
app_name
=
""
):
sparkConf
=
SparkConf
()
sparkConf
.
set
(
"spark.sql.crossJoin.enabled"
,
True
)
sparkConf
.
set
(
"spark.debug.maxToStringFields"
,
"100"
)
sparkConf
.
set
(
"spark.tispark.plan.allow_index_double_read"
,
False
)
sparkConf
.
set
(
"spark.tispark.plan.allow_index_read"
,
True
)
sparkConf
.
set
(
"spark.hive.mapred.supports.subdirectories"
,
True
)
sparkConf
.
set
(
"spark.hadoop.mapreduce.input.fileinputformat.input.dir.recursive"
,
True
)
sparkConf
.
set
(
"spark.serializer"
,
"org.apache.spark.serializer.KryoSerializer"
)
sparkConf
.
set
(
"mapreduce.output.fileoutputformat.compress"
,
False
)
sparkConf
.
set
(
"mapreduce.map.output.compress"
,
False
)
spark
=
SparkSession
.
builder
.
config
(
conf
=
sparkConf
)
.
config
(
"spark.sql.extensions"
,
"org.apache.spark.sql.TiExtensions"
)
.
config
(
"spark.tispark.pd.addresses"
,
"172.16.40.170:2379"
)
.
appName
(
app_name
)
.
enableHiveSupport
()
.
getOrCreate
()
sc
=
spark
.
sparkContext
sc
.
setLogLevel
(
"ERROR"
)
# sc.addPyFile("/srv/apps/strategy_embedding/utils/date.py")
ti
=
pti
.
TiContext
(
spark
)
ti
.
tidbMapDatabase
(
"jerry_test"
)
return
spark
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