22 namespace foreign_storage {
33 const std::map<std::string, std::vector<MemoryInfo>>& memory_info_by_device_type,
34 std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
35 for (
const auto& [device_type, memory_info_vector] : memory_info_by_device_type) {
37 for (
const auto& memory_info : memory_info_vector) {
38 size_t used_page_count{0}, free_page_count{0};
39 for (
const auto& memory_data : memory_info.nodeMemoryData) {
41 free_page_count += memory_data.numPages;
43 used_page_count += memory_data.numPages;
47 if (import_buffers.find(
"device_id") != import_buffers.end()) {
48 import_buffers[
"device_id"]->addInt(device_id);
50 if (import_buffers.find(
"device_type") != import_buffers.end()) {
51 import_buffers[
"device_type"]->addDictStringWithTruncation(device_type);
53 if (import_buffers.find(
"max_page_count") != import_buffers.end()) {
54 import_buffers[
"max_page_count"]->addBigint(memory_info.maxNumPages);
56 if (import_buffers.find(
"page_size") != import_buffers.end()) {
57 import_buffers[
"page_size"]->addBigint(memory_info.pageSize);
59 if (import_buffers.find(
"allocated_page_count") != import_buffers.end()) {
60 import_buffers[
"allocated_page_count"]->addBigint(memory_info.numPageAllocated);
62 if (import_buffers.find(
"used_page_count") != import_buffers.end()) {
63 import_buffers[
"used_page_count"]->addBigint(used_page_count);
65 if (import_buffers.find(
"free_page_count") != import_buffers.end()) {
66 import_buffers[
"free_page_count"]->addBigint(free_page_count);
85 auto column_name = catalog->getColumnName(table_id, column_id);
86 if (column_name.has_value()) {
87 return column_name.value();
96 const std::map<std::string, std::vector<MemoryInfo>>& memory_info_by_device_type,
97 std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
98 for (
const auto& [device_type, memory_info_vector] : memory_info_by_device_type) {
100 for (
const auto& memory_info : memory_info_vector) {
101 for (
const auto& memory_data : memory_info.nodeMemoryData) {
103 const auto& chunk_key = memory_data.chunk_key;
104 if (import_buffers.find(
"database_id") != import_buffers.end()) {
105 auto import_buffer = import_buffers[
"database_id"];
112 if (import_buffers.find(
"database_name") != import_buffers.end()) {
113 auto import_buffer = import_buffers[
"database_name"];
115 import_buffer->addDictStringWithTruncation(
121 if (import_buffers.find(
"table_id") != import_buffers.end()) {
122 auto import_buffer = import_buffers[
"table_id"];
129 if (import_buffers.find(
"table_name") != import_buffers.end()) {
130 auto import_buffer = import_buffers[
"table_name"];
138 if (import_buffers.find(
"column_id") != import_buffers.end()) {
139 auto import_buffer = import_buffers[
"column_id"];
146 if (import_buffers.find(
"column_name") != import_buffers.end()) {
147 auto import_buffer = import_buffers[
"column_name"];
149 import_buffer->addDictStringWithTruncation(
157 if (import_buffers.find(
"chunk_key") != import_buffers.end()) {
158 import_buffers[
"chunk_key"]->addArray(
ArrayDatum(
159 chunk_key.size() *
sizeof(int32_t),
160 reinterpret_cast<int8_t*>(const_cast<int32_t*>(chunk_key.data())),
163 if (import_buffers.find(
"device_id") != import_buffers.end()) {
164 import_buffers[
"device_id"]->addInt(device_id);
166 if (import_buffers.find(
"device_type") != import_buffers.end()) {
167 import_buffers[
"device_type"]->addDictStringWithTruncation(device_type);
169 if (import_buffers.find(
"memory_status") != import_buffers.end()) {
173 import_buffers[
"memory_status"]->addDictStringWithTruncation(memory_status);
175 if (import_buffers.find(
"page_count") != import_buffers.end()) {
176 import_buffers[
"page_count"]->addBigint(memory_data.numPages);
178 if (import_buffers.find(
"page_size") != import_buffers.end()) {
179 import_buffers[
"page_size"]->addBigint(memory_info.pageSize);
181 if (import_buffers.find(
"slab_id") != import_buffers.end()) {
182 import_buffers[
"slab_id"]->addInt(memory_data.slabNum);
184 if (import_buffers.find(
"start_page") != import_buffers.end()) {
185 import_buffers[
"start_page"]->addBigint(memory_data.startPage);
187 if (import_buffers.find(
"last_touch_epoch") != import_buffers.end()) {
188 import_buffers[
"last_touch_epoch"]->addBigint(memory_data.touch);
198 const std::string& table_name) {
215 for (
auto& memory_info : memory_info_vector) {
216 for (
auto& memory_data : memory_info.nodeMemoryData) {
218 memory_data.chunk_key.clear();
221 CHECK_GE(memory_data.chunk_key.size(),
static_cast<size_t>(4));
225 row_count_ += memory_info.nodeMemoryData.size();
229 UNREACHABLE() <<
"Unexpected table name: " << table_name;
234 const std::string& table_name,
235 std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
static constexpr const char * MEMORY_DETAILS_SYS_TABLE_NAME
std::vector< int > ChunkKey
std::string get_column_name(int32_t db_id, int32_t table_id, int32_t column_id)
void initializeObjectsForTable(const std::string &table_name) override
constexpr const char * kDeletedValueIndicator
bool is_table_chunk(const ChunkKey &chunk_key)
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Data_Namespace::DataMgr & getDataMgr() const
static SysCatalog & instance()
This file contains the class specification and related data structures for SysCatalog.
void set_node_name(std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
CONSTEXPR DEVICE void set_null(T &value)
#define CHUNK_KEY_TABLE_IDX
static constexpr const char * MEMORY_SUMMARY_SYS_TABLE_NAME
std::map< std::string, std::vector< MemoryInfo > > memory_info_by_device_type_
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
const ForeignTable * foreign_table_
void populate_import_buffers_for_memory_details(const std::map< std::string, std::vector< MemoryInfo >> &memory_info_by_device_type, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
std::string get_db_name(int32_t db_id)
const ColumnDescriptor * getColumnDesc() const
void populateChunkBuffersForTable(const std::string &table_name, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers) override
#define CHUNK_KEY_COLUMN_IDX
void add_value(const ColumnDescriptor *cd, const std::string_view val, const bool is_null, const CopyParams ©_params, const bool check_not_null=true)
void populate_import_buffers_for_memory_summary(const std::map< std::string, std::vector< MemoryInfo >> &memory_info_by_device_type, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
std::string get_table_name(int32_t db_id, int32_t table_id)
InternalMemoryStatsDataWrapper()