info

并查集(Union-Find)

僤鯓⒐⒋嵵緔 提交于 2019-12-24 16:49:27
Source: PAT A1114 Family Property (25 分) Description: This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each family, and the average area and number of sets of their real estate. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N ( ≤). Then N lines follow, each gives the infomation of a person who owns estate in the format: ID Father Mother k C h i l d ​ 1 ​​ ⋯ C h i l d ​ k ​​ M ​ e s

python学习值字典和集合

房东的猫 提交于 2019-12-24 16:49:03
集合定义总结 创建一个空集合必须用 set() 而不是 { }.{ } 是用来创建一个空字典。 集合里面的元素必须是不可变的数据类型。 通过set方法可以将列表/元组/字符串转换成集合数据类型。 >>> s1 = {} >>> type(s1) <class 'dict'> >>> s2 = {1, 2, 3} >>> type(s2) <class 'set'> >>> s3 = {1, 3.14, True, 'hello', [1, 2, 3], (1, 2, 3)} Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'list' >>> s3 = {1, 3.14, True, 'hello',(1, 2, 3)} >>> type(s3) <class 'set'> >>> s4 = set([]) >>> type(s4) <class 'set'> >>> s5 = set('abcde') >>> s5 {'c', 'e', 'b', 'a', 'd'} >>> type(s5) <class 'set'> 集合(set)是一个无序的不重复元素序列。1,2,3,4,1,2,3 = 1,2,3,4 集合的创建: 1).

CentOS日常维护及常用脚本

最后都变了- 提交于 2019-12-24 13:58:09
[root@192-16.x.x xiewenming]# curl myip.ipip.net 当前 IP:42.62.x.x 来自于:中国 北京 北京 联通/电信 www.17ce.com cdn解析网站测试 如果遇到 -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory,解决办法如下: vi /etc/environment add these lines... LANG=en_US.utf-8 LC_ALL=en_US.utf-8 结束php进程,主进程除外 ps -ef|grep php|grep -v grep|cut -c 9-15|xargs kill -9 用指定用户执行脚本或命令 su - tomcat -c /usr/local/tomcat/bin/startup.sh 切换root执行 sudo sh tomcat.sh start 查查哪个目录的inode节点使用的多 [root@opt]# df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/vda2 576K 497K 80K 87% / tmpfs 235K 5 235K 1% /dev/shm [root

tp3.2源码解析——入口文件

会有一股神秘感。 提交于 2019-12-24 12:01:15
  如果有人读这篇文章并跟着做的话,希望你能使用支持函数跳转的编辑器,还要善用var_dump和exit,对着源码去调试着看。跟着入口文件读,执行到哪里你看到哪里,对于那些不能一眼看出来的配置,则要记录下来,可能一个比较简单的功能会写出很长的代码,这个时候难免会看到后面忘了前面。   那么进入正题,从index.php文件可以看到入口文件只定义了几项常量作为配置,紧接着就引入了require './ThinkPHP/ThinkPHP.php';    1 // 检测PHP环境 2 if(version_compare(PHP_VERSION,'5.3.0','<')) die('require PHP > 5.3.0 !'); 3 4 // 开启调试模式 建议开发阶段开启 部署阶段注释或者设为false 5 define('APP_DEBUG',True); 6 7 // 定义应用目录 8 define('APP_PATH','./Application/'); 9 10 // 引入ThinkPHP入口文件 11 require './ThinkPHP/ThinkPHP.php';   在ThinkpPHP文件依然比较简单,tp定义了一些常量配置项(defined函数的写法让之前在index入口文件里定义的配置项不会被重置)记录了运行时间和内存使用信息,进行了php版本的判断

hadoop运行常见问题FAQ

风格不统一 提交于 2019-12-24 11:25:56
问题1:Shuffle Error: Exceeded MAX_FAILED_UNIQUE_FETCHES; bailing-out Answer: 程序 里面需要打开多个 文件 ,进行分析,系统一般默认数量是1024,(用ulimit -a可以看到)对于正常使用是够了,但是对于程序来讲,就太少了。 修改办法: 修改2个文件。 /etc/security/limits.conf vi /etc/security/limits.conf 加上: * soft nofile 102400 * hard nofile 409600 $cd /etc/pam.d/ $sudo vi login 添加 session required /lib/security/pam_limits.so 针对第一个 问题 我纠正下答案: 这是 reduce 预处理阶段shuffle时获取已完成的 map 的输出失败次数超过上限造成的,上限默认为5。引起此问题的方式可能会有很多种,比如网络连接不正常,连接超时,带宽较差以及端口阻塞等。。。通常框架内网络情况较好是不会出现此 错误 的。 问题2:Too many fetch-failures Answer: 出现这个问题主要是结点间的连通不够全面。 1) 检查 、/etc/hosts 要求本机ip 对应 服务 器名 要求要包含所有的服务器ip + 服务器名 2

Hadoop常见异常及其解决方案

眉间皱痕 提交于 2019-12-24 11:25:36
1、Shell$ExitCodeException 现象:运行hadoop job时出现如下异常: 14/07/09 14:42:50 INFO mapreduce.Job: Task Id : attempt_1404886826875_0007_m_000000_1, Status : FAILED Exception from container-launch: org.apache.hadoop.util.Shell$ExitCodeException: org.apache.hadoop.util.Shell$ExitCodeException: at org.apache.hadoop.util.Shell.runCommand(Shell.java:505) at org.apache.hadoop.util.Shell.run(Shell.java:418) at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:650) at org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:195) at org

python3 字典(dict)基础

喜欢而已 提交于 2019-12-24 10:58:13
1、定义及初始化 1.1、直接初始化 info = { "stu1101": "jack", "stu1102": "tom", "stu1103": "mary", } print(info)   打印输出结果: {'stu1101': 'jack', 'stu1102': 'tom', 'stu1103': 'mary'} 1.2、先定义后赋值 records ={} records["stu1101"] = 90 records["stu1102"] = 80 records["stu1103"] = 70 print(records)   打印输出结果: {'stu1101': 90, 'stu1102': 80, 'stu1103': 70} 2、方法 2.1、setdefault()   设置默认值。 2.2.1、对新的key设置默认值 info = { "stu1101": "jack", "stu1102": "tom", "stu1103": "mary", } info.setdefault("stu1100", "robin") print(info)   打印输出结果: {'stu1101': 'jack', 'stu1102': 'tom', 'stu1103': 'mary', 'stu1100': 'robin'} 2.2.2

Python字典类型、

北战南征 提交于 2019-12-24 08:47:41
字典类型: # msg_dic = { # 'apple': 10, # 'tesla': 100000, # 'mac': 3000, # 'lenovo': 30000, # 'chicken': 10, # } # 只取key的值 # for k in msg_dic: # print(k,msg_dic[k]) # for k in msg_dic.keys(): # print(k,msg_dic[k]) # 只取value的值 # for v in msg_dic.values(): # print(v) # #同时取key、value的值 # for k,v in msg_dic.items(): # print(k,v) # for循环取k # info={'a': 1, 'b': 2, 'c': 3} # for x in info: # # print(info[x]) # print(x) # 造字典 # d=dict(a=1,b=2,c=3) # print(d) #可以修改、删除、并且前后ID不变 # info={'a': 1, 'b': 2, 'c': 3} # print(info,id(info)) # info['a']=3 # print(info,id(info)) # del info['a'] 删除方法一 # print(info) #

Go语言获取系统性能数据gopsutil库

孤人 提交于 2019-12-24 07:30:06
psutil 是一个跨平台进程和系统监控的Python库,而 gopsutil 是其Go语言版本的实现。本文介绍了它的基本使用。 Go语言部署简单、性能好的特点非常适合做一些诸如采集系统信息和监控的服务,本文介绍的 gopsutil 库是知名Python库: psutil 的一个Go语言版本的实现。 安装 go get github.com/shirou/gopsutil 使用 CPU 采集CPU相关信息。 import "github.com/shirou/gopsutil/cpu" // cpu info func getCpuInfo() { cpuInfos, err := cpu.Info() if err != nil { fmt.Printf("get cpu info failed, err:%v", err) } for _, ci := range cpuInfos { fmt.Println(ci) } // CPU使用率 for { percent, _ := cpu.Percent(time.Second, false) fmt.Printf("cpu percent:%v\n", percent) } } 获取CPU负载信息: import "github.com/shirou/gopsutil/load" func getCpuLoad() {

HiveServer2和Beeline

。_饼干妹妹 提交于 2019-12-24 05:26:07
服务端HiveServer2和客户端beeline进行Hive SQL操作 一、启动服务端HiveServer2 配置好hive环境变量后: cd $HIVE_HOME /bin ./hiveserver2 启动成功后: [ ruoze@zhangfei ~ ] $ hiveserver2 --hiveconf hive.server2.thrift.port = 10086 which: no hbase in ( /home/ruoze/app/hive/bin:/home/ruoze/app/hadoop/bin:/home/ruoze/app/hadoop/sbin:/usr/java/jdk1.8.0_45/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ruoze/.local/bin:/home/ruoze/bin ) 19/12/21 16:54:38 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform .. . using builtin-java classes where applicable OK OK OK OK 生产上会将该启动命令放到后台执行: nohup .