Map to hold outstanding scanners. More...
#include <ScannerMap.h>
Classes | |
struct | ScanInfo |
Holds scanner information. More... | |
Public Member Functions | |
int32_t | put (MergeScannerRangePtr &scanner, RangePtr &range, const TableIdentifier &table, ProfileDataScanner &profile_data) |
This method computes a unique scanner ID and puts the given scanner and range pointers into a map using the scanner ID as the key. More... | |
bool | get (int32_t id, MergeScannerRangePtr &scanner, RangePtr &range, TableIdentifierManaged &table, ProfileDataScanner *profile_data) |
This method retrieves the scanner and range mapped to the given scanner id. More... | |
bool | remove (int32_t id) |
This method removes the entry in the scanner map corresponding to the given id. More... | |
void | purge_expired (int32_t max_idle_ms) |
This method iterates through the scanner map purging mappings that have not been referenced for max_idle_ms or greater milliseconds. More... | |
void | get_counts (int32_t *totalp, CstrToInt32Map &table_scanner_count_map) |
This method retrieves outstanding scanner counts. More... | |
void | update_profile_data (int32_t id, ProfileDataScanner &profile_data) |
Updates profile data of a scanner in the map. More... | |
Private Member Functions | |
int64_t | get_timestamp_millis () |
Returns the number of milliseconds since the epoch. More... | |
Private Attributes | |
std::mutex | m_mutex |
Mutex for serializing access to members More... | |
std::unordered_map< int32_t, ScanInfo > | m_scanner_map |
Scanner map. More... | |
Static Private Attributes | |
static std::atomic< int > | ms_next_id {0} |
Next available scanner ID. More... | |
Map to hold outstanding scanners.
Definition at line 45 of file ScannerMap.h.
bool ScannerMap::get | ( | int32_t | id, |
MergeScannerRangePtr & | scanner, | ||
RangePtr & | range, | ||
TableIdentifierManaged & | table, | ||
ProfileDataScanner * | profile_data | ||
) |
This method retrieves the scanner and range mapped to the given scanner id.
It also updates the 'last_access_millis' member of this scanner map entry.
id | scanner id |
scanner | smart pointer to returned scanner object |
range | smart pointer to returned range object |
table | reference to (managed) table identifier |
profile_data | Pointer to profile data structure populated by this function |
Definition at line 59 of file ScannerMap.cc.
void ScannerMap::get_counts | ( | int32_t * | totalp, |
CstrToInt32Map & | table_scanner_count_map | ||
) |
This method retrieves outstanding scanner counts.
It returns the total number of outstanding scanners as well as the number of outstanding scanners per-table. Only the tables that exist in the table_scanner_count_map that is passed into this method will be counted.
totalp | address of variable to hold total outstanding counters |
table_scanner_count_map | reference to table count map (NOTE: must be filled in by caller, no new entries will be added) |
Definition at line 104 of file ScannerMap.cc.
|
private |
Returns the number of milliseconds since the epoch.
Definition at line 127 of file ScannerMap.cc.
void ScannerMap::purge_expired | ( | int32_t | max_idle_ms | ) |
This method iterates through the scanner map purging mappings that have not been referenced for max_idle_ms or greater milliseconds.
max_idle_ms | maximum idle time |
Definition at line 83 of file ScannerMap.cc.
int32_t ScannerMap::put | ( | MergeScannerRangePtr & | scanner, |
RangePtr & | range, | ||
const TableIdentifier & | table, | ||
ProfileDataScanner & | profile_data | ||
) |
This method computes a unique scanner ID and puts the given scanner and range pointers into a map using the scanner ID as the key.
scanner | smart pointer to scanner object |
range | smart pointer to range object |
table | table identifier for this scanner |
profile_data | Scanner profile data |
Definition at line 40 of file ScannerMap.cc.
bool ScannerMap::remove | ( | int32_t | id | ) |
This method removes the entry in the scanner map corresponding to the given id.
id | scanner id |
Definition at line 77 of file ScannerMap.cc.
void ScannerMap::update_profile_data | ( | int32_t | id, |
ProfileDataScanner & | profile_data | ||
) |
Updates profile data of a scanner in the map.
id | Scanner ID of scanner |
profile_data | new profile data to associate with scanner |
Definition at line 117 of file ScannerMap.cc.
|
private |
Mutex for serializing access to members
Definition at line 124 of file ScannerMap.h.
|
private |
Scanner map.
Definition at line 141 of file ScannerMap.h.
|
staticprivate |
Next available scanner ID.
Definition at line 121 of file ScannerMap.h.