OmniSciDB  a5dc49c757
 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->addDictStringWithTruncation(
116  get_db_name(chunk_key[CHUNK_KEY_DB_IDX]));
117  } else {
118  set_null(import_buffer);
119  }
120  }
121  if (import_buffers.find("table_id") != import_buffers.end()) {
122  auto import_buffer = import_buffers["table_id"];
123  if (is_table_chunk(chunk_key)) {
124  import_buffer->addInt(chunk_key[CHUNK_KEY_TABLE_IDX]);
125  } else {
126  set_null(import_buffer);
127  }
128  }
129  if (import_buffers.find("table_name") != import_buffers.end()) {
130  auto import_buffer = import_buffers["table_name"];
131  if (is_table_chunk(chunk_key)) {
132  import_buffer->addDictStringWithTruncation(get_table_name(
133  chunk_key[CHUNK_KEY_DB_IDX], chunk_key[CHUNK_KEY_TABLE_IDX]));
134  } else {
135  set_null(import_buffer);
136  }
137  }
138  if (import_buffers.find("column_id") != import_buffers.end()) {
139  auto import_buffer = import_buffers["column_id"];
140  if (is_table_chunk(chunk_key)) {
141  import_buffer->addInt(chunk_key[CHUNK_KEY_COLUMN_IDX]);
142  } else {
143  set_null(import_buffer);
144  }
145  }
146  if (import_buffers.find("column_name") != import_buffers.end()) {
147  auto import_buffer = import_buffers["column_name"];
148  if (is_table_chunk(chunk_key)) {
149  import_buffer->addDictStringWithTruncation(
151  chunk_key[CHUNK_KEY_TABLE_IDX],
152  chunk_key[CHUNK_KEY_COLUMN_IDX]));
153  } else {
154  set_null(import_buffer);
155  }
156  }
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())),
161  DoNothingDeleter()));
162  }
163  if (import_buffers.find("device_id") != import_buffers.end()) {
164  import_buffers["device_id"]->addInt(device_id);
165  }
166  if (import_buffers.find("device_type") != import_buffers.end()) {
167  import_buffers["device_type"]->addDictStringWithTruncation(device_type);
168  }
169  if (import_buffers.find("memory_status") != import_buffers.end()) {
170  auto memory_status =
171  (memory_data.memStatus == Buffer_Namespace::MemStatus::FREE ? "FREE"
172  : "USED");
173  import_buffers["memory_status"]->addDictStringWithTruncation(memory_status);
174  }
175  if (import_buffers.find("page_count") != import_buffers.end()) {
176  import_buffers["page_count"]->addBigint(memory_data.numPages);
177  }
178  if (import_buffers.find("page_size") != import_buffers.end()) {
179  import_buffers["page_size"]->addBigint(memory_info.pageSize);
180  }
181  if (import_buffers.find("slab_id") != import_buffers.end()) {
182  import_buffers["slab_id"]->addInt(memory_data.slabNum);
183  }
184  if (import_buffers.find("start_page") != import_buffers.end()) {
185  import_buffers["start_page"]->addBigint(memory_data.startPage);
186  }
187  if (import_buffers.find("last_touch_epoch") != import_buffers.end()) {
188  import_buffers["last_touch_epoch"]->addBigint(memory_data.touch);
189  }
190  }
191  device_id++;
192  }
193  }
194 }
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:229
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"]->addDictStringWithTruncation(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:325
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:529

+ Here is the call graph for this function: