summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@apache.org>2010-09-30 12:03:15 +0000
committerFilipe David Borba Manana <fdmanana@apache.org>2010-09-30 12:03:15 +0000
commit6ae13b5f8b827bc87a8cf3306c3caa1b97e49df3 (patch)
tree9662164348a314705094f5f52456ab7bfe330df9 /src
parent1c0a6e9c637fcfec2990c6318b3c69e4c7591d76 (diff)
Removing ?getv macros.
With OTP releases up to R13B03 it's not possible to define a 2 macro functions with the same name and different arities. (Only allowed in R13B04 and R14). git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1003025 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_auth_cache.erl6
-rw-r--r--src/couchdb/couch_btree.erl21
-rw-r--r--src/couchdb/couch_db.erl20
-rw-r--r--src/couchdb/couch_db.hrl3
-rw-r--r--src/couchdb/couch_doc.erl32
-rw-r--r--src/couchdb/couch_httpd.erl4
-rw-r--r--src/couchdb/couch_httpd_auth.erl26
-rw-r--r--src/couchdb/couch_httpd_db.erl16
-rw-r--r--src/couchdb/couch_httpd_oauth.erl20
-rw-r--r--src/couchdb/couch_httpd_rewrite.erl16
-rw-r--r--src/couchdb/couch_httpd_show.erl8
-rw-r--r--src/couchdb/couch_httpd_stats_handlers.erl4
-rw-r--r--src/couchdb/couch_httpd_vhost.erl2
-rw-r--r--src/couchdb/couch_httpd_view.erl16
-rw-r--r--src/couchdb/couch_native_process.erl4
-rw-r--r--src/couchdb/couch_query_servers.erl8
-rw-r--r--src/couchdb/couch_rep.erl92
-rw-r--r--src/couchdb/couch_rep_changes_feed.erl30
-rw-r--r--src/couchdb/couch_rep_db_listener.erl20
-rw-r--r--src/couchdb/couch_rep_httpc.erl16
-rw-r--r--src/couchdb/couch_rep_missing_revs.erl18
-rw-r--r--src/couchdb/couch_rep_reader.erl6
-rw-r--r--src/couchdb/couch_rep_writer.erl10
-rw-r--r--src/couchdb/couch_server.erl4
-rw-r--r--src/couchdb/couch_stream.erl2
-rw-r--r--src/couchdb/couch_view.erl2
-rw-r--r--src/couchdb/couch_view_group.erl16
-rw-r--r--src/couchdb/couch_view_updater.erl4
-rw-r--r--src/couchdb/couch_work_queue.erl8
29 files changed, 215 insertions, 219 deletions
diff --git a/src/couchdb/couch_auth_cache.erl b/src/couchdb/couch_auth_cache.erl
index d00a4fed..078bfcc1 100644
--- a/src/couchdb/couch_auth_cache.erl
+++ b/src/couchdb/couch_auth_cache.erl
@@ -52,7 +52,7 @@ get_user_creds(UserName) ->
{<<"salt">>, ?l2b(Salt)},
{<<"password_sha">>, ?l2b(HashedPwd)}];
UserProps when is_list(UserProps) ->
- DocRoles = ?getv(<<"roles">>, UserProps),
+ DocRoles = couch_util:get_value(<<"roles">>, UserProps),
[{<<"roles">>, [<<"_admin">> | DocRoles]},
{<<"salt">>, ?l2b(Salt)},
{<<"password_sha">>, ?l2b(HashedPwd)}]
@@ -83,7 +83,7 @@ get_from_cache(UserName) ->
validate_user_creds(nil) ->
nil;
validate_user_creds(UserCreds) ->
- case ?getv(<<"_conflicts">>, UserCreds) of
+ case couch_util:get_value(<<"_conflicts">>, UserCreds) of
undefined ->
ok;
_ConflictList ->
@@ -240,7 +240,7 @@ add_cache_entry(UserName, Credentials, ATime, State) ->
end,
true = ets:insert(?BY_ATIME, {ATime, UserName}),
true = ets:insert(?BY_USER, {UserName, {Credentials, ATime}}),
- State#state{cache_size = ?getv(size, ets:info(?BY_USER))}.
+ State#state{cache_size = couch_util:get_value(size, ets:info(?BY_USER))}.
free_mru_cache_entry() ->
diff --git a/src/couchdb/couch_btree.erl b/src/couchdb/couch_btree.erl
index 3331e2eb..0e47bac7 100644
--- a/src/couchdb/couch_btree.erl
+++ b/src/couchdb/couch_btree.erl
@@ -16,7 +16,6 @@
-export([fold/4, full_reduce/1, final_reduce/2, foldl/3, foldl/4]).
-export([fold_reduce/4, lookup/2, get_state/1, set_options/2]).
--include("couch_db.hrl").
-define(CHUNK_THRESHOLD, 16#4ff).
-record(btree,
@@ -71,10 +70,10 @@ final_reduce(Reduce, {KVs, Reductions}) ->
final_reduce(Reduce, {[], [Red | Reductions]}).
fold_reduce(#btree{root=Root}=Bt, Fun, Acc, Options) ->
- Dir = ?getv(dir, Options, fwd),
- StartKey = ?getv(start_key, Options),
- EndKey = ?getv(end_key, Options),
- KeyGroupFun = ?getv(key_group_fun, Options, fun(_,_) -> true end),
+ Dir = couch_util:get_value(dir, Options, fwd),
+ StartKey = couch_util:get_value(start_key, Options),
+ EndKey = couch_util:get_value(end_key, Options),
+ KeyGroupFun = couch_util:get_value(key_group_fun, Options, fun(_,_) -> true end),
{StartKey2, EndKey2} =
case Dir of
rev -> {EndKey, StartKey};
@@ -108,9 +107,9 @@ convert_fun_arity(Fun) when is_function(Fun, 3) ->
Fun. % Already arity 3
make_key_in_end_range_function(#btree{less=Less}, fwd, Options) ->
- case ?getv(end_key_gt, Options) of
+ case couch_util:get_value(end_key_gt, Options) of
undefined ->
- case ?getv(end_key, Options) of
+ case couch_util:get_value(end_key, Options) of
undefined ->
fun(_Key) -> true end;
LastKey ->
@@ -120,9 +119,9 @@ make_key_in_end_range_function(#btree{less=Less}, fwd, Options) ->
fun(Key) -> Less(Key, EndKey) end
end;
make_key_in_end_range_function(#btree{less=Less}, rev, Options) ->
- case ?getv(end_key_gt, Options) of
+ case couch_util:get_value(end_key_gt, Options) of
undefined ->
- case ?getv(end_key, Options) of
+ case couch_util:get_value(end_key, Options) of
undefined ->
fun(_Key) -> true end;
LastKey ->
@@ -143,10 +142,10 @@ foldl(Bt, Fun, Acc, Options) ->
fold(#btree{root=nil}, _Fun, Acc, _Options) ->
{ok, {[], []}, Acc};
fold(#btree{root=Root}=Bt, Fun, Acc, Options) ->
- Dir = ?getv(dir, Options, fwd),
+ Dir = couch_util:get_value(dir, Options, fwd),
InRange = make_key_in_end_range_function(Bt, Dir, Options),
Result =
- case ?getv(start_key, Options) of
+ case couch_util:get_value(start_key, Options) of
undefined ->
stream_node(Bt, [], Bt#btree.root, InRange, Dir,
convert_fun_arity(Fun), Acc);
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index e26dee7f..36b61a7e 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -270,8 +270,8 @@ get_design_docs(#db{fulldocinfo_by_id_btree=Btree}=Db) ->
check_is_admin(#db{user_ctx=#user_ctx{name=Name,roles=Roles}}=Db) ->
{Admins} = get_admins(Db),
- AdminRoles = [<<"_admin">> | ?getv(<<"roles">>, Admins, [])],
- AdminNames = ?getv(<<"names">>, Admins,[]),
+ AdminRoles = [<<"_admin">> | couch_util:get_value(<<"roles">>, Admins, [])],
+ AdminNames = couch_util:get_value(<<"names">>, Admins,[]),
case AdminRoles -- Roles of
AdminRoles -> % same list, not an admin role
case AdminNames -- [Name] of
@@ -289,9 +289,9 @@ check_is_reader(#db{user_ctx=#user_ctx{name=Name,roles=Roles}=UserCtx}=Db) ->
ok -> ok;
_ ->
{Readers} = get_readers(Db),
- ReaderRoles = ?getv(<<"roles">>, Readers,[]),
+ ReaderRoles = couch_util:get_value(<<"roles">>, Readers,[]),
WithAdminRoles = [<<"_admin">> | ReaderRoles],
- ReaderNames = ?getv(<<"names">>, Readers,[]),
+ ReaderNames = couch_util:get_value(<<"names">>, Readers,[]),
case ReaderRoles ++ ReaderNames of
[] -> ok; % no readers == public access
_Else ->
@@ -311,10 +311,10 @@ check_is_reader(#db{user_ctx=#user_ctx{name=Name,roles=Roles}=UserCtx}=Db) ->
end.
get_admins(#db{security=SecProps}) ->
- ?getv(<<"admins">>, SecProps, {[]}).
+ couch_util:get_value(<<"admins">>, SecProps, {[]}).
get_readers(#db{security=SecProps}) ->
- ?getv(<<"readers">>, SecProps, {[]}).
+ couch_util:get_value(<<"readers">>, SecProps, {[]}).
get_security(#db{security=SecProps}) ->
{SecProps}.
@@ -329,21 +329,21 @@ set_security(_, _) ->
throw(bad_request).
validate_security_object(SecProps) ->
- Admins = ?getv(<<"admins">>, SecProps, {[]}),
- Readers = ?getv(<<"readers">>, SecProps, {[]}),
+ Admins = couch_util:get_value(<<"admins">>, SecProps, {[]}),
+ Readers = couch_util:get_value(<<"readers">>, SecProps, {[]}),
ok = validate_names_and_roles(Admins),
ok = validate_names_and_roles(Readers),
ok.
% validate user input
validate_names_and_roles({Props}) when is_list(Props) ->
- case ?getv(<<"names">>,Props,[]) of
+ case couch_util:get_value(<<"names">>,Props,[]) of
Ns when is_list(Ns) ->
[throw("names must be a JSON list of strings") ||N <- Ns, not is_binary(N)],
Ns;
_ -> throw("names must be a JSON list of strings")
end,
- case ?getv(<<"roles">>,Props,[]) of
+ case couch_util:get_value(<<"roles">>,Props,[]) of
Rs when is_list(Rs) ->
[throw("roles must be a JSON list of strings") ||R <- Rs, not is_binary(R)],
Rs;
diff --git a/src/couchdb/couch_db.hrl b/src/couchdb/couch_db.hrl
index 0b250ef4..f861219e 100644
--- a/src/couchdb/couch_db.hrl
+++ b/src/couchdb/couch_db.hrl
@@ -23,9 +23,6 @@
-define(b2l(V), binary_to_list(V)).
-define(l2b(V), list_to_binary(V)).
--define(getv(Key, List), couch_util:get_value(Key, List)).
--define(getv(Key, List, Default), couch_util:get_value(Key, List, Default)).
-
-define(DEFAULT_ATTACHMENT_CONTENT_TYPE, <<"application/octet-stream">>).
-define(LOG_DEBUG(Format, Args),
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl
index 1063f501..f8c874b0 100644
--- a/src/couchdb/couch_doc.erl
+++ b/src/couchdb/couch_doc.erl
@@ -195,26 +195,26 @@ transfer_fields([{<<"_rev">>, _Rev} | Rest], Doc) ->
transfer_fields([{<<"_attachments">>, {JsonBins}} | Rest], Doc) ->
Atts = lists:map(fun({Name, {BinProps}}) ->
- case ?getv(<<"stub">>, BinProps) of
+ case couch_util:get_value(<<"stub">>, BinProps) of
true ->
- Type = ?getv(<<"content_type">>, BinProps),
- RevPos = ?getv(<<"revpos">>, BinProps, nil),
- DiskLen = ?getv(<<"length">>, BinProps),
+ Type = couch_util:get_value(<<"content_type">>, BinProps),
+ RevPos = couch_util:get_value(<<"revpos">>, BinProps, nil),
+ DiskLen = couch_util:get_value(<<"length">>, BinProps),
{Enc, EncLen} = att_encoding_info(BinProps),
#att{name=Name, data=stub, type=Type, att_len=EncLen,
disk_len=DiskLen, encoding=Enc, revpos=RevPos};
_ ->
- Type = ?getv(<<"content_type">>, BinProps,
+ Type = couch_util:get_value(<<"content_type">>, BinProps,
?DEFAULT_ATTACHMENT_CONTENT_TYPE),
- RevPos = ?getv(<<"revpos">>, BinProps, 0),
- case ?getv(<<"follows">>, BinProps) of
+ RevPos = couch_util:get_value(<<"revpos">>, BinProps, 0),
+ case couch_util:get_value(<<"follows">>, BinProps) of
true ->
- DiskLen = ?getv(<<"length">>, BinProps),
+ DiskLen = couch_util:get_value(<<"length">>, BinProps),
{Enc, EncLen} = att_encoding_info(BinProps),
#att{name=Name, data=follows, type=Type, encoding=Enc,
att_len=EncLen, disk_len=DiskLen, revpos=RevPos};
_ ->
- Value = ?getv(<<"data">>, BinProps),
+ Value = couch_util:get_value(<<"data">>, BinProps),
Bin = base64:decode(Value),
LenBin = size(Bin),
#att{name=Name, data=Bin, type=Type, att_len=LenBin,
@@ -225,8 +225,8 @@ transfer_fields([{<<"_attachments">>, {JsonBins}} | Rest], Doc) ->
transfer_fields(Rest, Doc#doc{atts=Atts});
transfer_fields([{<<"_revisions">>, {Props}} | Rest], Doc) ->
- RevIds = ?getv(<<"ids">>, Props),
- Start = ?getv(<<"start">>, Props),
+ RevIds = couch_util:get_value(<<"ids">>, Props),
+ Start = couch_util:get_value(<<"start">>, Props),
if not is_integer(Start) ->
throw({doc_validation, "_revisions.start isn't an integer."});
not is_list(RevIds) ->
@@ -261,12 +261,12 @@ transfer_fields([Field | Rest], #doc{body=Fields}=Doc) ->
transfer_fields(Rest, Doc#doc{body=[Field|Fields]}).
att_encoding_info(BinProps) ->
- DiskLen = ?getv(<<"length">>, BinProps),
- case ?getv(<<"encoding">>, BinProps) of
+ DiskLen = couch_util:get_value(<<"length">>, BinProps),
+ case couch_util:get_value(<<"encoding">>, BinProps) of
undefined ->
{identity, DiskLen};
Enc ->
- EncodedLen = ?getv(<<"encoded_length">>, BinProps, DiskLen),
+ EncodedLen = couch_util:get_value(<<"encoded_length">>, BinProps, DiskLen),
{list_to_existing_atom(?b2l(Enc)), EncodedLen}
end.
@@ -338,7 +338,7 @@ att_to_bin(#att{data=DataFun, att_len=Len}) when is_function(DataFun)->
).
get_validate_doc_fun(#doc{body={Props}}=DDoc) ->
- case ?getv(<<"validate_doc_update">>, Props) of
+ case couch_util:get_value(<<"validate_doc_update">>, Props) of
undefined ->
nil;
_Else ->
@@ -473,7 +473,7 @@ doc_from_multi_part_stream(ContentType, DataFun) ->
end.
mp_parse_doc({headers, H}, []) ->
- case ?getv("content-type", H) of
+ case couch_util:get_value("content-type", H) of
{"application/json", _} ->
fun (Next) ->
mp_parse_doc(Next, [])
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 2ce4ebba..e853f97d 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -382,7 +382,7 @@ qs_value(Req, Key) ->
qs_value(Req, Key, undefined).
qs_value(Req, Key, Default) ->
- ?getv(Key, qs(Req), Default).
+ couch_util:get_value(Key, qs(Req), Default).
qs(#httpd{mochi_req=MochiReq}) ->
MochiReq:parse_qs().
@@ -844,7 +844,7 @@ nil_callback(_Data)->
fun(Next) -> nil_callback(Next) end.
get_boundary({"multipart/" ++ _, Opts}) ->
- case ?getv("boundary", Opts) of
+ case couch_util:get_value("boundary", Opts) of
S when is_list(S) ->
S
end;
diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl
index b16a439e..f76898e1 100644
--- a/src/couchdb/couch_httpd_auth.erl
+++ b/src/couchdb/couch_httpd_auth.erl
@@ -69,14 +69,14 @@ default_authentication_handler(Req) ->
nil ->
throw({unauthorized, <<"Name or password is incorrect.">>});
UserProps ->
- UserSalt = ?getv(<<"salt">>, UserProps, <<>>),
+ UserSalt = couch_util:get_value(<<"salt">>, UserProps, <<>>),
PasswordHash = hash_password(?l2b(Pass), UserSalt),
- ExpectedHash = ?getv(<<"password_sha">>, UserProps, nil),
+ ExpectedHash = couch_util:get_value(<<"password_sha">>, UserProps, nil),
case couch_util:verify(ExpectedHash, PasswordHash) of
true ->
Req#httpd{user_ctx=#user_ctx{
name=?l2b(User),
- roles=?getv(<<"roles">>, UserProps, [])
+ roles=couch_util:get_value(<<"roles">>, UserProps, [])
}};
_Else ->
throw({unauthorized, <<"Name or password is incorrect.">>})
@@ -180,7 +180,7 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
case couch_auth_cache:get_user_creds(User) of
nil -> Req;
UserProps ->
- UserSalt = ?getv(<<"salt">>, UserProps, <<"">>),
+ UserSalt = couch_util:get_value(<<"salt">>, UserProps, <<"">>),
FullSecret = <<Secret/binary, UserSalt/binary>>,
ExpectedHash = crypto:sha_mac(FullSecret, User ++ ":" ++ TimeStr),
Hash = ?l2b(string:join(HashParts, ":")),
@@ -194,7 +194,7 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
?LOG_DEBUG("Successful cookie auth as: ~p", [User]),
Req#httpd{user_ctx=#user_ctx{
name=?l2b(User),
- roles=?getv(<<"roles">>, UserProps, [])
+ roles=couch_util:get_value(<<"roles">>, UserProps, [])
}, auth={FullSecret, TimeLeft < Timeout*0.9}};
_Else ->
Req
@@ -215,9 +215,9 @@ cookie_auth_header(#httpd{user_ctx=#user_ctx{name=User}, auth={Secret, true}}, H
% or logout handler.
% The login and logout handlers need to set the AuthSession cookie
% themselves.
- CookieHeader = ?getv("Set-Cookie", Headers, ""),
+ CookieHeader = couch_util:get_value("Set-Cookie", Headers, ""),
Cookies = mochiweb_cookies:parse_cookie(CookieHeader),
- AuthSession = ?getv("AuthSession", Cookies),
+ AuthSession = couch_util:get_value("AuthSession", Cookies),
if AuthSession == undefined ->
TimeStamp = make_cookie_time(),
[cookie_auth_cookie(?b2l(User), Secret, TimeStamp)];
@@ -261,16 +261,16 @@ handle_session_req(#httpd{method='POST', mochi_req=MochiReq}=Req) ->
_ ->
[]
end,
- UserName = ?l2b(?getv("name", Form, "")),
- Password = ?l2b(?getv("password", Form, "")),
+ UserName = ?l2b(couch_util:get_value("name", Form, "")),
+ Password = ?l2b(couch_util:get_value("password", Form, "")),
?LOG_DEBUG("Attempt Login: ~s",[UserName]),
User = case couch_auth_cache:get_user_creds(UserName) of
nil -> [];
Result -> Result
end,
- UserSalt = ?getv(<<"salt">>, User, <<>>),
+ UserSalt = couch_util:get_value(<<"salt">>, User, <<>>),
PasswordHash = hash_password(Password, UserSalt),
- ExpectedHash = ?getv(<<"password_sha">>, User, nil),
+ ExpectedHash = couch_util:get_value(<<"password_sha">>, User, nil),
case couch_util:verify(ExpectedHash, PasswordHash) of
true ->
% setup the session cookie
@@ -287,8 +287,8 @@ handle_session_req(#httpd{method='POST', mochi_req=MochiReq}=Req) ->
send_json(Req#httpd{req_body=ReqBody}, Code, Headers,
{[
{ok, true},
- {name, ?getv(<<"name">>, User, null)},
- {roles, ?getv(<<"roles">>, User, [])}
+ {name, couch_util:get_value(<<"name">>, User, null)},
+ {roles, couch_util:get_value(<<"roles">>, User, [])}
]});
_Else ->
% clear the session
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 877ee99d..93e93892 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -277,7 +277,7 @@ db_req(#httpd{method='POST',path_parts=[_,<<"_bulk_docs">>]}=Req, Db) ->
couch_stats_collector:increment({httpd, bulk_requests}),
couch_httpd:validate_ctype(Req, "application/json"),
{JsonProps} = couch_httpd:json_body_obj(Req),
- DocsArray = ?getv(<<"docs">>, JsonProps),
+ DocsArray = couch_util:get_value(<<"docs">>, JsonProps),
case couch_httpd:header_value(Req, "X-Couch-Full-Commit") of
"true" ->
Options = [full_commit];
@@ -286,7 +286,7 @@ db_req(#httpd{method='POST',path_parts=[_,<<"_bulk_docs">>]}=Req, Db) ->
_ ->
Options = []
end,
- case ?getv(<<"new_edits">>, JsonProps, true) of
+ case couch_util:get_value(<<"new_edits">>, JsonProps, true) of
true ->
Docs = lists:map(
fun({ObjProps} = JsonObj) ->
@@ -296,7 +296,7 @@ db_req(#httpd{method='POST',path_parts=[_,<<"_bulk_docs">>]}=Req, Db) ->
<<>> -> couch_uuids:new();
Id0 -> Id0
end,
- case ?getv(<<"_rev">>, ObjProps) of
+ case couch_util:get_value(<<"_rev">>, ObjProps) of
undefined ->
Revs = {0, []};
Rev ->
@@ -307,7 +307,7 @@ db_req(#httpd{method='POST',path_parts=[_,<<"_bulk_docs">>]}=Req, Db) ->
end,
DocsArray),
Options2 =
- case ?getv(<<"all_or_nothing">>, JsonProps) of
+ case couch_util:get_value(<<"all_or_nothing">>, JsonProps) of
true -> [all_or_nothing|Options];
_ -> Options
end,
@@ -357,7 +357,7 @@ db_req(#httpd{method='GET',path_parts=[_,<<"_all_docs">>]}=Req, Db) ->
db_req(#httpd{method='POST',path_parts=[_,<<"_all_docs">>]}=Req, Db) ->
{Fields} = couch_httpd:json_body_obj(Req),
- case ?getv(<<"keys">>, Fields, nil) of
+ case couch_util:get_value(<<"keys">>, Fields, nil) of
nil ->
?LOG_DEBUG("POST to _all_docs with no keys member.", []),
all_docs_view(Req, Db, nil);
@@ -478,7 +478,7 @@ all_docs_view(Req, Db, Keys) ->
CurrentEtag = couch_httpd:make_etag(Info),
couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
- TotalRowCount = ?getv(doc_count, Info),
+ TotalRowCount = couch_util:get_value(doc_count, Info),
StartId = if is_binary(StartKey) -> StartKey;
true -> StartDocId
end,
@@ -612,9 +612,9 @@ db_doc_req(#httpd{method='POST'}=Req, Db, DocId) ->
couch_doc:validate_docid(DocId),
couch_httpd:validate_ctype(Req, "multipart/form-data"),
Form = couch_httpd:parse_form(Req),
- case ?getv("_doc", Form) of
+ case couch_util:get_value("_doc", Form) of
undefined ->
- Rev = couch_doc:parse_rev(?getv("_rev", Form)),
+ Rev = couch_doc:parse_rev(couch_util:get_value("_rev", Form)),
{ok, [{ok, Doc}]} = couch_db:open_doc_revs(Db, DocId, [Rev], []);
Json ->
Doc = couch_doc_from_req(Req, DocId, ?JSON_DECODE(Json))
diff --git a/src/couchdb/couch_httpd_oauth.erl b/src/couchdb/couch_httpd_oauth.erl
index 18e95b3c..05ee10e2 100644
--- a/src/couchdb/couch_httpd_oauth.erl
+++ b/src/couchdb/couch_httpd_oauth.erl
@@ -18,7 +18,7 @@
% OAuth auth handler using per-node user db
oauth_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
serve_oauth(Req, fun(URL, Params, Consumer, Signature) ->
- AccessToken = ?getv("oauth_token", Params),
+ AccessToken = couch_util:get_value("oauth_token", Params),
case couch_config:get("oauth_token_secrets", AccessToken) of
undefined ->
couch_httpd:send_error(Req, 400, <<"invalid_token">>,
@@ -44,14 +44,14 @@ set_user_ctx(Req, AccessToken) ->
case couch_auth_cache:get_user_creds(Name) of
nil -> Req;
User ->
- Roles = ?getv(<<"roles">>, User, []),
+ Roles = couch_util:get_value(<<"roles">>, User, []),
Req#httpd{user_ctx=#user_ctx{name=Name, roles=Roles}}
end.
% OAuth request_token
handle_oauth_req(#httpd{path_parts=[_OAuth, <<"request_token">>], method=Method}=Req) ->
serve_oauth(Req, fun(URL, Params, Consumer, Signature) ->
- AccessToken = ?getv("oauth_token", Params),
+ AccessToken = couch_util:get_value("oauth_token", Params),
TokenSecret = couch_config:get("oauth_token_secrets", AccessToken),
case oauth:verify(Signature, atom_to_list(Method), URL, Params, Consumer, TokenSecret) of
true ->
@@ -88,7 +88,7 @@ serve_oauth_authorize(#httpd{method=Method}=Req) ->
'GET' ->
% Confirm with the User that they want to authenticate the Consumer
serve_oauth(Req, fun(URL, Params, Consumer, Signature) ->
- AccessToken = ?getv("oauth_token", Params),
+ AccessToken = couch_util:get_value("oauth_token", Params),
TokenSecret = couch_config:get("oauth_token_secrets", AccessToken),
case oauth:verify(Signature, "GET", URL, Params, Consumer, TokenSecret) of
true ->
@@ -100,7 +100,7 @@ serve_oauth_authorize(#httpd{method=Method}=Req) ->
'POST' ->
% If the User has confirmed, we direct the User back to the Consumer with a verification code
serve_oauth(Req, fun(URL, Params, Consumer, Signature) ->
- AccessToken = ?getv("oauth_token", Params),
+ AccessToken = couch_util:get_value("oauth_token", Params),
TokenSecret = couch_config:get("oauth_token_secrets", AccessToken),
case oauth:verify(Signature, "POST", URL, Params, Consumer, TokenSecret) of
true ->
@@ -129,24 +129,24 @@ serve_oauth(#httpd{mochi_req=MochiReq}=Req, Fun, FailSilently) ->
end
end,
HeaderParams = oauth_uri:params_from_header_string(AuthHeader),
- %Realm = ?getv("realm", HeaderParams),
+ %Realm = couch_util:get_value("realm", HeaderParams),
Params = proplists:delete("realm", HeaderParams) ++ MochiReq:parse_qs(),
?LOG_DEBUG("OAuth Params: ~p", [Params]),
- case ?getv("oauth_version", Params, "1.0") of
+ case couch_util:get_value("oauth_version", Params, "1.0") of
"1.0" ->
- case ?getv("oauth_consumer_key", Params, undefined) of
+ case couch_util:get_value("oauth_consumer_key", Params, undefined) of
undefined ->
case FailSilently of
true -> Req;
false -> couch_httpd:send_error(Req, 400, <<"invalid_consumer">>, <<"Invalid consumer.">>)
end;
ConsumerKey ->
- SigMethod = ?getv("oauth_signature_method", Params),
+ SigMethod = couch_util:get_value("oauth_signature_method", Params),
case consumer_lookup(ConsumerKey, SigMethod) of
none ->
couch_httpd:send_error(Req, 400, <<"invalid_consumer">>, <<"Invalid consumer (key or signature method).">>);
Consumer ->
- Signature = ?getv("oauth_signature", Params),
+ Signature = couch_util:get_value("oauth_signature", Params),
URL = couch_httpd:absolute_uri(Req, MochiReq:get(raw_path)),
Fun(URL, proplists:delete("oauth_signature", Params),
Consumer, Signature)
diff --git a/src/couchdb/couch_httpd_rewrite.erl b/src/couchdb/couch_httpd_rewrite.erl
index 276e0601..36b90928 100644
--- a/src/couchdb/couch_httpd_rewrite.erl
+++ b/src/couchdb/couch_httpd_rewrite.erl
@@ -132,7 +132,7 @@ handle_rewrite_req(#httpd{
#doc{body={Props}} = DDoc,
% get rules from ddoc
- case ?getv(<<"rewrites">>, Props) of
+ case couch_util:get_value(<<"rewrites">>, Props) of
undefined ->
couch_httpd:send_error(Req, 404, <<"rewrite_error">>,
<<"Invalid path.">>);
@@ -215,7 +215,7 @@ try_bind_path([Dispatch|Rest], Method, PathParts, QueryList) ->
% QueryArgs1
Bindings2 = lists:foldl(fun({K, V}, Acc) ->
K1 = to_binding(K),
- KV = case ?getv(K1, QueryArgs1) of
+ KV = case couch_util:get_value(K1, QueryArgs1) of
undefined -> [{K1, V}];
_V1 -> []
end,
@@ -288,7 +288,7 @@ replace_var(Key, Value, Bindings) ->
get_var(VarName, Props, Default) ->
VarName1 = to_binding(VarName),
- ?getv(VarName1, Props, Default).
+ couch_util:get_value(VarName1, Props, Default).
%% doc: build new patch from bindings. bindings are query args
%% (+ dynamic query rewritten if needed) and bindings found in
@@ -302,7 +302,7 @@ make_new_path([?MATCH_ALL|_Rest], _Bindings, Remaining, Acc) ->
Acc1 = lists:reverse(Acc) ++ Remaining,
Acc1;
make_new_path([{bind, P}|Rest], Bindings, Remaining, Acc) ->
- P2 = case ?getv({bind, P}, Bindings) of
+ P2 = case couch_util:get_value({bind, P}, Bindings) of
undefined -> << "undefined">>;
P1 -> P1
end,
@@ -370,20 +370,20 @@ normalize_path1([Path|Rest], Acc) ->
%% @doc transform json rule in erlang for pattern matching
make_rule(Rule) ->
- Method = case ?getv(<<"method">>, Rule) of
+ Method = case couch_util:get_value(<<"method">>, Rule) of
undefined -> ?MATCH_ALL;
M -> to_binding(M)
end,
- QueryArgs = case ?getv(<<"query">>, Rule) of
+ QueryArgs = case couch_util:get_value(<<"query">>, Rule) of
undefined -> [];
{Args} -> Args
end,
- FromParts = case ?getv(<<"from">>, Rule) of
+ FromParts = case couch_util:get_value(<<"from">>, Rule) of
undefined -> [?MATCH_ALL];
From ->
parse_path(From)
end,
- ToParts = case ?getv(<<"to">>, Rule) of
+ ToParts = case couch_util:get_value(<<"to">>, Rule) of
undefined ->
throw({error, invalid_rewrite_target});
To ->
diff --git a/src/couchdb/couch_httpd_show.erl b/src/couchdb/couch_httpd_show.erl
index 9c0d2101..d50ca83a 100644
--- a/src/couchdb/couch_httpd_show.erl
+++ b/src/couchdb/couch_httpd_show.erl
@@ -95,7 +95,7 @@ show_etag(#httpd{user_ctx=UserCtx}=Req, Doc, DDoc, More) ->
get_fun_key(DDoc, Type, Name) ->
#doc{body={Props}} = DDoc,
- Lang = ?getv(<<"language">>, Props, <<"javascript">>),
+ Lang = couch_util:get_value(<<"language">>, Props, <<"javascript">>),
Src = couch_util:get_nested_json_value({Props}, [Type, Name]),
{Lang, Src}.
@@ -168,7 +168,7 @@ handle_view_list_req(#httpd{method='POST',
% {Props2} = couch_httpd:json_body(Req),
ReqBody = couch_httpd:body(Req),
{Props2} = ?JSON_DECODE(ReqBody),
- Keys = ?getv(<<"keys">>, Props2, nil),
+ Keys = couch_util:get_value(<<"keys">>, Props2, nil),
handle_view_list(Req#httpd{req_body=ReqBody}, Db, DDoc, ListName, {DesignName, ViewName}, Keys);
handle_view_list_req(#httpd{method='POST',
@@ -176,7 +176,7 @@ handle_view_list_req(#httpd{method='POST',
% {Props2} = couch_httpd:json_body(Req),
ReqBody = couch_httpd:body(Req),
{Props2} = ?JSON_DECODE(ReqBody),
- Keys = ?getv(<<"keys">>, Props2, nil),
+ Keys = couch_util:get_value(<<"keys">>, Props2, nil),
handle_view_list(Req#httpd{req_body=ReqBody}, Db, DDoc, ListName, {ViewDesignName, ViewName}, Keys);
handle_view_list_req(#httpd{method='POST'}=Req, _Db, _DDoc) ->
@@ -381,7 +381,7 @@ apply_etag({ExternalResponse}, CurrentEtag) ->
% headers on the JsonResponse object. We need to control the Etag and
% Vary headers. If the external function controls the Etag, we'd have to
% run it to check for a match, which sort of defeats the purpose.
- case ?getv(<<"headers">>, ExternalResponse, nil) of
+ case couch_util:get_value(<<"headers">>, ExternalResponse, nil) of
nil ->
% no JSON headers
% add our Etag and Vary headers to the response
diff --git a/src/couchdb/couch_httpd_stats_handlers.erl b/src/couchdb/couch_httpd_stats_handlers.erl
index 0e708db5..41aeaed0 100644
--- a/src/couchdb/couch_httpd_stats_handlers.erl
+++ b/src/couchdb/couch_httpd_stats_handlers.erl
@@ -40,7 +40,7 @@ handle_stats_req(Req) ->
send_method_not_allowed(Req, "GET").
range(Req) ->
- case ?getv("range", couch_httpd:qs(Req)) of
+ case couch_util:get_value("range", couch_httpd:qs(Req)) of
undefined ->
0;
Value ->
@@ -48,7 +48,7 @@ range(Req) ->
end.
flush(Req) ->
- case ?getv("flush", couch_httpd:qs(Req)) of
+ case couch_util:get_value("flush", couch_httpd:qs(Req)) of
"true" ->
couch_stats_aggregator:collect_sample();
_Else ->
diff --git a/src/couchdb/couch_httpd_vhost.erl b/src/couchdb/couch_httpd_vhost.erl
index 8aee966d..3dba2919 100644
--- a/src/couchdb/couch_httpd_vhost.erl
+++ b/src/couchdb/couch_httpd_vhost.erl
@@ -291,7 +291,7 @@ make_target([?MATCH_ALL|_Rest], _Bindings, Remaining, Acc) ->
Acc1 = lists:reverse(Acc) ++ Remaining,
Acc1;
make_target([{bind, P}|Rest], Bindings, Remaining, Acc) ->
- P2 = case ?getv({bind, P}, Bindings) of
+ P2 = case couch_util:get_value({bind, P}, Bindings) of
undefined -> "undefined";
P1 -> P1
end,
diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl
index cecbf8c0..65598a68 100644
--- a/src/couchdb/couch_httpd_view.erl
+++ b/src/couchdb/couch_httpd_view.erl
@@ -63,7 +63,7 @@ handle_view_req(#httpd{method='POST',
path_parts=[_, _, DName, _, ViewName]}=Req, Db, _DDoc) ->
couch_httpd:validate_ctype(Req, "application/json"),
{Fields} = couch_httpd:json_body_obj(Req),
- case ?getv(<<"keys">>, Fields, nil) of
+ case couch_util:get_value(<<"keys">>, Fields, nil) of
nil ->
Fmt = "POST to view ~p/~p in database ~p with no keys member.",
?LOG_DEBUG(Fmt, [DName, ViewName, Db]),
@@ -82,12 +82,12 @@ handle_temp_view_req(#httpd{method='POST'}=Req, Db) ->
ok = couch_db:check_is_admin(Db),
couch_stats_collector:increment({httpd, temporary_view_reads}),
{Props} = couch_httpd:json_body_obj(Req),
- Language = ?getv(<<"language">>, Props, <<"javascript">>),
- {DesignOptions} = ?getv(<<"options">>, Props, {[]}),
- MapSrc = ?getv(<<"map">>, Props),
- Keys = ?getv(<<"keys">>, Props, nil),
+ Language = couch_util:get_value(<<"language">>, Props, <<"javascript">>),
+ {DesignOptions} = couch_util:get_value(<<"options">>, Props, {[]}),
+ MapSrc = couch_util:get_value(<<"map">>, Props),
+ Keys = couch_util:get_value(<<"keys">>, Props, nil),
Reduce = get_reduce_type(Req),
- case ?getv(<<"reduce">>, Props, null) of
+ case couch_util:get_value(<<"reduce">>, Props, null) of
null ->
QueryArgs = parse_view_params(Req, Keys, map),
{ok, View, Group} = couch_view:get_temp_map_view(Db, Language,
@@ -623,13 +623,13 @@ view_row_obj(_Db, {{Key, error}, Value}, _IncludeDocs) ->
{[{key, Key}, {error, Value}]};
% include docs in the view output
view_row_obj(Db, {{Key, DocId}, {Props}}, true) ->
- Rev = case ?getv(<<"_rev">>, Props) of
+ Rev = case couch_util:get_value(<<"_rev">>, Props) of
undefined ->
nil;
Rev0 ->
couch_doc:parse_rev(Rev0)
end,
- IncludeId = ?getv(<<"_id">>, Props, DocId),
+ IncludeId = couch_util:get_value(<<"_id">>, Props, DocId),
view_row_with_doc(Db, {{Key, DocId}, {Props}}, {IncludeId, Rev});
view_row_obj(Db, {{Key, DocId}, Value}, true) ->
view_row_with_doc(Db, {{Key, DocId}, Value}, {DocId, nil});
diff --git a/src/couchdb/couch_native_process.erl b/src/couchdb/couch_native_process.erl
index 5a1723ed..b512f712 100644
--- a/src/couchdb/couch_native_process.erl
+++ b/src/couchdb/couch_native_process.erl
@@ -25,7 +25,7 @@
%
% fun({Doc}) ->
% % Below, we emit a single record - the _id as key, null as value
-% DocId = ?getv(Doc, <<"_id">>, null),
+% DocId = couch_util:get_value(Doc, <<"_id">>, null),
% Emit(DocId, null)
% end.
%
@@ -173,7 +173,7 @@ ddoc(State, {DDoc}, [FunPath, Args]) ->
% load fun from the FunPath
BFun = lists:foldl(fun
(Key, {Props}) when is_list(Props) ->
- ?getv(Key, Props, nil);
+ couch_util:get_value(Key, Props, nil);
(_Key, Fun) when is_binary(Fun) ->
Fun;
(_Key, nil) ->
diff --git a/src/couchdb/couch_query_servers.erl b/src/couchdb/couch_query_servers.erl
index 85470a95..8dceba87 100644
--- a/src/couchdb/couch_query_servers.erl
+++ b/src/couchdb/couch_query_servers.erl
@@ -320,7 +320,7 @@ terminate(_Reason, #qserver{pid_procs=PidProcs}) ->
ok.
handle_call({get_proc, #doc{body={Props}}=DDoc, DDocKey}, From, Server) ->
- Lang = ?getv(<<"language">>, Props, <<"javascript">>),
+ Lang = couch_util:get_value(<<"language">>, Props, <<"javascript">>),
case lang_proc(Lang, Server, fun(Procs) ->
% find a proc in the set that has the DDoc
proc_with_ddoc(DDoc, DDocKey, Procs)
@@ -405,7 +405,7 @@ service_waitlist(#qserver{waitlist=Waitlist}=Server) ->
% todo get rid of duplication
service_waiting({{#doc{body={Props}}=DDoc, DDocKey}, From}, Server) ->
- Lang = ?getv(<<"language">>, Props, <<"javascript">>),
+ Lang = couch_util:get_value(<<"language">>, Props, <<"javascript">>),
case lang_proc(Lang, Server, fun(Procs) ->
% find a proc in the set that has the DDoc
proc_with_ddoc(DDoc, DDocKey, Procs)
@@ -522,7 +522,7 @@ get_ddoc_process(#doc{} = DDoc, DDocKey) ->
% process knows the ddoc
case (catch proc_prompt(Proc, [<<"reset">>, {QueryConfig}])) of
true ->
- proc_set_timeout(Proc, ?getv(<<"timeout">>, QueryConfig)),
+ proc_set_timeout(Proc, couch_util:get_value(<<"timeout">>, QueryConfig)),
link(Proc#proc.pid),
gen_server:call(couch_query_servers, {unlink_proc, Proc#proc.pid}),
Proc;
@@ -539,7 +539,7 @@ get_os_process(Lang) ->
{ok, Proc, {QueryConfig}} ->
case (catch proc_prompt(Proc, [<<"reset">>, {QueryConfig}])) of
true ->
- proc_set_timeout(Proc, ?getv(<<"timeout">>, QueryConfig)),
+ proc_set_timeout(Proc, couch_util:get_value(<<"timeout">>, QueryConfig)),
link(Proc#proc.pid),
gen_server:call(couch_query_servers, {unlink_proc, Proc#proc.pid}),
Proc;
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl
index 60cc4b80..3e029421 100644
--- a/src/couchdb/couch_rep.erl
+++ b/src/couchdb/couch_rep.erl
@@ -67,7 +67,7 @@ replicate(Source, Target) when is_binary(Source), is_binary(Target) ->
%% function handling POST to _replicate
replicate({Props}=PostBody, UserCtx) ->
RepId = make_replication_id(PostBody, UserCtx),
- case ?getv(<<"cancel">>, Props, false) of
+ case couch_util:get_value(<<"cancel">>, Props, false) of
true ->
end_replication(RepId);
false ->
@@ -101,7 +101,7 @@ checkpoint(Server) ->
gen_server:cast(Server, do_checkpoint).
get_result(Server, {BaseId, _Extension}, {Props} = PostBody, UserCtx) ->
- case ?getv(<<"continuous">>, Props, false) of
+ case couch_util:get_value(<<"continuous">>, Props, false) of
true ->
{ok, {continuous, ?l2b(BaseId)}};
false ->
@@ -125,15 +125,15 @@ init(InitArgs) ->
do_init([RepId, {PostProps} = RepDoc, UserCtx] = InitArgs) ->
process_flag(trap_exit, true),
- SourceProps = ?getv(<<"source">>, PostProps),
- TargetProps = ?getv(<<"target">>, PostProps),
+ SourceProps = couch_util:get_value(<<"source">>, PostProps),
+ TargetProps = couch_util:get_value(<<"target">>, PostProps),
- DocIds = ?getv(<<"doc_ids">>, PostProps, nil),
- Continuous = ?getv(<<"continuous">>, PostProps, false),
- CreateTarget = ?getv(<<"create_target">>, PostProps, false),
+ DocIds = couch_util:get_value(<<"doc_ids">>, PostProps, nil),
+ Continuous = couch_util:get_value(<<"continuous">>, PostProps, false),
+ CreateTarget = couch_util:get_value(<<"create_target">>, PostProps, false),
ProxyParams = parse_proxy_params(
- ?getv(<<"proxy">>, PostProps, [])),
+ couch_util:get_value(<<"proxy">>, PostProps, [])),
Source = open_db(SourceProps, UserCtx, ProxyParams),
Target = open_db(TargetProps, UserCtx, ProxyParams, CreateTarget),
@@ -209,8 +209,8 @@ do_init([RepId, {PostProps} = RepDoc, UserCtx] = InitArgs) ->
source_log = SourceLog,
target_log = TargetLog,
rep_starttime = httpd_util:rfc1123_date(),
- src_starttime = ?getv(instance_start_time, SourceInfo),
- tgt_starttime = ?getv(instance_start_time, TargetInfo),
+ src_starttime = couch_util:get_value(instance_start_time, SourceInfo),
+ tgt_starttime = couch_util:get_value(instance_start_time, TargetInfo),
doc_ids = DocIds,
rep_doc = RepDoc
},
@@ -329,17 +329,17 @@ start_replication_server(Replicator) ->
compare_replication_logs(SrcDoc, TgtDoc) ->
#doc{body={RepRecProps}} = SrcDoc,
#doc{body={RepRecPropsTgt}} = TgtDoc,
- case ?getv(<<"session_id">>, RepRecProps) ==
- ?getv(<<"session_id">>, RepRecPropsTgt) of
+ case couch_util:get_value(<<"session_id">>, RepRecProps) ==
+ couch_util:get_value(<<"session_id">>, RepRecPropsTgt) of
true ->
% if the records have the same session id,
% then we have a valid replication history
- OldSeqNum = ?getv(<<"source_last_seq">>, RepRecProps, 0),
- OldHistory = ?getv(<<"history">>, RepRecProps, []),
+ OldSeqNum = couch_util:get_value(<<"source_last_seq">>, RepRecProps, 0),
+ OldHistory = couch_util:get_value(<<"history">>, RepRecProps, []),
{OldSeqNum, OldHistory};
false ->
- SourceHistory = ?getv(<<"history">>, RepRecProps, []),
- TargetHistory = ?getv(<<"history">>, RepRecPropsTgt, []),
+ SourceHistory = couch_util:get_value(<<"history">>, RepRecProps, []),
+ TargetHistory = couch_util:get_value(<<"history">>, RepRecPropsTgt, []),
?LOG_INFO("Replication records differ. "
"Scanning histories to find a common ancestor.", []),
?LOG_DEBUG("Record on source:~p~nRecord on target:~p~n",
@@ -351,18 +351,18 @@ compare_rep_history(S, T) when S =:= [] orelse T =:= [] ->
?LOG_INFO("no common ancestry -- performing full replication", []),
{0, []};
compare_rep_history([{S}|SourceRest], [{T}|TargetRest]=Target) ->
- SourceId = ?getv(<<"session_id">>, S),
+ SourceId = couch_util:get_value(<<"session_id">>, S),
case has_session_id(SourceId, Target) of
true ->
- RecordSeqNum = ?getv(<<"recorded_seq">>, S, 0),
+ RecordSeqNum = couch_util:get_value(<<"recorded_seq">>, S, 0),
?LOG_INFO("found a common replication record with source_seq ~p",
[RecordSeqNum]),
{RecordSeqNum, SourceRest};
false ->
- TargetId = ?getv(<<"session_id">>, T),
+ TargetId = couch_util:get_value(<<"session_id">>, T),
case has_session_id(TargetId, SourceRest) of
true ->
- RecordSeqNum = ?getv(<<"recorded_seq">>, T, 0),
+ RecordSeqNum = couch_util:get_value(<<"recorded_seq">>, T, 0),
?LOG_INFO("found a common replication record with source_seq ~p",
[RecordSeqNum]),
{RecordSeqNum, TargetRest};
@@ -454,7 +454,7 @@ terminate_cleanup(#state{source=Source, target=Target, stats=Stats}) ->
has_session_id(_SessionId, []) ->
false;
has_session_id(SessionId, [{Props} | Rest]) ->
- case ?getv(<<"session_id">>, Props, nil) of
+ case couch_util:get_value(<<"session_id">>, Props, nil) of
SessionId ->
true;
_Else ->
@@ -464,7 +464,7 @@ has_session_id(SessionId, [{Props} | Rest]) ->
maybe_append_options(Options, {Props}) ->
lists:foldl(fun(Option, Acc) ->
Acc ++
- case ?getv(Option, Props, false) of
+ case couch_util:get_value(Option, Props, false) of
true ->
"+" ++ ?b2l(Option);
false ->
@@ -484,20 +484,20 @@ make_replication_id(RepProps, UserCtx) ->
make_replication_id({Props}, UserCtx, 2) ->
{ok, HostName} = inet:gethostname(),
Port = mochiweb_socket_server:get(couch_httpd, port),
- Src = get_rep_endpoint(UserCtx, ?getv(<<"source">>, Props)),
- Tgt = get_rep_endpoint(UserCtx, ?getv(<<"target">>, Props)),
+ Src = get_rep_endpoint(UserCtx, couch_util:get_value(<<"source">>, Props)),
+ Tgt = get_rep_endpoint(UserCtx, couch_util:get_value(<<"target">>, Props)),
maybe_append_filters({Props}, [HostName, Port, Src, Tgt], UserCtx);
make_replication_id({Props}, UserCtx, 1) ->
{ok, HostName} = inet:gethostname(),
- Src = get_rep_endpoint(UserCtx, ?getv(<<"source">>, Props)),
- Tgt = get_rep_endpoint(UserCtx, ?getv(<<"target">>, Props)),
+ Src = get_rep_endpoint(UserCtx, couch_util:get_value(<<"source">>, Props)),
+ Tgt = get_rep_endpoint(UserCtx, couch_util:get_value(<<"target">>, Props)),
maybe_append_filters({Props}, [HostName, Src, Tgt], UserCtx).
maybe_append_filters({Props}, Base, UserCtx) ->
Base2 = Base ++
- case ?getv(<<"filter">>, Props) of
+ case couch_util:get_value(<<"filter">>, Props) of
undefined ->
- case ?getv(<<"doc_ids">>, Props) of
+ case couch_util:get_value(<<"doc_ids">>, Props) of
undefined ->
[];
DocIds ->
@@ -505,15 +505,17 @@ maybe_append_filters({Props}, Base, UserCtx) ->
end;
Filter ->
[filter_code(Filter, Props, UserCtx),
- ?getv(<<"query_params">>, Props, {[]})]
+ couch_util:get_value(<<"query_params">>, Props, {[]})]
end,
couch_util:to_hex(couch_util:md5(term_to_binary(Base2))).
filter_code(Filter, Props, UserCtx) ->
{match, [DDocName, FilterName]} =
re:run(Filter, "(.*?)/(.*)", [{capture, [1, 2], binary}]),
- ProxyParams = parse_proxy_params(?getv(<<"proxy">>, Props, [])),
- Source = open_db(?getv(<<"source">>, Props), UserCtx, ProxyParams),
+ ProxyParams = parse_proxy_params(
+ couch_util:get_value(<<"proxy">>, Props, [])),
+ Source = open_db(
+ couch_util:get_value(<<"source">>, Props), UserCtx, ProxyParams),
try
{ok, DDoc} = open_doc(Source, <<"_design/", DDocName/binary>>),
Code = couch_util:get_nested_json_value(
@@ -527,10 +529,10 @@ maybe_add_trailing_slash(Url) ->
re:replace(Url, "[^/]$", "&/", [{return, list}]).
get_rep_endpoint(_UserCtx, {Props}) ->
- Url = maybe_add_trailing_slash(?getv(<<"url">>, Props)),
- {BinHeaders} = ?getv(<<"headers">>, Props, {[]}),
- {Auth} = ?getv(<<"auth">>, Props, {[]}),
- case ?getv(<<"oauth">>, Auth) of
+ Url = maybe_add_trailing_slash(couch_util:get_value(<<"url">>, Props)),
+ {BinHeaders} = couch_util:get_value(<<"headers">>, Props, {[]}),
+ {Auth} = couch_util:get_value(<<"auth">>, Props, {[]}),
+ case couch_util:get_value(<<"oauth">>, Auth) of
undefined ->
{remote, Url, [{?b2l(K),?b2l(V)} || {K,V} <- BinHeaders]};
{OAuth} ->
@@ -596,9 +598,9 @@ open_db(Props, UserCtx, ProxyParams) ->
open_db(Props, UserCtx, ProxyParams, false).
open_db({Props}, _UserCtx, ProxyParams, CreateTarget) ->
- Url = maybe_add_trailing_slash(?getv(<<"url">>, Props)),
- {AuthProps} = ?getv(<<"auth">>, Props, {[]}),
- {BinHeaders} = ?getv(<<"headers">>, Props, {[]}),
+ Url = maybe_add_trailing_slash(couch_util:get_value(<<"url">>, Props)),
+ {AuthProps} = couch_util:get_value(<<"auth">>, Props, {[]}),
+ {BinHeaders} = couch_util:get_value(<<"headers">>, Props, {[]}),
Headers = [{?b2l(K),?b2l(V)} || {K,V} <- BinHeaders],
DefaultHeaders = (#http_db{})#http_db.headers,
Db1 = #http_db{
@@ -738,8 +740,8 @@ ensure_full_commit(#http_db{headers = Headers} = Target) ->
headers = couch_util:proplist_apply_field({"Content-Type", "application/json"}, Headers)
},
{ResultProps} = couch_rep_httpc:request(Req),
- true = ?getv(<<"ok">>, ResultProps),
- ?getv(<<"instance_start_time">>, ResultProps);
+ true = couch_util:get_value(<<"ok">>, ResultProps),
+ couch_util:get_value(<<"instance_start_time">>, ResultProps);
ensure_full_commit(Target) ->
{ok, NewDb} = couch_db:open_int(Target#db.name, []),
UpdateSeq = couch_db:get_update_seq(Target),
@@ -764,9 +766,9 @@ ensure_full_commit(#http_db{headers = Headers} = Source, RequiredSeq) ->
headers = couch_util:proplist_apply_field({"Content-Type", "application/json"}, Headers)
},
{ResultProps} = couch_rep_httpc:request(Req),
- case ?getv(<<"ok">>, ResultProps) of
+ case couch_util:get_value(<<"ok">>, ResultProps) of
true ->
- ?getv(<<"instance_start_time">>, ResultProps);
+ couch_util:get_value(<<"instance_start_time">>, ResultProps);
undefined -> nil end;
ensure_full_commit(Source, RequiredSeq) ->
{ok, NewDb} = couch_db:open_int(Source#db.name, []),
@@ -791,7 +793,7 @@ update_local_doc(#http_db{} = Db, Doc) ->
headers = [{"x-couch-full-commit", "false"} | Db#http_db.headers]
},
{ResponseMembers} = couch_rep_httpc:request(Req),
- Rev = ?getv(<<"rev">>, ResponseMembers),
+ Rev = couch_util:get_value(<<"rev">>, ResponseMembers),
couch_doc:parse_rev(Rev);
update_local_doc(Db, Doc) ->
{ok, Result} = couch_db:update_doc(Db, Doc, [delay_commit]),
@@ -821,7 +823,7 @@ parse_proxy_params(ProxyUrl) ->
end.
update_rep_doc({Props} = _RepDoc, KVs) ->
- case ?getv(<<"_id">>, Props) of
+ case couch_util:get_value(<<"_id">>, Props) of
undefined ->
% replication triggered by POSTing to _replicate/
ok;
@@ -854,7 +856,7 @@ update_rep_doc(RepDb, #doc{body = {RepDocBody}} = RepDoc, KVs) ->
).
maybe_set_triggered({RepProps} = RepDoc, RepId) ->
- case ?getv(<<"state">>, RepProps) of
+ case couch_util:get_value(<<"state">>, RepProps) of
<<"triggered">> ->
ok;
_ ->
diff --git a/src/couchdb/couch_rep_changes_feed.erl b/src/couchdb/couch_rep_changes_feed.erl
index 773a2ced..7f7d3a38 100644
--- a/src/couchdb/couch_rep_changes_feed.erl
+++ b/src/couchdb/couch_rep_changes_feed.erl
@@ -48,7 +48,7 @@ stop(Server) ->
init([Parent, #http_db{}=Source, Since, PostProps]) ->
process_flag(trap_exit, true),
- Feed = case ?getv(<<"continuous">>, PostProps, false) of
+ Feed = case couch_util:get_value(<<"continuous">>, PostProps, false) of
false ->
normal;
true ->
@@ -60,11 +60,11 @@ init([Parent, #http_db{}=Source, Since, PostProps]) ->
{"since", Since},
{"feed", Feed}
],
- QS = case ?getv(<<"filter">>, PostProps) of
+ QS = case couch_util:get_value(<<"filter">>, PostProps) of
undefined ->
BaseQS;
FilterName ->
- {Params} = ?getv(<<"query_params">>, PostProps, {[]}),
+ {Params} = couch_util:get_value(<<"query_params">>, PostProps, {[]}),
lists:foldr(
fun({K, V}, QSAcc) ->
Ks = couch_util:to_list(K),
@@ -126,8 +126,8 @@ init([_Parent, Source, Since, PostProps] = InitArgs) ->
ChangesArgs = #changes_args{
style = all_docs,
since = Since,
- filter = ?b2l(?getv(<<"filter">>, PostProps, <<>>)),
- feed = case ?getv(<<"continuous">>, PostProps, false) of
+ filter = ?b2l(couch_util:get_value(<<"filter">>, PostProps, <<>>)),
+ feed = case couch_util:get_value(<<"continuous">>, PostProps, false) of
true ->
"continuous";
false ->
@@ -150,11 +150,11 @@ init([_Parent, Source, Since, PostProps] = InitArgs) ->
{ok, #state{changes_loop=ChangesPid, init_args=InitArgs}}.
filter_json_req(Db, PostProps) ->
- case ?getv(<<"filter">>, PostProps) of
+ case couch_util:get_value(<<"filter">>, PostProps) of
undefined ->
{[]};
FilterName ->
- {Query} = ?getv(<<"query_params">>, PostProps, {[]}),
+ {Query} = couch_util:get_value(<<"query_params">>, PostProps, {[]}),
{ok, Info} = couch_db:get_db_info(Db),
% simulate a request to db_name/_changes
{[
@@ -307,7 +307,7 @@ handle_messages([Chunk|Rest], State) ->
#state{reply_to=nil} ->
State#state{
count = Count+1,
- last_seq = ?getv(<<"seq">>, Props),
+ last_seq = couch_util:get_value(<<"seq">>, Props),
partial_chunk = <<>>,
rows=queue:in(Row,Rows)
};
@@ -354,16 +354,16 @@ by_seq_loop(Server, Source, StartSeq) ->
qs = [{limit, 1000}, {startkey, StartSeq}]
},
{Results} = couch_rep_httpc:request(Req),
- Rows = ?getv(<<"rows">>, Results),
+ Rows = couch_util:get_value(<<"rows">>, Results),
if Rows =:= [] -> exit(normal); true -> ok end,
EndSeq = lists:foldl(fun({RowInfoList}, _) ->
- Id = ?getv(<<"id">>, RowInfoList),
- Seq = ?getv(<<"key">>, RowInfoList),
- {RowProps} = ?getv(<<"value">>, RowInfoList),
+ Id = couch_util:get_value(<<"id">>, RowInfoList),
+ Seq = couch_util:get_value(<<"key">>, RowInfoList),
+ {RowProps} = couch_util:get_value(<<"value">>, RowInfoList),
RawRevs = [
- ?getv(<<"rev">>, RowProps),
- ?getv(<<"conflicts">>, RowProps, []),
- ?getv(<<"deleted_conflicts">>, RowProps, [])
+ couch_util:get_value(<<"rev">>, RowProps),
+ couch_util:get_value(<<"conflicts">>, RowProps, []),
+ couch_util:get_value(<<"deleted_conflicts">>, RowProps, [])
],
ParsedRevs = couch_doc:parse_revs(lists:flatten(RawRevs)),
Change = {[
diff --git a/src/couchdb/couch_rep_db_listener.erl b/src/couchdb/couch_rep_db_listener.erl
index d2a2978e..926b2987 100644
--- a/src/couchdb/couch_rep_db_listener.erl
+++ b/src/couchdb/couch_rep_db_listener.erl
@@ -142,7 +142,7 @@ consume_changes(ChangesQueue) ->
has_valid_rep_id({Change}) ->
- has_valid_rep_id(?getv(<<"id">>, Change));
+ has_valid_rep_id(couch_util:get_value(<<"id">>, Change));
has_valid_rep_id(<<?DESIGN_DOC_PREFIX, _Rest/binary>>) ->
false;
has_valid_rep_id(_Else) ->
@@ -150,12 +150,12 @@ has_valid_rep_id(_Else) ->
process_change({Change}) ->
- {RepProps} = JsonRepDoc = ?getv(doc, Change),
- case ?getv(<<"deleted">>, Change, false) of
+ {RepProps} = JsonRepDoc = couch_util:get_value(doc, Change),
+ case couch_util:get_value(<<"deleted">>, Change, false) of
true ->
maybe_stop_replication(JsonRepDoc);
false ->
- case ?getv(<<"state">>, RepProps) of
+ case couch_util:get_value(<<"state">>, RepProps) of
<<"completed">> ->
maybe_stop_replication(JsonRepDoc);
<<"error">> ->
@@ -164,7 +164,7 @@ process_change({Change}) ->
<<"triggered">> ->
maybe_start_replication(JsonRepDoc);
undefined ->
- case ?getv(<<"replication_id">>, RepProps) of
+ case couch_util:get_value(<<"replication_id">>, RepProps) of
undefined ->
maybe_start_replication(JsonRepDoc);
_ ->
@@ -176,13 +176,13 @@ process_change({Change}) ->
rep_user_ctx({RepDoc}) ->
- case ?getv(<<"user_ctx">>, RepDoc) of
+ case couch_util:get_value(<<"user_ctx">>, RepDoc) of
undefined ->
#user_ctx{roles = [<<"_admin">>]};
{UserCtx} ->
#user_ctx{
- name = ?getv(<<"name">>, UserCtx, null),
- roles = ?getv(<<"roles">>, UserCtx, [])
+ name = couch_util:get_value(<<"name">>, UserCtx, null),
+ roles = couch_util:get_value(<<"roles">>, UserCtx, [])
}
end.
@@ -190,7 +190,7 @@ rep_user_ctx({RepDoc}) ->
maybe_start_replication({RepProps} = JsonRepDoc) ->
UserCtx = rep_user_ctx(JsonRepDoc),
RepId = couch_rep:make_replication_id(JsonRepDoc, UserCtx),
- DocId = ?getv(<<"_id">>, RepProps),
+ DocId = couch_util:get_value(<<"_id">>, RepProps),
case ets:lookup(?REP_ID_TO_DOC_ID_MAP, RepId) of
[] ->
true = ets:insert(?REP_ID_TO_DOC_ID_MAP, {RepId, DocId}),
@@ -222,7 +222,7 @@ start_replication(RepDoc, RepId, UserCtx) ->
maybe_stop_replication({RepProps}) ->
- DocId = ?getv(<<"_id">>, RepProps),
+ DocId = couch_util:get_value(<<"_id">>, RepProps),
case ets:lookup(?DOC_TO_REP_ID_MAP, DocId) of
[{DocId, RepId}] ->
couch_rep:end_replication(RepId),
diff --git a/src/couchdb/couch_rep_httpc.erl b/src/couchdb/couch_rep_httpc.erl
index 0b5b5328..06d4748a 100644
--- a/src/couchdb/couch_rep_httpc.erl
+++ b/src/couchdb/couch_rep_httpc.erl
@@ -34,7 +34,7 @@ do_request(Req) ->
qs = QS
} = Req,
Url = full_url(Req),
- Headers = case ?getv(<<"oauth">>, Auth) of
+ Headers = case couch_util:get_value(<<"oauth">>, Auth) of
undefined ->
Headers0;
{OAuthProps} ->
@@ -76,7 +76,7 @@ db_exists(Req, CanonicalUrl, CreateDB) ->
url = Url
} = Req,
HeadersFun = fun(Method) ->
- case ?getv(<<"oauth">>, Auth) of
+ case couch_util:get_value(<<"oauth">>, Auth) of
undefined ->
Headers0;
{OAuthProps} ->
@@ -190,7 +190,7 @@ process_response({error, Reason}, Req) ->
redirected_request(Req, RedirectUrl) ->
{Base, QStr, _} = mochiweb_util:urlsplit_path(RedirectUrl),
QS = mochiweb_util:parse_qs(QStr),
- Hdrs = case ?getv(<<"oauth">>, Req#http_db.auth) of
+ Hdrs = case couch_util:get_value(<<"oauth">>, Req#http_db.auth) of
undefined ->
Req#http_db.headers;
_Else ->
@@ -220,11 +220,11 @@ oauth_header(Url, QS, Action, Props) ->
% erlang-oauth doesn't like iolists
QSL = [{couch_util:to_list(K), ?b2l(?l2b(couch_util:to_list(V)))} ||
{K,V} <- QS],
- ConsumerKey = ?b2l(?getv(<<"consumer_key">>, Props)),
- Token = ?b2l(?getv(<<"token">>, Props)),
- TokenSecret = ?b2l(?getv(<<"token_secret">>, Props)),
- ConsumerSecret = ?b2l(?getv(<<"consumer_secret">>, Props)),
- SignatureMethodStr = ?b2l(?getv(<<"signature_method">>, Props, <<"HMAC-SHA1">>)),
+ ConsumerKey = ?b2l(couch_util:get_value(<<"consumer_key">>, Props)),
+ Token = ?b2l(couch_util:get_value(<<"token">>, Props)),
+ TokenSecret = ?b2l(couch_util:get_value(<<"token_secret">>, Props)),
+ ConsumerSecret = ?b2l(couch_util:get_value(<<"consumer_secret">>, Props)),
+ SignatureMethodStr = ?b2l(couch_util:get_value(<<"signature_method">>, Props, <<"HMAC-SHA1">>)),
SignatureMethodAtom = case SignatureMethodStr of
"PLAINTEXT" ->
plaintext;
diff --git a/src/couchdb/couch_rep_missing_revs.erl b/src/couchdb/couch_rep_missing_revs.erl
index 6e46c1ce..1eff6774 100644
--- a/src/couchdb/couch_rep_missing_revs.erl
+++ b/src/couchdb/couch_rep_missing_revs.erl
@@ -145,44 +145,44 @@ changes_loop(OurServer, SourceChangesServer, Target) ->
get_missing_revs(#http_db{}=Target, Changes) ->
Transform = fun({Props}) ->
- C = ?getv(<<"changes">>, Props),
- Id = ?getv(<<"id">>, Props),
+ C = couch_util:get_value(<<"changes">>, Props),
+ Id = couch_util:get_value(<<"id">>, Props),
{Id, [R || {[{<<"rev">>, R}]} <- C]}
end,
IdRevsList = [Transform(Change) || Change <- Changes],
SeqDict = changes_dictionary(Changes),
{LastProps} = lists:last(Changes),
- HighSeq = ?getv(<<"seq">>, LastProps),
+ HighSeq = couch_util:get_value(<<"seq">>, LastProps),
Request = Target#http_db{
resource = "_missing_revs",
method = post,
body = {IdRevsList}
},
{Resp} = couch_rep_httpc:request(Request),
- case ?getv(<<"missing_revs">>, Resp) of
+ case couch_util:get_value(<<"missing_revs">>, Resp) of
{MissingRevs} ->
X = [{Id, dict:fetch(Id, SeqDict), couch_doc:parse_revs(RevStrs)} ||
{Id,RevStrs} <- MissingRevs],
{HighSeq, X};
_ ->
- exit({target_error, ?getv(<<"error">>, Resp)})
+ exit({target_error, couch_util:get_value(<<"error">>, Resp)})
end;
get_missing_revs(Target, Changes) ->
Transform = fun({Props}) ->
- C = ?getv(<<"changes">>, Props),
- Id = ?getv(<<"id">>, Props),
+ C = couch_util:get_value(<<"changes">>, Props),
+ Id = couch_util:get_value(<<"id">>, Props),
{Id, [couch_doc:parse_rev(R) || {[{<<"rev">>, R}]} <- C]}
end,
IdRevsList = [Transform(Change) || Change <- Changes],
SeqDict = changes_dictionary(Changes),
{LastProps} = lists:last(Changes),
- HighSeq = ?getv(<<"seq">>, LastProps),
+ HighSeq = couch_util:get_value(<<"seq">>, LastProps),
{ok, Results} = couch_db:get_missing_revs(Target, IdRevsList),
{HighSeq, [{Id, dict:fetch(Id, SeqDict), Revs} || {Id, Revs, _} <- Results]}.
changes_dictionary(ChangeList) ->
- KVs = [{?getv(<<"id">>,C), ?getv(<<"seq">>,C)}
+ KVs = [{couch_util:get_value(<<"id">>,C), couch_util:get_value(<<"seq">>,C)}
|| {C} <- ChangeList],
dict:from_list(KVs).
diff --git a/src/couchdb/couch_rep_reader.erl b/src/couchdb/couch_rep_reader.erl
index 1e496acf..4f81c8e4 100644
--- a/src/couchdb/couch_rep_reader.erl
+++ b/src/couchdb/couch_rep_reader.erl
@@ -253,7 +253,7 @@ open_doc_revs(#http_db{url = Url} = DbS, DocId, Revs) ->
},
[Doc1 | Acc];
({ErrorProps}, Acc) ->
- Err = ?getv(<<"error">>, ErrorProps,
+ Err = couch_util:get_value(<<"error">>, ErrorProps,
?JSON_ENCODE({ErrorProps})),
?LOG_ERROR("Replicator: error accessing doc ~s at ~s, reason: ~s",
[DocId, couch_util:url_strip_password(Url), Err]),
@@ -268,14 +268,14 @@ open_doc(#http_db{url = Url} = DbS, DocId) ->
qs=[{att_encoding_info, true}]
},
{Props} = Json = couch_rep_httpc:request(Req),
- case ?getv(<<"_id">>, Props) of
+ case couch_util:get_value(<<"_id">>, Props) of
Id when is_binary(Id) ->
#doc{id=Id, revs=Rev, atts=Atts} = Doc = couch_doc:from_json_obj(Json),
[Doc#doc{
atts=[couch_rep_att:convert_stub(A, {DbS,Id,Rev}) || A <- Atts]
}];
undefined ->
- Err = ?getv(<<"error">>, Props, ?JSON_ENCODE(Json)),
+ Err = couch_util:get_value(<<"error">>, Props, ?JSON_ENCODE(Json)),
?LOG_ERROR("Replicator: error accessing doc ~s at ~s, reason: ~s",
[DocId, couch_util:url_strip_password(Url), Err]),
[]
diff --git a/src/couchdb/couch_rep_writer.erl b/src/couchdb/couch_rep_writer.erl
index 47de670a..f7bc9a72 100644
--- a/src/couchdb/couch_rep_writer.erl
+++ b/src/couchdb/couch_rep_writer.erl
@@ -80,7 +80,7 @@ write_bulk_docs(#http_db{headers = Headers} = Db, Docs) ->
},
ErrorsJson = case couch_rep_httpc:request(Request) of
{FailProps} ->
- exit({target_error, ?getv(<<"error">>, FailProps)});
+ exit({target_error, couch_util:get_value(<<"error">>, FailProps)});
List when is_list(List) ->
List
end,
@@ -164,8 +164,8 @@ streamer_fun(Boundary, JsonBytes, Atts) ->
end.
write_docs_1({Props}) ->
- Id = ?getv(<<"id">>, Props),
- Rev = couch_doc:parse_rev(?getv(<<"rev">>, Props)),
- ErrId = couch_util:to_existing_atom(?getv(<<"error">>, Props)),
- Reason = ?getv(<<"reason">>, Props),
+ Id = couch_util:get_value(<<"id">>, Props),
+ Rev = couch_doc:parse_rev(couch_util:get_value(<<"rev">>, Props)),
+ ErrId = couch_util:to_existing_atom(couch_util:get_value(<<"error">>, Props)),
+ Reason = couch_util:get_value(<<"reason">>, Props),
{{Id, Rev}, {ErrId, Reason}}.
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl
index 5f536d3d..2d96d5f3 100644
--- a/src/couchdb/couch_server.erl
+++ b/src/couchdb/couch_server.erl
@@ -53,7 +53,7 @@ sup_start_link() ->
open(DbName, Options) ->
case gen_server:call(couch_server, {open, DbName, Options}, infinity) of
{ok, Db} ->
- Ctx = ?getv(user_ctx, Options, #user_ctx{}),
+ Ctx = couch_util:get_value(user_ctx, Options, #user_ctx{}),
{ok, Db#db{user_ctx=Ctx}};
Error ->
Error
@@ -62,7 +62,7 @@ open(DbName, Options) ->
create(DbName, Options) ->
case gen_server:call(couch_server, {create, DbName, Options}, infinity) of
{ok, Db} ->
- Ctx = ?getv(user_ctx, Options, #user_ctx{}),
+ Ctx = couch_util:get_value(user_ctx, Options, #user_ctx{}),
{ok, Db#db{user_ctx=Ctx}};
Error ->
Error
diff --git a/src/couchdb/couch_stream.erl b/src/couchdb/couch_stream.erl
index 4ba1fa93..60af1c2b 100644
--- a/src/couchdb/couch_stream.erl
+++ b/src/couchdb/couch_stream.erl
@@ -173,7 +173,7 @@ foldl_decode(DecFun, Fd, [Pos|Rest], Md5, Md5Acc, Fun, Acc) ->
foldl_decode(DecFun, Fd, Rest, Md5, Md5Acc2, Fun, Fun(Bin, Acc)).
gzip_init(Options) ->
- case ?getv(compression_level, Options, 0) of
+ case couch_util:get_value(compression_level, Options, 0) of
Lvl when Lvl >= 1 andalso Lvl =< 9 ->
Z = zlib:open(),
% 15 = ?MAX_WBITS (defined in the zlib module)
diff --git a/src/couchdb/couch_view.erl b/src/couchdb/couch_view.erl
index 19b6ee7f..35bc80b6 100644
--- a/src/couchdb/couch_view.erl
+++ b/src/couchdb/couch_view.erl
@@ -91,7 +91,7 @@ cleanup_index_files(Db) ->
% make unique list of group sigs
Sigs = lists:map(fun(#doc{id = GroupId}) ->
{ok, Info} = get_group_info(Db, GroupId),
- ?b2l(?getv(signature, Info))
+ ?b2l(couch_util:get_value(signature, Info))
end, [DD||DD <- DesignDocs, DD#doc.deleted == false]),
FileList = list_index_files(Db),
diff --git a/src/couchdb/couch_view_group.erl b/src/couchdb/couch_view_group.erl
index 86e41b89..2f59f8e3 100644
--- a/src/couchdb/couch_view_group.erl
+++ b/src/couchdb/couch_view_group.erl
@@ -519,19 +519,19 @@ get_group_info(State) ->
% maybe move to another module
design_doc_to_view_group(#doc{id=Id,body={Fields}}) ->
- Language = ?getv(<<"language">>, Fields, <<"javascript">>),
- {DesignOptions} = ?getv(<<"options">>, Fields, {[]}),
- {RawViews} = ?getv(<<"views">>, Fields, {[]}),
- Lib = ?getv(<<"lib">>, RawViews, {[]}),
+ Language = couch_util:get_value(<<"language">>, Fields, <<"javascript">>),
+ {DesignOptions} = couch_util:get_value(<<"options">>, Fields, {[]}),
+ {RawViews} = couch_util:get_value(<<"views">>, Fields, {[]}),
+ Lib = couch_util:get_value(<<"lib">>, RawViews, {[]}),
% add the views to a dictionary object, with the map source as the key
DictBySrc =
lists:foldl(
fun({Name, {MRFuns}}, DictBySrcAcc) ->
- case ?getv(<<"map">>, MRFuns) of
+ case couch_util:get_value(<<"map">>, MRFuns) of
undefined -> DictBySrcAcc;
MapSrc ->
- RedSrc = ?getv(<<"reduce">>, MRFuns, null),
- {ViewOptions} = ?getv(<<"options">>, MRFuns, {[]}),
+ RedSrc = couch_util:get_value(<<"reduce">>, MRFuns, null),
+ {ViewOptions} = couch_util:get_value(<<"options">>, MRFuns, {[]}),
View =
case dict:find({MapSrc, ViewOptions}, DictBySrcAcc) of
{ok, View0} -> View0;
@@ -594,7 +594,7 @@ init_group(Db, Fd, #group{def_lang=Lang,views=Views}=
{Count, Reduced}
end,
- case ?getv(<<"collation">>, Options, <<"default">>) of
+ case couch_util:get_value(<<"collation">>, Options, <<"default">>) of
<<"default">> ->
Less = fun couch_view:less_json_ids/2;
<<"raw">> ->
diff --git a/src/couchdb/couch_view_updater.erl b/src/couchdb/couch_view_updater.erl
index 87a15f77..bfef73ba 100644
--- a/src/couchdb/couch_view_updater.erl
+++ b/src/couchdb/couch_view_updater.erl
@@ -51,9 +51,9 @@ update(Owner, Group) ->
% update status every half second
couch_task_status:set_update_frequency(500),
#group{ design_options = DesignOptions } = Group,
- IncludeDesign = ?getv(<<"include_design">>,
+ IncludeDesign = couch_util:get_value(<<"include_design">>,
DesignOptions, false),
- LocalSeq = ?getv(<<"local_seq">>, DesignOptions, false),
+ LocalSeq = couch_util:get_value(<<"local_seq">>, DesignOptions, false),
DocOpts =
case LocalSeq of
true -> [conflicts, deleted_conflicts, local_seq];
diff --git a/src/couchdb/couch_work_queue.erl b/src/couchdb/couch_work_queue.erl
index 2ec748f5..13ec7335 100644
--- a/src/couchdb/couch_work_queue.erl
+++ b/src/couchdb/couch_work_queue.erl
@@ -20,8 +20,6 @@
-export([init/1, terminate/2]).
-export([handle_call/3, handle_cast/2, code_change/3, handle_info/2]).
--include("couch_db.hrl").
-
-record(q, {
queue = queue:new(),
blocked = [],
@@ -61,9 +59,9 @@ close(Wq) ->
init(Options) ->
Q = #q{
- max_size = ?getv(max_size, Options),
- max_items = ?getv(max_items, Options),
- multi_workers = ?getv(multi_workers, Options, false)
+ max_size = couch_util:get_value(max_size, Options),
+ max_items = couch_util:get_value(max_items, Options),
+ multi_workers = couch_util:get_value(multi_workers, Options, false)
},
{ok, Q}.