OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::anonymous_namespace{InternalMemoryStatsDataWrapper.cpp} Namespace Reference

Functions

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)
 
void set_null (import_export::TypedImportBuffer *import_buffer)
 
bool is_table_chunk (const ChunkKey &chunk_key)
 
std::string get_column_name (int32_t db_id, int32_t table_id, int32_t column_id)
 
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)
 

Function Documentation

std::string foreign_storage::anonymous_namespace{InternalMemoryStatsDataWrapper.cpp}::get_column_name ( int32_t  db_id,
int32_t  table_id,
int32_t  column_id 
)

Definition at line 82 of file InternalMemoryStatsDataWrapper.cpp.

References CHECK, Catalog_Namespace::SysCatalog::getCatalog(), Catalog_Namespace::SysCatalog::instance(), and foreign_storage::kDeletedValueIndicator.

Referenced by populate_import_buffers_for_memory_details().

82  {
84  CHECK(catalog);
85  auto column_name = catalog->getColumnName(table_id, column_id);
86  if (column_name.has_value()) {
87  return column_name.value();
88  } else {
89  // It is possible for the column to be concurrently deleted while querying the system
90  // table.
92  }
93 }
constexpr const char * kDeletedValueIndicator
static SysCatalog & instance()
Definition: SysCatalog.h:343
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool foreign_storage::anonymous_namespace{InternalMemoryStatsDataWrapper.cpp}::is_table_chunk ( const ChunkKey chunk_key)

Definition at line 77 of file InternalMemoryStatsDataWrapper.cpp.

References CHUNK_KEY_DB_IDX.

Referenced by foreign_storage::InternalMemoryStatsDataWrapper::initializeObjectsForTable(), and populate_import_buffers_for_memory_details().

77  {
78  // Non-table chunks (temporary buffers) use a negative id for the database id.
79  return (!chunk_key.empty() && chunk_key[CHUNK_KEY_DB_IDX] > 0);
80 }
#define CHUNK_KEY_DB_IDX
Definition: types.h:38

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{InternalMemoryStatsDataWrapper.cpp}::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 
)

Definition at line 95 of file InternalMemoryStatsDataWrapper.cpp.

References CHUNK_KEY_COLUMN_IDX, CHUNK_KEY_DB_IDX, CHUNK_KEY_TABLE_IDX, Buffer_Namespace::FREE, get_column_name(), foreign_storage::get_db_name(), foreign_storage::get_table_name(), is_table_chunk(), foreign_storage::set_node_name(), and set_null().

Referenced by foreign_storage::InternalMemoryStatsDataWrapper::populateChunkBuffersForTable().

97  {
98  for (const auto& [device_type, memory_info_vector] : memory_info_by_device_type) {
99  int32_t device_id{0};
100  for (const auto& memory_info : memory_info_vector) {
101  for (const auto& memory_data : memory_info.nodeMemoryData) {
102  set_node_name(import_buffers);
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"];
106  if (is_table_chunk(chunk_key)) {
107  import_buffer->addInt(chunk_key[CHUNK_KEY_DB_IDX]);
108  } else {
109  set_null(import_buffer);
110  }
111  }
112  if (import_buffers.find("database_name") != import_buffers.end()) {
113  auto import_buffer = import_buffers["database_name"];
114  if (is_table_chunk(chunk_key)) {
115  import_buffer->addString(get_db_name(chunk_key[CHUNK_KEY_DB_IDX]));
116  } else {
117  set_null(import_buffer);
118  }
119  }
120  if (import_buffers.find("table_id") != import_buffers.end()) {
121  auto import_buffer = import_buffers["table_id"];
122  if (is_table_chunk(chunk_key)) {
123  import_buffer->addInt(chunk_key[CHUNK_KEY_TABLE_IDX]);
124  } else {
125  set_null(import_buffer);
126  }
127  }
128  if (import_buffers.find("table_name") != import_buffers.end()) {
129  auto import_buffer = import_buffers["table_name"];
130  if (is_table_chunk(chunk_key)) {
131  import_buffer->addString(get_table_name(chunk_key[CHUNK_KEY_DB_IDX],
132  chunk_key[CHUNK_KEY_TABLE_IDX]));
133  } else {
134  set_null(import_buffer);
135  }
136  }
137  if (import_buffers.find("column_id") != import_buffers.end()) {
138  auto import_buffer = import_buffers["column_id"];
139  if (is_table_chunk(chunk_key)) {
140  import_buffer->addInt(chunk_key[CHUNK_KEY_COLUMN_IDX]);
141  } else {
142  set_null(import_buffer);
143  }
144  }
145  if (import_buffers.find("column_name") != import_buffers.end()) {
146  auto import_buffer = import_buffers["column_name"];
147  if (is_table_chunk(chunk_key)) {
148  import_buffer->addString(get_column_name(chunk_key[CHUNK_KEY_DB_IDX],
149  chunk_key[CHUNK_KEY_TABLE_IDX],
150  chunk_key[CHUNK_KEY_COLUMN_IDX]));
151  } else {
152  set_null(import_buffer);
153  }
154  }
155  if (import_buffers.find("chunk_key") != import_buffers.end()) {
156  import_buffers["chunk_key"]->addArray(ArrayDatum(
157  chunk_key.size() * sizeof(int32_t),
158  reinterpret_cast<int8_t*>(const_cast<int32_t*>(chunk_key.data())),
159  DoNothingDeleter()));
160  }
161  if (import_buffers.find("device_id") != import_buffers.end()) {
162  import_buffers["device_id"]->addInt(device_id);
163  }
164  if (import_buffers.find("device_type") != import_buffers.end()) {
165  import_buffers["device_type"]->addString(device_type);
166  }
167  if (import_buffers.find("memory_status") != import_buffers.end()) {
168  auto memory_status =
169  (memory_data.memStatus == Buffer_Namespace::MemStatus::FREE ? "FREE"
170  : "USED");
171  import_buffers["memory_status"]->addString(memory_status);
172  }
173  if (import_buffers.find("page_count") != import_buffers.end()) {
174  import_buffers["page_count"]->addBigint(memory_data.numPages);
175  }
176  if (import_buffers.find("page_size") != import_buffers.end()) {
177  import_buffers["page_size"]->addBigint(memory_info.pageSize);
178  }
179  if (import_buffers.find("slab_id") != import_buffers.end()) {
180  import_buffers["slab_id"]->addInt(memory_data.slabNum);
181  }
182  if (import_buffers.find("start_page") != import_buffers.end()) {
183  import_buffers["start_page"]->addBigint(memory_data.startPage);
184  }
185  if (import_buffers.find("last_touch_epoch") != import_buffers.end()) {
186  import_buffers["last_touch_epoch"]->addBigint(memory_data.touch);
187  }
188  }
189  device_id++;
190  }
191  }
192 }
std::string get_column_name(int32_t db_id, int32_t table_id, int32_t column_id)
#define CHUNK_KEY_DB_IDX
Definition: types.h:38
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:219
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
Definition: types.h:39
std::string get_db_name(int32_t db_id)
#define CHUNK_KEY_COLUMN_IDX
Definition: types.h:40
std::string get_table_name(int32_t db_id, int32_t table_id)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{InternalMemoryStatsDataWrapper.cpp}::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 
)

Definition at line 32 of file InternalMemoryStatsDataWrapper.cpp.

References Buffer_Namespace::FREE, and foreign_storage::set_node_name().

Referenced by foreign_storage::InternalMemoryStatsDataWrapper::populateChunkBuffersForTable().

34  {
35  for (const auto& [device_type, memory_info_vector] : memory_info_by_device_type) {
36  int32_t device_id{0};
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) {
40  if (memory_data.memStatus == Buffer_Namespace::MemStatus::FREE) {
41  free_page_count += memory_data.numPages;
42  } else {
43  used_page_count += memory_data.numPages;
44  }
45  }
46  set_node_name(import_buffers);
47  if (import_buffers.find("device_id") != import_buffers.end()) {
48  import_buffers["device_id"]->addInt(device_id);
49  }
50  if (import_buffers.find("device_type") != import_buffers.end()) {
51  import_buffers["device_type"]->addString(device_type);
52  }
53  if (import_buffers.find("max_page_count") != import_buffers.end()) {
54  import_buffers["max_page_count"]->addBigint(memory_info.maxNumPages);
55  }
56  if (import_buffers.find("page_size") != import_buffers.end()) {
57  import_buffers["page_size"]->addBigint(memory_info.pageSize);
58  }
59  if (import_buffers.find("allocated_page_count") != import_buffers.end()) {
60  import_buffers["allocated_page_count"]->addBigint(memory_info.numPageAllocated);
61  }
62  if (import_buffers.find("used_page_count") != import_buffers.end()) {
63  import_buffers["used_page_count"]->addBigint(used_page_count);
64  }
65  if (import_buffers.find("free_page_count") != import_buffers.end()) {
66  import_buffers["free_page_count"]->addBigint(free_page_count);
67  }
68  device_id++;
69  }
70  }
71 }
void set_node_name(std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{InternalMemoryStatsDataWrapper.cpp}::set_null ( import_export::TypedImportBuffer import_buffer)

Definition at line 73 of file InternalMemoryStatsDataWrapper.cpp.

References import_export::TypedImportBuffer::add_value(), and import_export::TypedImportBuffer::getColumnDesc().

73  {
74  import_buffer->add_value(import_buffer->getColumnDesc(), "", true, {});
75 }
const ColumnDescriptor * getColumnDesc() const
Definition: Importer.h:319
void add_value(const ColumnDescriptor *cd, const std::string_view val, const bool is_null, const CopyParams &copy_params, const bool check_not_null=true)
Definition: Importer.cpp:528

+ Here is the call graph for this function: