Python HashCode 分库分表逻辑
来源:互联网 发布:大数据 维基百科 编辑:程序博客网 时间:2024/06/05 23:58
def longToInt(value): assert isinstance(value, (int, long)) return int(value & sys.maxint)#4294967295 int unsigned#18446744073709551615 bigint unsigneddef int_overflow(val): maxint = 4294967295 if not -maxint-1 <= val <= maxint: val = (val + (maxint + 1)) % (2 * (maxint + 1)) - maxint - 1 return val# get the database no, table nodef get_db_no(val): no=abs(int_overflow(longToInt(val ^ (val >> 32)))) % 64 if no < 10: no='0'+str(no) else: no=str(no) return nodef get_table_no(val): no= abs(int_overflow(longToInt(val ^ (val >> 32)))) % 63 #no=str(no) return no
阅读全文
2 0
- Python HashCode 分库分表逻辑
- python 3 逻辑字段
- python 逻辑表达式应用
- python实现逻辑回归
- 逻辑回归 python 实现
- python/逻辑回归
- python与逻辑回归
- Python实现逻辑回归
- python的逻辑语句
- python逻辑表达
- 逻辑回归Python代码
- Python逻辑操作符
- python 的逻辑关系
- 逻辑回归----Python实现
- python逻辑控制
- python 逻辑回归
- python 逻辑回归
- Python实现逻辑回归
- 开发日志 2017年8月31日
- asp.net mvc Ajax由应用到深入理解
- RTMP推流摄像头设计实现2
- It requires Vim 7.3.885 or later with Lua support ("+lua")."
- ArcGIS API for JavaScript实现坐标定位
- Python HashCode 分库分表逻辑
- nyoj 19
- Hadoop_0_集群搭建
- css布局的一些小总结
- Nginx高级数据结构总结之 ngx_queue_t 双向链表
- RTMP推流摄像头设计实现3
- golang设计模式之简单工厂模式
- @Autowired与@Resource的区别
- TODO