Open
Conversation
drmingdrmer
requested changes
Aug 26, 2017
consistenthash.c
Outdated
|
|
||
| static int | ||
| node_cmp( const hashnode_t *a, const hashnode_t *b ) | ||
| node_cmp( const hashnode_t *a, const hashnode_t *b ) /*for qsort below, sort from small to large*/ |
consistenthash.c
Outdated
|
|
||
|
|
||
| while ( s + 1 < e ) { | ||
| while ( s + 1 < e ) { /*binary search*/ |
Contributor
There was a problem hiding this comment.
你的vim里有NERD-Comment这个插件. ctrl-f切换注释.
consistenthash.c
Outdated
|
|
||
|
|
||
| p = get_continuum( L, 1 ); | ||
| p = get_continuum( L, 1 ); /*get the storage address for userdata*/ |
Contributor
There was a problem hiding this comment.
不是很关键的注释自己看就好了..不用提交上来.
consistenthash.c
Outdated
| if ( lua_isnumber( L, 3 ) ) { | ||
| n_replica = lua_tointeger( L, 3 ); | ||
| if ( n_replica > MAX_REPLICA ) { | ||
| if ( n_replica > MAX_REPLICA ) { /*the number of replica nodes is limited to MAX_REPLICA*/ |
drmingdrmer
requested changes
Aug 26, 2017
consistenthash.c
Outdated
| #include <lua.h> | ||
| #include <lauxlib.h> | ||
|
|
||
| #include"md5.h" |
Contributor
There was a problem hiding this comment.
装个astyle, 专门用来格式化c代码的.
这里是配置文件, 放到 ~/.astylerc
#Bracket style
style=google
#Tab
#使用2个空格作为一个缩进单位
indent=spaces=4
#Indentation
#缩进case本身
indent-switches
#缩进case内容
indent-cases
#缩进宏定义内容
# indent-preproc-block
# indent-preproc-cond
# indent-preproc-define
#缩进注释
indent-col1-comments
#Padding
#操作符两端补空格
pad-oper
#if/for/while后面与小括号之间补空格
pad-header
#除上述两点外,都不补空格
unpad-paren
#声明指针时,*贴紧变量名
align-pointer=name
#Formatting
#单行的分支循环块补充花括号
add-brackets
#凡是tab都替换成两个空格
convert-tabs
#单行最长100个字节
max-code-length=100
#单行长度超过100字节时根据条件逻辑进行切分换行
break-after-logical
#c/c++风格
mode=c
#保持一行代码的写法
keep-one-line-blocks
#Other
#转化后的文件修改时间不变
preserve-date
#linux风格的换行符
lineend=linux
#show detail
verbose
# do not create backup
suffix=none
| @@ -0,0 +1,15 @@ | |||
| typedef struct { | |||
drmingdrmer
requested changes
Aug 26, 2017
consistenthash.c
Outdated
|
|
||
| while ( s + 1 < e ) { | ||
| mid = ( s+e ) / 2; | ||
| mid = ( s+e ) ; |
consistenthash.c
Outdated
| if ( lua_isnumber( L, 3 ) ) { | ||
| n_replica = lua_tointeger( L, 3 ); | ||
| if ( n_replica > MAX_REPLICA ) { | ||
| if ( n_replica > MAX_REPLICA ) { |
consistenthash.c
Outdated
|
|
||
| while ( n_names < n_replica ) { | ||
|
|
||
| /* assignment */ |
consistenthash.c
Outdated
|
|
||
| if ( 0 == n ) { | ||
| luaL_argerror( L, 2, "Empty table" ); | ||
| luaL_argerror( L, 2, "Empty table" ); |
consistenthash.c
Outdated
| for ( i = 0; i < conti->n_buckets; i++ ) { | ||
| i_nodes = point_search( conti, step * i ); | ||
| conti->buckets[ i ] = i_nodes; | ||
| conti->buckets[ i ] = i_nodes; /*map the node to a bucket*/ |
Contributor
|
测试跑过了没~ |
drmingdrmer
requested changes
Oct 16, 2017
md5.h
Outdated
| @@ -0,0 +1,19 @@ | |||
| #ifndef MD5_H | |||
| #define MD5_H | |||
| #endif | |||
Contributor
There was a problem hiding this comment.
看看c preprocessor的例子和教程.这个endif加的不对
Makefile
Outdated
|
|
||
| LUAPKG = lua5.2 | ||
| CFLAGS = `pkg-config $(LUAPKG) --cflags` -fPIC -O3 -Wall $(OMIT_FRAME_PTR) | ||
| CFLAGS = `pkg-config $(LUAPKG) --cflags` -fPIC -O3 -Wall $(OMIT_FRAME_PTR) -I/usr/local/include/luajit-2.1 |
Contributor
There was a problem hiding this comment.
这个地方不能直接用带版本的绝对路径..不是所有的机器上都装的2.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
split lch_new.