• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "memory_rs_image_table.h"
17 
18 namespace SysTuning {
19 namespace TraceStreamer {
20 enum class Index : int32_t {
21     ID = 0,
22     IPID,
23     TS,
24     MEM_SIZE,
25     TYPE_INDEX,
26     SURFACE_NAME_INDEX,
27 };
MemoryRSImageTable(const TraceDataCache * dataCache)28 MemoryRSImageTable::MemoryRSImageTable(const TraceDataCache *dataCache) : TableBase(dataCache)
29 {
30     tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER"));
31     tableColumn_.push_back(TableBase::ColumnInfo("ipid", "INTEGER"));
32     tableColumn_.push_back(TableBase::ColumnInfo("ts", "INTEGER"));
33     tableColumn_.push_back(TableBase::ColumnInfo("mem_size", "INTEGER"));
34     tableColumn_.push_back(TableBase::ColumnInfo("type_id", "INTEGER"));
35     tableColumn_.push_back(TableBase::ColumnInfo("surface_name_id", "INTEGER"));
36     tablePriKey_.push_back("id");
37 }
38 
~MemoryRSImageTable()39 MemoryRSImageTable::~MemoryRSImageTable() {}
40 
CreateCursor()41 std::unique_ptr<TableBase::Cursor> MemoryRSImageTable::CreateCursor()
42 {
43     return std::make_unique<Cursor>(dataCache_, this);
44 }
45 
Cursor(const TraceDataCache * dataCache,TableBase * table)46 MemoryRSImageTable::Cursor::Cursor(const TraceDataCache *dataCache, TableBase *table)
47     : TableBase::Cursor(dataCache, table, static_cast<uint32_t>(dataCache->GetConstRSImageDumpInfo().Size())),
48       rsImageDumpInfoObj_(dataCache->GetConstRSImageDumpInfo())
49 {
50 }
51 
~Cursor()52 MemoryRSImageTable::Cursor::~Cursor() {}
53 
Column(int32_t column) const54 int32_t MemoryRSImageTable::Cursor::Column(int32_t column) const
55 {
56     switch (static_cast<Index>(column)) {
57         case Index::ID:
58             sqlite3_result_int64(context_, rsImageDumpInfoObj_.IdsData()[CurrentRow()]);
59             break;
60         case Index::IPID:
61             if (rsImageDumpInfoObj_.Ipids()[CurrentRow()] != INVALID_IPID) {
62                 sqlite3_result_int64(context_, rsImageDumpInfoObj_.Ipids()[CurrentRow()]);
63             }
64             break;
65         case Index::TS:
66             sqlite3_result_int64(context_, rsImageDumpInfoObj_.TimeStampData()[CurrentRow()]);
67             break;
68         case Index::MEM_SIZE:
69             sqlite3_result_int64(context_, rsImageDumpInfoObj_.MemSizes()[CurrentRow()]);
70             break;
71         case Index::TYPE_INDEX:
72             sqlite3_result_int64(context_, rsImageDumpInfoObj_.TypeIndexs()[CurrentRow()]);
73             break;
74         case Index::SURFACE_NAME_INDEX:
75             sqlite3_result_int64(context_, rsImageDumpInfoObj_.SurfaceNameIndexs()[CurrentRow()]);
76             break;
77         default:
78             TS_LOGF("Unregistered column : %d", column);
79             break;
80     }
81     return SQLITE_OK;
82 }
83 } // namespace TraceStreamer
84 } // namespace SysTuning
85