- 博客(116)
- 收藏
- 关注
转载 spark模型运行时无法连接摸个excutors异常org.apache.spark.shuffle.FetchFailedException: Failed to connect to xxxx/x...
error:org.apache.spark.shuffle.FetchFailedException: Failed to connect to xxxx/xx.xx.xx.xx:xxxx 定位来定位去与防火墙等无关。反复查看日志: 2019-09-30 11:00:46,521 | WARN | [dispatcher-event-loop-50] | Lost task 5...
2019-09-30 17:44:00
692
转载 spark模型error java.lang.IllegalArgumentException: Row length is 0
failure: Lost task 18.3 in stage 17.0 (TID 59784,XXXXX, executor 19): java.lang.IllegalArgumentException: Row length is 0 场景是写入hbase: val put = new Put(Bytes.toBytes(line._1)) 当取出的line._1做...
2019-09-30 17:29:00
3181
转载 被简书恶心到了
之前在简书写,但是被简书封号,只能在手机app查看自己的文章列表,没搞懂。写的东西很烂自己也知道。 但是无缘无故被封号,还将所有文章同步到了这个“台部落“。账号都爬过去了,不是本人操作,都被爬到了这个网站https://www.twblogs.net/ 索性搬家到博客园了,文章依然很烂,就当笔记记下。简书上边还有的钻提不了现。发客服邮箱简书也不回复。 公告说被封号的,两个月后账号就...
2019-09-29 14:49:00
624
转载 spark foreachPartition foreach
1.foreach val list = new ArrayBuffer() myRdd.foreach(record => { list += record }) 2.foreachPartition val list = new ArrayBuffer rdd.foreachPartition(it ...
2019-09-27 18:49:00
270
转载 spark sql createOrReplaceTempView registerTempTable
spark sql ,如果每个表里的数据都很大,用sql直接将几个表关联起来查询时比较耗内存。 可以先将每个表的可用集合过滤到最小,然后在内存中关联,可以提高减少内存占用,提高效率。 createOrReplaceTempView2.x版本以上。registerTempTable1.5.x val data1 = dataSelect1(sqlContext, spar...
2019-09-27 17:04:00
1843
转载 java8 stream
import org.junit.Test; import java.util.*; import java.util.stream.Collectors; /** * Created by shaozhiqi on 2019/9/26 */ public class testLam { @Test public void te...
2019-09-26 16:18:00
108
转载 python3(四十)datetime timestamp str
"""时间处理 """ __author__on__ = 'shaozhiqi 2019/9/25' # !/usr/bin/env python3 # -*- coding: utf-8 -*- # ------------------------------------------datetime----------------------------------...
2019-09-25 15:20:00
147
转载 python3(三十八) serialize
""" """ __author__on__ = 'shaozhiqi 2019/9/24' # !/usr/bin/env python3 # -*- coding: utf-8 -*- # 在程序运行的过程中,所有的变量都是在内存中,比如,定义一个dict: d = dict(name='Bob', age=20, score=88) # 我们把变量从内存...
2019-09-24 18:50:00
305
转载 python3(三十七) filepath
""" file path """ __author__on__ = 'shaozhiqi 2019/9/23' # !/usr/bin/env python3 # -*- coding: utf-8 -*- # os模块的基本功能 import os print(os.name) # nt # 如果是posix,说明系统是Linux、Unix或Mac ...
2019-09-23 18:56:00
1119
转载 python3(三十六)StringIO BytesIO
""" StringIO和BytesIO """ __author__on__ = 'shaozhiqi 2019/9/23' # !/usr/bin/env python3 # -*- coding: utf-8 -*- # 很多时候,数据读写不一定是文件,也可以在内存中读写。 # StringIO顾名思义就是在内存中读写str。 # 要把str写入Strin...
2019-09-23 18:55:00
109
转载 python3(三十五)file read write
""" 文件读写 """ __author__on__ = 'shaozhiqi 2019/9/23' # !/usr/bin/env python3 # -*- coding: utf-8 -*- # 读文件的模式打开一个文件对象,使用Python内置的open()函数,传入文件名和标示符 f = open('D:/temp/shao.txt', 'r', en...
2019-09-23 18:54:00
249
转载 python3(三十四)unitTest
""" 单元测试 """ __author__on__ = 'shaozhiqi 2019/9/23' class Dict(dict): def __init__(self, **kw): super().__init__(**kw) def __getattr__(self, key): try: ...
2019-09-23 18:53:00
105
转载 python3(三十三)debug
""" 调试 """ __author__on__ = 'shaozhiqi 2019/9/23' # 调试程序 # 1. print打印,没问题了上线还得删掉 # 2. 断言、assert # n不等于0则继续执行,否则走断言的处理,Python解释器时可以用-O参数来关闭assert # def foo(s): # n = int(s) # ...
2019-09-23 18:51:00
168
转载 python3(三十二) try except
""" 异常处理 """ __author__on__ = 'shaozhiqi 2019/9/19' # 大量的代码来判断是否出错: # def foo(): # r = some_function() # if r == (-1): # return (-1) # # do something # return...
2019-09-19 18:27:00
136
转载 python3(三十一)metaclass
""" """ __author__ = 'shaozhiqi' # 动态语言和静态语言最大的不同,就是函数和类的定义,不是编译时定义的,而是运行时动态创建的。 # type()函数既可以返回一个对象的类型,又可以创建出新的类型,比如,我们可以通过type()函数创建出Hello类,而无需通过class Hello(object)...的定义: def fn(sel...
2019-09-19 16:19:00
136
转载 python3(三十) Enum
""" """ __author__ = 'shaozhiqi' # 当我们需要定义常量时,一个办法是用大写变量通过整数来定义,例如月份: JAN = 1 FEB = 2 MAR = 3 # 好处是简单,缺点是类型是int,并且仍然是变量 # --------------Enum-----------------------------------------...
2019-09-19 16:18:00
140
转载 python3(二十九) orderClass
""" """ __author__ = 'shaozhiqi' # Python的class中还有许多有特殊用途的函数,可以帮助我们定制类 # ------------------str----------------------------------- class Student(object): def __init__(self, name)...
2019-09-19 16:17:00
262
转载 python3(二十八)manyExten
""" 多重继承 """ __author__ = 'shaozhiqi' # start ------------------------------------------------------ class Animal(object): pass # 哺乳动物 -----------------------------------------...
2019-09-19 16:16:00
95
转载 python3(二十七)property
""" """ __author__ = 'shaozhiqi' # 绑定属性时,如果我们直接把属性暴露出去,虽然写起来很简单, # 但是,没办法检查参数,导致可以把参数随便改 # 比如想限制student score的范围 class Student(object): def get_score(self): return s...
2019-09-19 16:14:00
112
转载 python3(二十六)slots
""" """ __author__ = 'shaozhiqi' # python是动态语言,所以定义类后,我们可以动态的给类绑定属性和方法,上一节都都与接触 class Student(object): pass s = Student() s.name = 'shaozhiqi' print(s.name) # shaozhiqi ...
2019-09-19 16:13:00
113
转载 python3(二十五) getClassInfo
""" """ __author__ = 'shaozhiqi' # 如何知道这个对象是什么类型,使用type() print(type(123)) # <class 'int'> print(type('abc')) # <class 'str'> print(type(None)) # <class 'NoneType'>...
2019-09-19 16:12:00
184
转载 python3(二十四) subClas
""" 继承的多态 """ __author__ = 'shaozhiqi' # -----------------父类------------------------ class Animal(object): def run(self): print('Animal is running...') # -------------...
2019-09-19 16:11:00
109
转载 python3(二十三)classInstance
""" 类和实例和访问权限 """ __author__ = 'shaozhiqi' # class后面紧接着是类名,即Student,类名通常是大写开头的单词, # 紧接着是(object),表示该类是从哪个类继承下来的 class Student(object): pass bart = Student() # 变量bart指向的就是一个St...
2019-09-19 16:09:00
149
转载 python3(二十二) oop
""" 面向对象编程 """ __author__ = 'shaozhiqi' # 面向对象的程序设计把计算机程序视为一组对象的集合,而每个对象都可以接收其他对象发过来的消息,并处理这些消息,计算机程序的执行就是一系列消息在各个对象之间传递。 # 在Python中,所有数据类型都可以视为对象,当然也可以自定义对象 # 打印学生成绩,首先必须创建出这个学生对应的对象,然...
2019-09-19 16:08:00
84
转载 python3(二十一) pip
先确保安装了windows的Python的pip 出现上图说明安装了,命令未找到则没有安装 安装一个图形处理的第三方库 Anaconda安装第三方库 我们经常需要用到很多第三方库,如MySQL驱动程序,Web框架等。用pip一个一个安装费时费力,还需要考虑兼容性。我们推荐直接使用Anaconda,这是一个基于Python的数据处理和科学计算平台,它已经内置了...
2019-09-19 16:07:00
80
转载 python3(二十) module
# 在Python中,一个.py文件就称之为一个模块(Module) # 1.最大的好处是大大提高了代码的可维护性。 # 2.可以被其他地方引用 # 3.python内置的模块和来自第三方的模块 # 4.使用模块还可以避免函数名和变量名冲突 # 5.同样,Python也有包(Package),同名不同包引用是也不会冲突。 # 每一个包目录下面都会有一个__init__...
2019-09-18 17:05:00
136
转载 python3(十九)Partial func
# 偏函数(Partial function) # 如int()函数可以把字符串转换为整数,当仅传入字符串时,int()函数默认按十进制转换 print(int('12345')) # 12345 # 但int()函数还提供额外的base参数,默认值为10。如果传入base参数,就可以做N进制的转换: print(int('12345', base=8)) # 5349 ...
2019-09-18 17:03:00
105
转载 python3(十八)decorator
# -----------------------1-------------------------------------------- # 由于函数也是一个对象,而且函数对象可以被赋值给变量,所以,通过变量也能调用该函数。 def now(): print('2019-3-25') f = now print(f()) # 2019-3-25 pr...
2019-09-18 17:01:00
65
转载 python3(十七) nonameFunc
L = list(map(lambda x: x * x, [1, 2, 3, 4, 5, 6, 7, 8, 9])) print(L) # [1, 4, 9, 16, 25, 36, 49, 64, 81] # lambda x: x * x等价于下面的 def f(x): return x * x # 关键字lambda表示匿名函数,冒号前面的...
2019-09-18 16:59:00
86
转载 python3(十六)returnFunc
# 通常求和函数定义,调动就求和 def calc_sum(*args): ax = 0 for n in args: ax = ax + n return ax # 如果不需要立即求和 def lazy_sum(*args): def sum(): ax = 0 for n ...
2019-09-18 16:58:00
148
转载 python3(十六) sorted
# sorted()函数list进行排序: L = sorted([36, 5, -12, 9, -21]) print(L) # [-21, -12, 5, 9, 36] # 可以看到默认是按照升序排 LL = sorted([36, 5, -12, 9, -21], key=abs) print(LL) # [5, 9, -12, -21, 36] 自定义ke...
2019-09-18 16:56:00
66
转载 python3(十四) filter
# 和map()类似,filter()也接收一个函数和一个序列。 # 和map()不同的是,filter()把传入的函数依次作用于每个元素, # 然后根据返回值是True还是False决定保留还是丢弃该元素。 def is_odd(n): return n % 2 == 1 # filter()函数返回的是一个Iterator,也就是一个惰性序列, # 所...
2019-09-18 16:56:00
98
转载 python3(十三)map reduce
# map()函数接收两个参数,一个是函数,一个是Iterable, # map将传入的函数依次作用到序列的每个元素,并把结果作为新的Iterator返回。 def f(x): return x * x r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9]) # f作用掉序列的每个元素上,可提高代码可读性 print(r) # &...
2019-09-18 16:54:00
118
转载 python3(十二)functional
# 函数式编程的一个特点就是,允许把函数本身作为参数传入另一个函数,还允许返回一个函数! # 变量可以指向函数 abs(-10) # 10 abs # <built-in function abs> # ------abs(-10)是函数调用,而abs是函数本身 x = abs(-10) print(x) # 10 # 函数名也是变量 f = a...
2019-09-18 16:53:00
218
转载 python3(十一)generator
# 只要把一个列表生成式的[]改成() L = [x * x for x in range(10)] print(L) # [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] g = (x * x for x in range(10)) print(g) # <generator object <genexpr> at 0x0000...
2019-09-18 16:52:00
118
转载 python3(十) iteration
d = {'a': 1, 'b': 2, 'c': 3} for key in d: print(key, end=' ') # a b c dict的存储不是按照list的方式顺序排列,所以,迭代出的结果顺序很可能不一样 for ch in 'ABC': print(ch, end=' ') # A B C # 判断一个对象是否可迭代 from ...
2019-09-18 16:51:00
236
转载 python3(九) Section
# list或tuple的部分元素 L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack'] # -----------------传统方法 print([L[0], L[1], L[2]]) # 取前三个值 r = [] n = 3 for i in range(n): r.append(L[i]) # 取前n个值 ...
2019-09-18 16:49:00
805
转载 python3(八) function
# Python 常用内置函数 https://docs.python.org/3/library/functions.html#abs print(help(abs)) # Return the absolute value of the argument. 返回参数的绝对值。 print(abs(-20)) # 20 print(max(2, 3, 1, -5)) ...
2019-09-18 16:47:00
104
转载 python3(七)dict list
# dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度。 # dict内部存放的顺序和key放入的顺序是没有关系的 # 根据同学的名字查找对应的成绩,如果用list实现,需要两个list names = ['Michael', 'Bob', 'Tracy'] scores = [95, 75, 85] # d...
2019-09-18 16:46:00
223
转载 python3(六) for while
# Python的循环有两种,一种是for...in循环,依次把list或tuple中的每个元素迭代出来 names = ['Michael', 'Bob', 'Tracy'] for name in names: print(name) # 计算1-10的整数之和 sumAdd = 0 for x in [1, 2, 3, 4, 5, 6, 7, 8, 9, 1...
2019-09-18 16:45:00
62
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人