Skip to content

Commit

Permalink
grn_db_recover: reduce memory usage when only 1 thread mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 4, 2017
1 parent 215df0f commit f151bfd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -14780,9 +14780,12 @@ grn_db_recover(grn_ctx *ctx, grn_obj *db)
{
grn_table_cursor *cursor;
grn_id id;
grn_bool is_close_opened_object_mode;

GRN_API_ENTER;

is_close_opened_object_mode = (grn_thread_get_limit() == 1);

grn_db_recover_database(ctx, db);
if (ctx->rc != GRN_SUCCESS) {
GRN_API_RETURN(ctx->rc);
Expand All @@ -14799,6 +14802,10 @@ grn_db_recover(grn_ctx *ctx, grn_obj *db)
while ((id = grn_table_cursor_next(ctx, cursor)) != GRN_ID_NIL) {
grn_obj *object;

if (is_close_opened_object_mode) {
grn_ctx_push_temporary_open_space(ctx);
}

if ((object = grn_ctx_at(ctx, id))) {
switch (object->header.type) {
case GRN_TABLE_NO_KEY :
Expand All @@ -14824,6 +14831,10 @@ grn_db_recover(grn_ctx *ctx, grn_obj *db)
}
}

if (is_close_opened_object_mode) {
grn_ctx_pop_temporary_open_space(ctx);
}

if (ctx->rc != GRN_SUCCESS) {
break;
}
Expand Down

0 comments on commit f151bfd

Please sign in to comment.