You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2017/03/01 16:38:56 UTC

[09/50] couch commit: updated refs/heads/2971-count-distinct to ee32cd5

Add couch_debug:opened_files_contains/1

couch_debug:opened_files_contains is an efficient way to find out list
of file descriptors or couch_file processes which path contains given
substring.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/3888faf8
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/3888faf8
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/3888faf8

Branch: refs/heads/2971-count-distinct
Commit: 3888faf8182a4f33de37f8fe3852c08e7cefc107
Parents: 8553050
Author: ILYA Khlopotov <ii...@apache.org>
Authored: Fri Oct 21 11:51:05 2016 -0700
Committer: ILYA Khlopotov <ii...@apache.org>
Committed: Fri Oct 21 11:51:05 2016 -0700

----------------------------------------------------------------------
 src/couch_debug.erl | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/3888faf8/src/couch_debug.erl
----------------------------------------------------------------------
diff --git a/src/couch_debug.erl b/src/couch_debug.erl
index e2d5ea1..633b2c6 100644
--- a/src/couch_debug.erl
+++ b/src/couch_debug.erl
@@ -14,7 +14,8 @@
 
 -export([
     opened_files/0,
-    opened_files_by_regexp/1
+    opened_files_by_regexp/1,
+    opened_files_contains/1
 ]).
 
 -spec opened_files() ->
@@ -42,3 +43,10 @@ opened_files_by_regexp(FileRegExp) ->
     lists:filter(fun({_Port, _Pid, _Fd, Path}) ->
         re:run(Path, RegExp) =/= nomatch
     end, couch_debug:opened_files()).
+
+-spec opened_files_contains(FileNameFragment :: iodata()) ->
+    [{port(), CouchFilePid :: pid(), Fd :: pid() | tuple(), FilePath :: string()}].
+opened_files_contains(FileNameFragment) ->
+    lists:filter(fun({_Port, _Pid, _Fd, Path}) ->
+        string:str(Path, FileNameFragment) > 0
+    end, couch_debug:opened_files()).