由于经常“搜索结果未予显示”,禁止评论和一系列的审查内容,现放弃使用微博。
spark处理广告数据中搜索词与bidword的大小写全角繁体问题
环境:spark 1.4.1, jpinyin-1.1.3.jar
spark-shell –executor-memory 10G –total-executor-cores 10 –jars ~/huangqiang/jpinyin-1.1.3.jar
import com.github.stuxuhai.jpinyin.ChineseHelper
val hiveCtx = new org.apache.spark.sql.hive.HiveContext(sc)
val hql1 = hiveCtx.sql(“select logdate, query, custid, groupid, bidword, quality, price from search_join_log where logdate <=’2016-01-07′ and logdate >= ‘2016-01-01′ and adtype=’2′ and adid > 0 and channel in(’16’,’40’,’51’,’52’,’78’,’80’,’72’,’73’,’81’)”)
def qj2Bj(str: String): String = {
var b = str.toCharArray
val c = b.map{i =>
if(i == ‘\\\\u3000’){
“”
}else if(i > ‘\\\\uFF00’ && i < ‘\\\\uFF5F’){
(i – 65248).toChar
}else{
i.toChar
}
}
return c.mkString
}
val norm_search_join_log = hql1.map{r =>
val q_bc = qj2Bj(r(1).toString.toLowerCase())
val b_bc = qj2Bj(r(4).toString.toLowerCase())
val q_sim = ChineseHelper.convertToSimplifiedChinese(q_bc)
val b_sim = ChineseHelper.convertToSimplifiedChinese(b_bc)
(r(0).toString, q_sim, r(2).toString, r(3).toString, b_sim, r(5).toString, r(6).toString)
}
go使用json定义字段需首字大学
在使用golang中的json包,定义字段时需要首字母大写,例:
type Load_log struct{
User_id string
Os string
Load_dtime string
}
必须写User_id的格式而不是user_id,不然解析的时候没有任何结果。
librados: client.admin initialization error (2) No such file or directory
环境: Ubuntu 14.04, Ceph 0.80.10
在使用ceph或rados命令时(如:rados -p .rgw ls)发生只能加sudo才可以使用,不然就出现报错:
monclient(hunting): ERROR: missing keyring, cannot use cephx for authentication
librados: client.admin initialization error (2) No such file or directory
ls /etc/ceph/ceph.client.admin.keyring -l
-rw——- 1 root root 63 Jan 18 18:45 /etc/ceph/ceph.client.admin.keyring
查看文件的属性才发现只有root用户才可以读取文件ceph.client.admin.keyring。因而修改其权限以便其它用户也可以访问
sudo chmod o+r /etc/ceph/ceph.client.admin.keyring
mac笔记本翻转屏幕后恢复
之前180度翻转屏幕后无法恢复,错误提示为”Display preferences pane cloud not be loaded”。试过网上说的各种方法都无法恢复,甚至升级一个新的mac os都无法奏效。最终的恢复方法是找一个显示器,接入mac的hdmi,在该显示屏幕上恢复回正常的显示效果。
Datanode denied communication with namenode
环境: hadoop 2.6
查看日志 org.apache.hadoop.hdfs.server.protocol.DisallowedDatanodeException: Datanode denied communication with namenode
在hdfs-site.xml添加如下:
<property>
<name>dfs.namenode.datanode.registration.ip-hostname-check</name>
<value>false</value>
</property>
hive使用postgresql启动问题No suitable driver found
环境:CentOS 6.4, hadoop 2.6, hive 1.1,postgresql 9.4
在启动hive的时候出现No suitable driver found for jdbc:postgres://xxx.xxx.xxx.xxx:5432/hive
依据提示是说postgresql jdbc包找不到,反复确认包是存在lib文件夹内。
最终发现hive-site.xml中的
<value>jdbc:postgres://xxx.xxx.xxx.xxx:5432/hive</value> 的问题。修改为
value>jdbc:postgresql://xxx.xxx.xxx.xx:5432/hive</value>即可
期货合约代码表
http://wenku.baidu.com/link?url=tSDHwkZ8jxPshAShLtIEsI77CBSpWMO7eqNd1yn0LdOVH6KMwvBm83dm9FaPrUUBFgAVzo_arzwV0_NZI21fVetJUowvpcx2wQU0ZFhlmh3
Micrsoft开源的lightLDA
环境:Ubuntu 14.04
git clone https://github.com/Microsoft/lightlda.git
cd lightlda/
vi build.sh
修改如下:
#git clone https://github.com:Microsoft/multiverso.git
git clone https://github.com/Microsoft/multiverso.git
sh build.sh
cd example
export LD_LIBRARY_PATH=~/lightlda/multiverso/third_party/lib:$LD_LIBRARY_PATH
sh nytimes.sh
DMLC XGBoost安装使用
环境:Ubuntu 14.04
git clone https://github.com/dmlc/xgboost.git
cd xgboost
编译
make cxx11=1
运行示例
cd demo/binary_classification
../../xgboost mushroom.conf
安装python包
cd ~/xgboost/python-package
sudo python setup.py install