MCPcopy Index your code
hub / github.com/idank/explainshell / collect_sample_srcs

Function collect_sample_srcs

tools/bench_src_index.py:52–84  ·  view source on GitHub ↗

Return three lists of src values for benchmarking. - single_dst: src values that map to exactly 1 destination (common case) - multi_dst: src values that map to >1 destination - subcommand: src values containing a space (e.g. 'git commit')

(
    conn: sqlite3.Connection, n: int
)

Source from the content-addressed store, hash-verified

50
51
52def collect_sample_srcs(
53 conn: sqlite3.Connection, n: int
54) -> tuple[list[str], list[str], list[str]]:
55 """Return three lists of src values for benchmarking.
56
57 - single_dst: src values that map to exactly 1 destination (common case)
58 - multi_dst: src values that map to >1 destination
59 - subcommand: src values containing a space (e.g. 'git commit')
60 """
61 single = [
62 r[0]
63 for r in conn.execute(
64 "SELECT src FROM mappings GROUP BY src HAVING COUNT(*) = 1 "
65 "ORDER BY RANDOM() LIMIT ?",
66 (n,),
67 ).fetchall()
68 ]
69 multi = [
70 r[0]
71 for r in conn.execute(
72 "SELECT src FROM mappings GROUP BY src HAVING COUNT(*) > 1 "
73 "ORDER BY RANDOM() LIMIT ?",
74 (n,),
75 ).fetchall()
76 ]
77 subcmd = [
78 r[0]
79 for r in conn.execute(
80 "SELECT src FROM mappings WHERE src LIKE '% %' ORDER BY RANDOM() LIMIT ?",
81 (n,),
82 ).fetchall()
83 ]
84 return single, multi, subcmd
85
86
87def bench_query(

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected