-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_query.lua
More file actions
117 lines (102 loc) · 2.64 KB
/
example_query.lua
File metadata and controls
117 lines (102 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
function query1()
local r_start, r_end = en_span_range()
local ids = {}
for i = r_start, r_end do
if en_child_cnt(i) > 2 then
table.insert(ids, i)
end
end
return ids
end
function query4()
local r_start, r_end = en_span_range()
local ids = {}
for i = r_start, r_end do
if not en_contains_anywhere(i, "winit") then
table.insert(ids, i)
end
end
return ids
end
function query5()
local r_start, r_end = en_span_range()
local ids = {}
for i = r_start, r_end do
local msg_cnt = en_attr_by_name(i, "msg_idx")
if msg_cnt ~= nil and math.fmod(msg_cnt, 2) == 1 then
table.insert(ids, i)
end
end
return ids
end
function query6()
local r_start, r_end = en_span_range()
local ids = {}
for i = r_start, r_end do
local is_winit = en_metadata_target(i) == "winit::window"
local log_module_path = en_attr_by_name(i, "log.module_path")
local is_eframe_related = log_module_path ~= nil and string.match(log_module_path, "eframe")
if is_winit or is_eframe_related then
table.insert(ids, i)
end
end
return ids
end
function query7()
local r_start, r_end = en_span_range()
local ids = {}
for i = r_start, r_end do
local node_value = en_attr_by_name(i, "node_value")
if node_value and node_value >= "d3" then
table.insert(ids, i)
end
end
return ids
end
-- equivalent to query7(), but about 2x faster.
function query8()
local r_start, r_end = en_span_range()
filter_settings = {
target = "node_value",
relation = "GT",
value = "d3",
}
filtered = en_filter_range(r_start, r_end, filter_settings)
return filtered
end
-- we are looking for the spans where
-- message = "constructed node"
-- breadth > 1
-- This is the "old fashioned" no filterset implementation
function query9()
local rstart, rend = en_span_range()
local ids = {}
for i = rstart, rend do
local message_matches = en_attr_by_name(i, "message") == "constructed node"
if message_matches and (en_attr_by_name(i, "breadth") > 1) then
table.insert(ids, i)
end
end
return ids
end
function query10()
local rstart, rend = en_span_range()
local base = en_filterset_from_range(rstart, rend)
msg_filter_desc = { target = "message", value = "constructed node", relation = "EQ" }
local message_matches = en_filter(msg_filter_desc, base)
breadth_filter_desc = { target = "breadth", value = 1, relation = "GT" }
local breadth_matches = en_filter(breadth_filter_desc, message_matches)
final = breadth_matches
materialized = en_filterset_materialize(final)
return materialized
end
function query11()
local rstart, rend = en_span_range()
local ids = {}
for i = rstart, rend do
table.insert(ids, i)
end
joined = en_join(ids)
table.sort(joined)
return joined
end