1/* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17DROP TABLE IF EXISTS tracing_mark_write_split; 18 19CREATE TABLE tracing_mark_write_split ( 20 raw_ftrace_entry_id INT REFERENCES raw_ftrace_entries (id), 21 atrace_type CHAR(1), -- only null for the first 2 sync timers. usually 'B', 'C', E', ... 22 atrace_pid INT, -- only null for first 2 sync timers 23 atrace_message, -- usually null for type='E' etc. 24 atrace_count, -- usually non-null only for 'C' 25 26 UNIQUE(raw_ftrace_entry_id) -- drops redundant inserts into table 27); 28 29INSERT INTO tracing_mark_write_split 30WITH 31 pivoted AS ( 32 SELECT tx.predictorset_id, 33 --ty.predictorset_id, 34 --tz.predictorset_id, 35 --tzz.predictorset_id, 36 tx.predictor_name AS atrace_type, 37 CAST(ty.predictor_name AS integer) AS atrace_pid, 38 tz.predictor_name AS atrace_message, 39 CAST(tzz.predictor_name AS integer) AS atrace_count 40 FROM (SELECT * from tracing_mark_write_split_array WHERE gen = 1) AS tx 41 LEFT JOIN 42 (SELECT * FROM tracing_mark_write_split_array WHERE gen = 2) AS ty 43 ON tx.predictorset_id = ty.predictorset_id 44 LEFT JOIN 45 (SELECT * FROM tracing_mark_write_split_array WHERE gen = 3) AS tz 46 ON tx.predictorset_id = tz.predictorset_id 47 LEFT JOIN 48 (SELECT * FROM tracing_mark_write_split_array WHERE gen = 4) AS tzz 49 ON tx.predictorset_id = tzz.predictorset_id 50 ) 51SELECT * from pivoted ORDER BY predictorset_id;-- LIMIT 100; 52 53SELECT * FROM tracing_mark_write_split; 54