plutolove’s diary

I love three things in this world, the sun, the moon and you. The sun for the day, the moon for the night, and you forever。

Clash 配置

安装clash sudo pacman -S clash 配置文件,external-ui需要单独安装 port: 7890 socks-port: 7891 redir-port: 7892 mixed-port: 7893 allow-lan: false mode: Rule log-level: info ipv6: false external-controller: 0.0.0.0:9090 external-ui: dashboard …

Spark SQL 执行过程

以下列代码为例: val teenagersDF = spark.sql("SELECT name, age FROM people WHERE age BETWEEN 13 AND 19") // The columns of a row in the result can be accessed by field index teenagersDF.map(teenager => "Name: " + teenager(0)).show()

C++ 模板类型推导

C++

以下列代码为例子,当调用func(expr)时,编译器会自动推导出来T的类型和ParamType的类型,模板类型推导分为一下三种类型: template<typename T> void func(ParamType p); 当ParamType是指针或者引用类型,并且不是通用引用类型 ,如果expr的类型是引用类型,丢掉其引用</typename>…

PostgreSQL添加用户自定义function

首先配置好本地源码编译环境,详情可参考http://plutolove.hatenablog.com/entry/2017/08/10/190138。添加用户自定义函数以strcon为例,其功能是连接两个字符串。

Manjaro CUDA

# 独显性能 optirun glxgears -info # 打开nvida面板 optirun -b none nvidia-settings -c :8 # 不依赖Bumblebee来使用CUDA sudo tee /proc/acpi/bbswitch <<< 'ON' # 使用完CUDA 停止NVIDIA显卡 sudo rmmod nvidia_uvm nvidia && sudo tee /proc/acpi/bbswi…

Kickstart Practice Round 2018 Problem Problem B. Googol String

题意 A "0/1 string" is a string in which every character is either 0 or 1. There are two operations that can be performed on a 0/1 string: switch: Every 0 becomes 1 and every 1 becomes 0. For example, "100" becomes "011". reverse: The stri…

hiho-[Offer收割]编程练习赛65-题目4 : 解方程

题目链接:https://hihocoder.com/problemset/problem/1771 题意 设 f(n) 表示 n 的每一位数字的平方之和,求 [a,b] 中有几个 n 满足 k × f(n)=n (1 ≤ k, a, b ≤ 1018,且a ≤ b) 解法 由于f(n)表示每一位数字的平方之和,那么f(n)的范围最大不超过18*9*9,那…

hiho-[Offer收割]编程练习赛65-题目2 : 最长子段

题目链接:https://hihocoder.com/problemset/problem/1769 题意 给定一个数组a[1..n],你需要选一个尽可能长的非空连续子段,使得这个子段的和小于等于给定的一个数 S. 解法 sum[i]数组维护前缀和,mas[i]数组维护以i结尾的最大的sum[i]+S:mas[i] = max(sum…

RTree index speed up Range query in SparkSQL

本文接着Add Range Query on Spark DataSet继续,上一篇只是添加了基本的Range操作,为了加速执行,本文将在RDD上实现一个RTree Index来加速执行Range和Knn操作,全部代码在Github。实现之后的例子如下: import org.apache.spark.sql.SparkSession import s…

Add Range Query on Spark DataSet

准备工作 首先下载代码并编译,将编译之后的代码导入到IDEA中,若在IDEA中编译出现问题,一般是由于有的代码在编译时才生成,在导入到IDEA之后要重新生成一下,点击Generate Sources and Update folders后重新编译即可。(我用的是Spark-2.1版本的代码) git c…

LevelDB源码分析-SSTable

SSTable是LevelDB的核心,将数据文件组织存储在磁盘中。有关SSTable的结构设计参考下列博客: http://blog.csdn.net/u012658346/article/details/45644195 https://www.cnblogs.com/cobbliu/p/6194072.html http://blog.csdn.net/anderscloud/article/detail…

LevelDB源码分析-Put/Delete

在LevelDB中,Put和Delete操作本质上都是Writebatch,不同点在于key值有不同的标记。真正的Delete会在Compaction时删除标记为kTypeDeletion的数据。(在本文中mem和memtable等价,imm和Immutable等价) enum ValueType { kTypeDeletion = 0x0, kTypeValue = 0x1…

LevelDB源码分析-Prepare

LevelDB整体设计 Implementation notes Format of an immutable Table file Format of a log file

配置PostgreSQL调试环境

首先下载PostgreSQL源码,我用的是PostgreSQL9.4.2。 在/home/username/新建pg文件夹,然后在.bashrc文件内添加 #每次更改.bashrc之后,执行 source ~/.bashrc export PG=/home/username/pg 在源代码文件夹下执行 ./configure --prefix=$PG --enable-depend …

MIT 6.824 Lab1 MapReduce

MapReduce MapReduce是Google提出的一种分布式编程框架,具体介绍看MapReduce论文 MIT 6.824 Lab1要求使用Go语言实现一个简易版本的MapReduce框架,在实现之前先通过下图了解MapReduce的执行过程 以实验1的wordcount为例,首先将输入文件分成5份,用户规定Ma…

Logistic Regression

ML

逻辑回归模型(二分类): 代价函数cost function为: 同样通过梯度下降算法计算最小的cost来得到参数,迭代多次直到收敛 每次迭代参数更新:

Linear Regression

ML

線性迴歸模型:$h_\theta(x) = \theta * x$ 參數$\theta = (\theta_0, \theta_2, ..., \theta_n)$ Cost Function爲:$J(\theta) = \frac{1}{2} \sum_i \left( h_\theta(x^{(i)}) - y^{(i)} \right)2$ m爲訓練集的大小,解線性迴歸模型即就是求出最小的Cost F…

TopCoder SRM 661 Div2 ColorfulLineGraphsDiv2

題目鏈接:http://community.topcoder.com/stat?c=problem_statement&pm=13842&rd=16464

TopCoder SRM 661 Div2 BridgeBuildingDiv2

題目鏈接:http://community.topcoder.com/stat?c=problem_statement&pm=13546&rd=16464

Codeforces Round #303 (Div. 2)

題目鏈接:http://codeforces.com/contest/545

TopCoder SRM 659 Div1 ApplesAndOrangesEasy

題目鏈接:http://community.topcoder.com/stat?c=problem_statement&pm=13791&rd=16462

TopCoder SRM 659 Div2 FilipTheFrog,PublicTransit

題目鏈接:http://community.topcoder.com/stat?c=problem_statement&pm=13779&rd=16462 http://community.topcoder.com/stat?c=problem_statement&pm=13779&rd=16462

Codeforces Round #302 Div. 2 D. Destroying Roads

題目鏈接:http://codeforces.com/contest/544/problem/D

Codeforces Round #302 Div. 2 C. Writing Code

題目鏈接:http://codeforces.com/contest/544/problem/C

TopCoder SRM 648 Div2 ABC

題目鏈接:http://community.topcoder.com/stat?c=problem_statement&pm=13645&rd=16312

TopCoder SRM 647 Div1 BuildingTowersEasy

題目鏈接:http://community.topcoder.com/stat?c=problem_statement&pm=13634&rd=16279

TopCoder SRM 647 Div2 TravellingSalesmanEasy

題目鏈接:http://community.topcoder.com/stat?c=problem_statement&pm=13631&rd=16279

TopCoder SRM 646 Div2 TheGridDivTwo

題目鏈接:http://community.topcoder.com/stat?c=problem_statement&pm=13628&rd=16278

Codeforces Round #285 Div. 2 D. Misha and Permutations Summation

題目鏈接:http://codeforces.com/contest/501/problem/D

TopCoder SRM 645 Div2 JanuszInTheCasino

題目鏈接:http://community.topcoder.com/stat?c=problem_statement&pm=13349&rd=16277