如果在构造一张很宽的 postgresql 表的时候,发现表磁盘占用膨胀的很厉害,且这张宽表是一张稀疏表,那么可以把所有的稀疏字段都用 null 赋值(而不是 0)
这个心得貌似很简单,但是花费了我好大周折才总结出来,表空间缩小很显著
阅读全文
Category Archives: Tech
virtualbox + centos 的 gui 和 nat 问题
virtualbox 安装 centos6.5,需要安装多台,搭建一个测试用的集群,但是过程中发现一些问题,记录一下
一个是图形界面的问题,默认是安装了图形界面的,这个我们不需要,参考这里, https://superuser.com/question… ,在 /boot/grub/grub.conf 中加一个配置
# cat /boot/grub/grub.conf
# grub.conf generated…… 阅读全文
scala 多字符替换效率
来看这三种不同的写法
object strreplace {
def main(args: Array[String]): Unit = {
val loop = 50000000;
{
val start = System.currentTimeMillis()
for (i <- 0 to loop) {
val a = ("123456".replace("2", "00").replace("3", …… 阅读全文
spark 写 gp/tpg 效率优化 —— 写入 237w 行数据耗时从 77 分钟到 34 秒
摘自内部分享,有删减。
具体到我们这次的场景中,我们用的是 gp,gp 全称是 greenplum,是一个 mpp 版本的 postgresql,可以参考这个简介 http://www.infoq.com/cn/news/2… ,协议上兼容 postgresql,我们可以用普通能连 postgresql 的方式去连 gp,并且把 gp 看成一个黑盒的集群版本的 postgresql 来使用
然后这…… 阅读全文
scala 的强制类型转换
scala 中没有强制类型转换,也即是无法写出 (T)obj 的写法,所以需要绕一下,看到这里, https://stackoverflow.com/ques… ,提到可以这么来
var bar:Dog = foo.asInstanceOf[Dog]
原文是
Lets say I have the following code:
abstract class Animal
case class Dog(name:String) extends Animal
var foo:An…… 阅读全文
单例,多线程的一些验证
作为一个基础知识,java 下的一种单例实现是这样的
package me.zrj.test.test20170607;
public class Singleton {
private Singleton() {}
private static Singleton instance;
public static Singleton getInstance() {
if (instance == null) {
instance = new…… 阅读全文
leetcode Hamming Distance
https://leetcode.com/problems/…
盲敲,一遍过,:)
class Solution {
public:
int hammingDistance(int x, int y) {
int res = x ^ y;
int cnt = 0;
while (res) {
if (res % 2) {
cnt++;
}
res /= 2;
}
…… 阅读全文
javascript 计算当月当季当年的总天数和已过天数
function q(now, timePeriodType) {
console.log('---------');
console.log(now);
console.log(timePeriodType);
var time_process_value = 0;
var time_process_total_value = 0;
if (timePeriodType == '月') {
time_process_value = now.getDate() - 1;
…… 阅读全文
自行编译 saiku 的一些填坑记录
起因是说 jackson 的代码存在一个远程任意代码执行漏洞, http://bobao.360.cn/news/detai… ,而 saiku 又用到了 jackson,用的是 2.5.1
因此我们需要自行编译一个 saiku 的 pentaho 插件,把 jackson 的版本升上去
在此之前,我们用的是从 saiku 的官方下载回来的预编译好的 saiku-pentaho 插件,版本是 saiku-p…… 阅读全文
javascript 闭包实现斐波那契数列生成器
几个点,一个是生成器 https://developer.mozilla.org/… 另外一个是闭包
function fibo() {
var a = 0;
var b = 1;
function gen() {
var res = (a < b) ? a : b;
if (a < b) {
a = a + b;
} else {
b = a + b;
}
…… 阅读全文