rnewson commented on a change in pull request #1605: Feature/user partitioned 
databases
URL: https://github.com/apache/couchdb/pull/1605#discussion_r227798339
 
 

 ##########
 File path: src/couch/src/couch_bt_engine.erl
 ##########
 @@ -283,6 +340,31 @@ get_security(#st{header = Header} = St) ->
     end.
 
 
+get_props(#st{header = Header} = St) ->
+    case couch_bt_engine_header:get(Header, props_ptr) of
+        undefined ->
+            [];
+        Pointer ->
+            {ok, Props} = couch_file:pread_term(St#st.fd, Pointer),
+            Props
+    end.
+
+
+get_prop(St, Key) ->
+    Props = get_props(St),
+    case lists:keyfind(Key, 1, Props) of
+        false -> {error, no_value};
+        {Key, Value} -> {ok, Value}
+    end.
+
+
+get_prop(St, Key, DefaultValue) ->
+    case get_prop(St, Key) of
+        {error, no_value} -> DefaultValue;
+        Value -> Value
 
 Review comment:
   This was intentional but I see your point. get_prop/3 will always return a 
value whereas get_prop/2 might not, which is why the result shape is different. 
We could change get_prop/2 to return `Value` or `undefined` instead, which 
matches proplists:get_value behaviour.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to