Skip to content

Commit

Permalink
CLEANUP : reflected reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
jooho812 committed Aug 21, 2017
1 parent 6341ad4 commit 88bdb04
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
6 changes: 4 additions & 2 deletions engines/COMMON/mblock_allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,11 @@ bool eblk_prepare(eblock_result_t *result, uint32_t elem_count) {
mem_block_t *head;
mem_block_t *last;
uint32_t curr_blkcnt = result->blck_cnt;
int alloc_blkcnt;
blkcnt = ((result->elem_cnt + elem_count - 1) / EITEMS_PER_BLOCK) + 1;
if (blkcnt > curr_blkcnt) { // need append block
if (!mblock_list_alloc((blkcnt - curr_blkcnt), &head, &last))
alloc_blkcnt = blkcnt - curr_blkcnt;
if (alloc_blkcnt > 0) { // need append block
if (!mblock_list_alloc((alloc_blkcnt), &head, &last))
return false;
result->last_blk->next = head;
result->last_blk = last;
Expand Down
5 changes: 3 additions & 2 deletions engines/default/items.c
Original file line number Diff line number Diff line change
Expand Up @@ -4934,11 +4934,11 @@ static int do_btree_posi_find_with_get(btree_meta_info *info,

ecnt = 1; /* elem count */
eidx = (bpos < count) ? bpos : count; /* elem index in elem array */
elem->refcount++;
#ifdef USE_EBLOCK_RESULT
if (!eblk_prepare(eblk_ret, (eidx + count + 1)))
return ENGINE_ENOMEM;

elem->refcount++;
eblk_add_elem_with_posi(eblk_ret, elem, eidx);
if (order == BTREE_ORDER_ASC) {
ecnt += do_btree_elem_batch_get(path[0], eidx, false, true, eblk_ret);
Expand All @@ -4951,6 +4951,7 @@ static int do_btree_posi_find_with_get(btree_meta_info *info,
}
eblk_truncate(eblk_ret);
#else
elem->refcount++;
elem_array[eidx] = elem;

if (order == BTREE_ORDER_ASC) {
Expand Down Expand Up @@ -4994,7 +4995,7 @@ static ENGINE_ERROR_CODE do_btree_elem_get_by_posi(btree_meta_info *info,
if (info->root == NULL) return ENGINE_ELEM_ENOENT;

#ifdef USE_EBLOCK_RESULT
if (!eblk_prepare(eblk_ret, (count > 0 && count < info->ccnt) ? count : info->ccnt))
if (!eblk_prepare(eblk_ret, (count < info->ccnt) ? count : info->ccnt))
return ENGINE_ENOMEM;
#endif
node = info->root;
Expand Down
10 changes: 9 additions & 1 deletion include/memcached/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,15 @@ extern "C" {
(s)->idx = 0; \
} while(0) \

#define EBLOCK_SCAN_RESET(b, s) ((s)->tot = (b)->elem_cnt)
#define EBLOCK_SCAN_RESET(f, b, s) \
do { \
if ((f) == false) { \
(s)->blk = (b)->head_blk; \
(s)->idx = 0; \
(f) = true; \
} \
(s)->tot = (b)->elem_cnt; \
} while(0) \

#define EBLOCK_SCAN_NEXT(s, e) \
do { \
Expand Down
11 changes: 2 additions & 9 deletions memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,7 @@ static void process_bop_mget_complete(conn *c) {
}

#ifdef USE_EBLOCK_RESULT
EBLOCK_SCAN_INIT(&c->eblk_ret, &eblk_sc); //dummy initialization
EBLOCK_SCAN_INIT(&c->eblk_ret, &eblk_sc);
#endif
for (k = 0; k < c->coll_numkeys; k++) {
#ifdef USE_EBLOCK_RESULT
Expand Down Expand Up @@ -2325,14 +2325,7 @@ static void process_bop_mget_complete(conn *c) {
resultptr += strlen(resultptr);

#ifdef USE_EBLOCK_RESULT
if (cur_elem_count > 0) {
if (eblk_scan_init == false) {
EBLOCK_SCAN_INIT(&c->eblk_ret, &eblk_sc);
eblk_scan_init = true;
} else {
EBLOCK_SCAN_RESET(&c->eblk_ret, &eblk_sc);
}
}
EBLOCK_SCAN_RESET(eblk_scan_init, &c->eblk_ret, &eblk_sc);
#endif
for (e = 0; e < cur_elem_count; e++) {
#ifdef USE_EBLOCK_RESULT
Expand Down

0 comments on commit 88bdb04

Please sign in to comment.