Whitespace. Call wterl:drop not truncate for drop calls and set force

to true when calling so that we ignore ENOENT.  Change the session estimate
down a bit.
This commit is contained in:
Gregory Burd 2013-04-19 14:55:32 -04:00
parent 40bdda15bb
commit d505f7f9c8
3 changed files with 73 additions and 65 deletions

View file

@ -1264,11 +1264,18 @@ ASYNC_NIF_DECL(
WT_CURSOR* cursor;
rc = session->open_cursor(session, args->uri, NULL, (config.data[0] != 0) ? (char *)config.data : "overwrite,raw", &cursor);
if (rc != 0) {
session->close(session, NULL);
ASYNC_NIF_REPLY(__strerror_term(env, rc));
return;
}
WterlCursorHandle* cursor_handle = enif_alloc_resource(wterl_cursor_RESOURCE, sizeof(WterlCursorHandle));
if (!cursor_handle) {
cursor->close(cursor);
session->close(session, NULL);
ASYNC_NIF_REPLY(__strerror_term(env, ENOMEM));
return;
}
cursor_handle->session = session;
cursor_handle->cursor = cursor;
ERL_NIF_TERM result = enif_make_resource(env, cursor_handle);
@ -1304,9 +1311,10 @@ ASYNC_NIF_DECL(
WT_CURSOR *cursor = args->cursor_handle->cursor;
WT_SESSION *session = args->cursor_handle->session;
/* Note: session->close() will cause all open cursors in the session to be
closed first, so we don't have explicitly to do that here. */
int rc = cursor->close(cursor);
(void)session->close(session, NULL);
closed first, so we don't have explicitly to do that here.
rc = cursor->close(cursor);
*/
int rc = session->close(session, NULL);
ASYNC_NIF_REPLY(rc == 0 ? ATOM_OK : __strerror_term(env, rc));
},
{ // post

View file

@ -310,7 +310,7 @@ fold_objects(FoldObjectsFun, Acc, Opts, #state{connection=Connection, table=Tabl
%% @doc Delete all objects from this wterl backend
-spec drop(state()) -> {ok, state()} | {error, term(), state()}.
drop(#state{connection=Connection, table=Table}=State) ->
case wterl:truncate(Connection, Table) of
case wterl:drop(Connection, Table) of
ok ->
{ok, State};
Error ->
@ -355,7 +355,7 @@ max_sessions(Config) ->
undefined -> 1024;
Size -> Size
end,
Est = 1000 * (RingSize * erlang:system_info(schedulers)), % TODO: review/fix this logic
Est = 100 * (RingSize * erlang:system_info(schedulers)), % TODO: review/fix this logic
case Est > 1000000000 of % Note: WiredTiger uses a signed int for this
true -> 1000000000;
false -> Est

View file

@ -147,7 +147,7 @@ create_nif(_AsyncNif, _Ref, _Name, _Config) ->
-spec drop(connection(), string()) -> ok | {error, term()}.
-spec drop(connection(), string(), config_list()) -> ok | {error, term()}.
drop(Ref, Name) ->
drop(Ref, Name, []).
drop(Ref, Name, [{force, true}]).
drop(Ref, Name, Config) ->
?ASYNC_NIF_CALL(fun drop_nif/4, [Ref, Name, config_to_bin(Config)]).