Commit d577dbc1 authored by 张彦钊's avatar 张彦钊

change test file

parent 2412d089
...@@ -37,8 +37,8 @@ def Json(x): ...@@ -37,8 +37,8 @@ def Json(x):
#rdd transform #rdd transform
def model(rdd): def model(rdd):
try: try:
rdd = rdd.filter(lambda x:Json(x)).repartition(10).map(lambda x:get_data(x)) rdd = rdd.filter(lambda x:Json(x)).repartition(10).map(lambda x:get_data(x).na.drop().groupByKey())\
# .repartition(10) .map(lambda x:write_redis(x[0],x[1]))
return rdd return rdd
except: except:
print("fail") print("fail")
...@@ -81,6 +81,7 @@ def write_redis(device_id,cid_list): ...@@ -81,6 +81,7 @@ def write_redis(device_id,cid_list):
else: else:
r.set(key, json.dumps(cids)) r.set(key, json.dumps(cids))
r.expire(key, 7*24*60*60) r.expire(key, 7*24*60*60)
return "good"
except Exception as e: except Exception as e:
print("insert redis fail") print("insert redis fail")
print(e) print(e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment