summaryrefslogtreecommitdiff
path: root/startop/scripts/trace_analyzer/queries_all.sql
blob: 41d1c0804a7f67a6b288b49696699272e16d1fb3 (plain)
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
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

-- filter for atrace writes
CREATE VIEW IF NOT EXISTS tracing_mark_writes AS
    SELECT *
      FROM raw_ftrace_entries
     WHERE function = 'tracing_mark_write';

-- split the tracing_mark_write function args by ||s
DROP TABLE IF exists tracing_mark_write_split_array;

CREATE TABLE tracing_mark_write_split_array (
    predictorset_id INT REFERENCES raw_ftrace_entries (id),
    predictor_name,
    rest,
    gen,
    
    UNIQUE(predictorset_id, gen) -- drops redundant inserts into table
);

CREATE INDEX "tracing_mark_write_split_array_id" ON tracing_mark_write_split_array (
    predictorset_id COLLATE BINARY COLLATE BINARY
);

INSERT INTO tracing_mark_write_split_array
  WITH 
    split(predictorset_id, predictor_name, rest, gen) AS (
      -- split by |
      SELECT id, '', function_args || '|', 0 FROM tracing_mark_writes WHERE id
       UNION ALL
      SELECT predictorset_id, 
             substr(rest, 0, instr(rest, '|')),
             substr(rest, instr(rest, '|')+1),
             gen + 1
        FROM split
       WHERE rest <> ''),
     split_results AS (
       SELECT * FROM split WHERE predictor_name <> ''
     )
  SELECT * from split_results
;