Skip to content

Commit f666260

Browse files
committed
Java: Add meta query for metrics gathering
Exposes the same information as the existing queries through two query predicates instead. This makes the downstream data gathering a bit more convenient to implement.
1 parent 36c6c72 commit f666260

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* This file contains query predicates for use when gathering metrics at scale using Multi Repo
3+
* Variant Analysis.
4+
*/
5+
6+
private import java
7+
private import AutomodelAlertSinkUtil
8+
9+
query predicate sinkModelCountPerQuery(
10+
string queryId, int alertCount, string package, string type, boolean subtypes, string name,
11+
string signature, string input, string ext, string kind, string provenance
12+
) {
13+
exists(SinkModel s |
14+
sinkModelTallyPerQuery(queryId, alertCount, s) and
15+
s.getProvenance() = "ai-generated" and
16+
s.getPackage() = package and
17+
s.getType() = type and
18+
s.getSubtypes() = subtypes and
19+
s.getName() = name and
20+
s.getSignature() = signature and
21+
s.getInput() = input and
22+
s.getExt() = ext and
23+
s.getKind() = kind and
24+
s.getProvenance() = provenance
25+
)
26+
}
27+
28+
query predicate instanceCount(
29+
int instanceCount, string package, string type, boolean subtypes, string name, string signature,
30+
string input, string ext, string kind, string provenance
31+
) {
32+
exists(SinkModel s |
33+
instanceCount = s.getInstanceCount() and
34+
instanceCount > 0 and
35+
s.getProvenance() = "ai-generated" and
36+
s.getPackage() = package and
37+
s.getType() = type and
38+
s.getSubtypes() = subtypes and
39+
s.getName() = name and
40+
s.getSignature() = signature and
41+
s.getInput() = input and
42+
s.getExt() = ext and
43+
s.getKind() = kind and
44+
s.getProvenance() = provenance
45+
)
46+
}
47+
48+
// MRVA requires a select clause, so we repurpose it to tell us which query predicates had results.
49+
from string hadResults
50+
where
51+
sinkModelCountPerQuery(_, _, _, _, _, _, _, _, _, _, _) and hadResults = "sinkModelCountPerQuery"
52+
or
53+
instanceCount(_, _, _, _, _, _, _, _, _, _) and hadResults = "instanceCount"
54+
select hadResults

0 commit comments

Comments
 (0)