1. 云栖社区>
  2. PHP教程>
  3. 正文

php按uid分a/b测试

作者:用户 来源:互联网 时间:2017-12-01 12:21:35

测试

php按uid分a/b测试 - 摘要: 本文讲的是php按uid分a/b测试, PHP端: $uid = 108358768;if ((hexdec(substr(md5($uid), 24, 8)) % 2) == 0) { echo 'a';} else { echo 'b';} SHELL端:

PHP端:

$uid = 108358768;if ((hexdec(substr(md5($uid), 24, 8)) % 2) == 0) { echo 'a';} else { echo 'b';}

SHELL端:

md5_group() {local field=$1local num_group=${2:-2}local cls='org.apache.commons.codec.digest.DigestUtils'echo "(cast(conv(substr(reflect('$cls','md5Hex',cast($field as string)), 25, 8), 16, 10) as BIGINT) % $num_group)"}hive -e "select uid, $(md5_group uid) as ab from log where ds=20151111"

HIVE查询

select uid, (cast(conv(substr(reflect('org.apache.commons.codec.digest.DigestUtils','md5Hex',cast(uid as string)), 25, 8), 16, 10) as BIGINT) % 2) as ab from log where ds=20151111

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索测试 ,以便于您获取更多的相关知识。