Skip to content

Instantly share code, notes, and snippets.

@code6
code6 / auto_convert_join_bug_in_local_mode
Last active December 20, 2015 19:59
hive11_auto_convert_join_bug
hive> SELECT
> `dim_pay_date`.`date`
> , `deal`.`dealid`
> FROM `orderpayment_small` `orderpayment`
> JOIN `orderpayment_small` `dim_pay_date` ON `dim_pay_date`.`date` = `orderpayment`.`date`
> JOIN `orderpayment_small` `deal` ON `deal`.`dealid` = `orderpayment`.`dealid`
> JOIN `orderpayment_small` `order_city` ON `order_city`.`cityid` = `orderpayment`.`cityid`
> JOIN `user_small` `user` ON `user`.`userid` = `orderpayment`.`userid`
> limit 5;
Total MapReduce jobs = 4
@code6
code6 / dump_sw_jstack
Created August 22, 2013 13:48
dump hive process jstack
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: dump_sw_java.sh <keyword>"
fi
DUMPDIR=dump_dir
keyword=$1
ts=$(date +%H%M%S.%N)
env LC_CTYPE=C tr -dc "a-zA-Z0-9-_\$\?" < /dev/urandom | head -c 10
@code6
code6 / importer
Last active December 21, 2015 17:08
python recipe
import os
import imp
WORKDIR = os.path.dirname(os.path.abspath(__file__))
path = lambda *a: os.path.join(WORKDIR, *a)
importer = lambda m, path: imp.load_module(m, *imp.find_module(m, [path]))
@code6
code6 / gsh
Created August 27, 2013 07:12
control multiple host using gsh
gsh --hosts-file=hosts
@code6
code6 / array
Last active December 22, 2015 02:39
bash note
#http://stackoverflow.com/questions/15105135/bash-capturing-output-of-awk-into-array
lists=("http://www.youtube.com/watch?v=tKTZoB2Vjuk"
"http://www.youtube.com/watch?v=EPYupizJYQI"
"http://www.youtube.com/watch?v=haycL41dAhg"
"http://www.youtube.com/watch?v=kWyoYtvJpe4"
"http://www.youtube.com/watch?v=uKZ8GBKmeDM"
"http://www.youtube.com/watch?v=Nn2KQmVF5Og"
"http://www.youtube.com/watch?v=IcteAbMC1Ok");
#http://mapredit.blogspot.com/2013/05/get-all-extended-hive-tables-with.html
for file in $(hive -e "show table extended like \`*\`" | grep location: | awk 'BEGIN { FS = ":" };{printf("hdfs:%s:%s\n",$3,$4)}'); do hdfs dfs -du -h $file; done;
@code6
code6 / remove last 6 char
Created September 26, 2013 10:18
vim tips
http://stackoverflow.com/questions/11409518/how-to-remove-last-6-characters-of-every-line-in-vim
@code6
code6 / calc.py
Created November 16, 2013 08:21
quick and dirty calc.py
#coding=utf8
read_ints = lambda: map(int, raw_input().split())
#先假设没有正负号
# 1 + (12 + 4)
# 提高, 有正负号怎么办呢?
#((1+2)*(-333+4)+1) * (-5)
# 1 * -5
@code6
code6 / gen.sh
Created June 13, 2014 09:44
mdrill.task.assignment generate script
python gen_task_assignment_conf.py -m 10 -s 60 --hosts $hosts --ports $ports