OmniSciDB  2e3a973ef4
UpdelRoll Struct Reference

#include <UpdelRoll.h>

+ Collaboration diagram for UpdelRoll:

Public Member Functions

 ~UpdelRoll ()
 
void cancelUpdate ()
 
void commitUpdate ()
 

Public Attributes

std::mutex mutex
 
std::map< Chunk_NS::Chunk *, std::shared_ptr< Chunk_NS::Chunk > > dirtyChunks
 
std::set< ChunkKeydirtyChunkeys
 
std::map< MetaDataKey, size_t > numTuples
 
std::map< MetaDataKey, ChunkMetadataMapchunkMetadata
 
const Catalog_Namespace::Catalogcatalog = nullptr
 
int logicalTableId
 
Data_Namespace::MemoryLevel memoryLevel {Data_Namespace::MemoryLevel::CPU_LEVEL}
 
bool is_varlen_update = false
 

Detailed Description

Definition at line 43 of file UpdelRoll.h.

Constructor & Destructor Documentation

◆ ~UpdelRoll()

UpdelRoll::~UpdelRoll ( )
inline

Definition at line 44 of file UpdelRoll.h.

44  {
45  if (dirtyChunks.size()) {
46  cancelUpdate();
47  }
48  }
void cancelUpdate()
std::map< Chunk_NS::Chunk *, std::shared_ptr< Chunk_NS::Chunk > > dirtyChunks
Definition: UpdelRoll.h:52

Member Function Documentation

◆ cancelUpdate()

void UpdelRoll::cancelUpdate ( )

Definition at line 1313 of file UpdelStorage.cpp.

References CHECK, Catalog_Namespace::Catalog::getMetadataForTable(), and lockmgr::TableLockMgrImpl< TableDataLockMgr >::getWriteLockForTable().

1313  {
1314  if (nullptr == catalog) {
1315  return;
1316  }
1317 
1318  // TODO: needed?
1320  const auto table_lock = lockmgr::TableDataLockMgr::getWriteLockForTable(chunk_key);
1321  if (is_varlen_update) {
1322  int databaseId = catalog->getDatabaseId();
1323  int32_t tableEpoch = catalog->getTableEpoch(databaseId, logicalTableId);
1324 
1325  dirtyChunks.clear();
1326  const_cast<Catalog_Namespace::Catalog*>(catalog)->setTableEpoch(
1327  databaseId, logicalTableId, tableEpoch);
1328  } else {
1329  const auto td = catalog->getMetadataForTable(logicalTableId);
1330  CHECK(td);
1331  if (td->persistenceLevel != memoryLevel) {
1332  for (auto dit : dirtyChunks) {
1333  catalog->getDataMgr().free(dit.first->getBuffer());
1334  dit.first->setBuffer(nullptr);
1335  }
1336  }
1337  }
1338 }
Data_Namespace::MemoryLevel memoryLevel
Definition: UpdelRoll.h:65
bool is_varlen_update
Definition: UpdelRoll.h:67
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:97
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:209
std::map< Chunk_NS::Chunk *, std::shared_ptr< Chunk_NS::Chunk > > dirtyChunks
Definition: UpdelRoll.h:52
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Definition: LockMgrImpl.h:155
int32_t getTableEpoch(const int32_t db_id, const int32_t table_id) const
Definition: Catalog.cpp:2715
int getDatabaseId() const
Definition: Catalog.h:243
const Catalog_Namespace::Catalog * catalog
Definition: UpdelRoll.h:63
int logicalTableId
Definition: UpdelRoll.h:64
#define CHECK(condition)
Definition: Logger.h:197
std::vector< int > ChunkKey
Definition: types.h:37
void free(AbstractBuffer *buffer)
Definition: DataMgr.cpp:461
+ Here is the call graph for this function:

◆ commitUpdate()

void UpdelRoll::commitUpdate ( )

Definition at line 1286 of file UpdelStorage.cpp.

References CHECK, Data_Namespace::DISK_LEVEL, lockmgr::TableLockMgrImpl< TableDataLockMgr >::getWriteLockForTable(), and Data_Namespace::GPU_LEVEL.

Referenced by Catalog_Namespace::Catalog::vacuumDeletedRows().

1286  {
1287  if (nullptr == catalog) {
1288  return;
1289  }
1290  const auto td = catalog->getMetadataForTable(logicalTableId);
1291  CHECK(td);
1292  ChunkKey chunk_key{catalog->getDatabaseId(), td->tableId};
1293  const auto table_lock = lockmgr::TableDataLockMgr::getWriteLockForTable(chunk_key);
1294 
1295  // checkpoint all shards regardless, or epoch becomes out of sync
1296  if (td->persistenceLevel == Data_Namespace::MemoryLevel::DISK_LEVEL) {
1298  }
1299  // for each dirty fragment
1300  for (auto& cm : chunkMetadata) {
1301  cm.first.first->fragmenter->updateMetadata(catalog, cm.first, *this);
1302  }
1303  dirtyChunks.clear();
1304  // flush gpu dirty chunks if update was not on gpu
1306  for (const auto& chunkey : dirtyChunkeys) {
1309  }
1310  }
1311 }
Data_Namespace::MemoryLevel memoryLevel
Definition: UpdelRoll.h:65
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:209
std::map< Chunk_NS::Chunk *, std::shared_ptr< Chunk_NS::Chunk > > dirtyChunks
Definition: UpdelRoll.h:52
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Definition: LockMgrImpl.h:155
std::set< ChunkKey > dirtyChunkeys
Definition: UpdelRoll.h:53
int getDatabaseId() const
Definition: Catalog.h:243
void checkpoint(const int logicalTableId) const
Definition: Catalog.cpp:3693
const Catalog_Namespace::Catalog * catalog
Definition: UpdelRoll.h:63
void deleteChunksWithPrefix(const ChunkKey &keyPrefix)
Definition: DataMgr.cpp:428
int logicalTableId
Definition: UpdelRoll.h:64
std::map< MetaDataKey, ChunkMetadataMap > chunkMetadata
Definition: UpdelRoll.h:59
#define CHECK(condition)
Definition: Logger.h:197
std::vector< int > ChunkKey
Definition: types.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ catalog

◆ chunkMetadata

◆ dirtyChunkeys

◆ dirtyChunks

◆ is_varlen_update

bool UpdelRoll::is_varlen_update = false

◆ logicalTableId

◆ memoryLevel

◆ mutex

◆ numTuples


The documentation for this struct was generated from the following files: