OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UpdelRoll Struct Reference

#include <UpdelRoll.h>

+ Collaboration diagram for UpdelRoll:

Public Member Functions

 ~UpdelRoll ()
 
void cancelUpdate ()
 
bool commitUpdate ()
 
void stageUpdate ()
 

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,
ChunkMetadataMap
chunkMetadata
 
const Catalog_Namespace::Catalogcatalog = nullptr
 
int logicalTableId
 
Data_Namespace::MemoryLevel memoryLevel {Data_Namespace::MemoryLevel::CPU_LEVEL}
 
bool is_varlen_update = false
 
const TableDescriptortable_descriptor {nullptr}
 

Private Member Functions

void updateFragmenterAndCleanupChunks ()
 

Detailed Description

Definition at line 43 of file UpdelRoll.h.

Constructor & Destructor Documentation

UpdelRoll::~UpdelRoll ( )
inline

Definition at line 44 of file UpdelRoll.h.

References cancelUpdate(), and dirtyChunks.

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

+ Here is the call graph for this function:

Member Function Documentation

void UpdelRoll::cancelUpdate ( )

Definition at line 1495 of file UpdelStorage.cpp.

References CHECK, Data_Namespace::DataMgr::free(), Catalog_Namespace::Catalog::getDatabaseId(), Catalog_Namespace::Catalog::getDataMgr(), Catalog_Namespace::Catalog::getMetadataForTable(), Catalog_Namespace::Catalog::getTableEpochs(), lockmgr::TableLockMgrImpl< TableDataLockMgr >::getWriteLockForTable(), TableDescriptor::persistenceLevel, and Catalog_Namespace::Catalog::setTableEpochs().

Referenced by ~UpdelRoll().

1495  {
1496  if (nullptr == catalog) {
1497  return;
1498  }
1499 
1500  // TODO: needed?
1502  const auto table_lock = lockmgr::TableDataLockMgr::getWriteLockForTable(chunk_key);
1503  if (is_varlen_update) {
1504  int databaseId = catalog->getDatabaseId();
1505  auto table_epochs = catalog->getTableEpochs(databaseId, logicalTableId);
1506 
1507  dirtyChunks.clear();
1508  catalog->setTableEpochs(databaseId, table_epochs);
1509  } else {
1510  const auto td = catalog->getMetadataForTable(logicalTableId);
1511  CHECK(td);
1512  if (td->persistenceLevel != memoryLevel) {
1513  for (auto dit : dirtyChunks) {
1514  catalog->getDataMgr().free(dit.first->getBuffer());
1515  dit.first->setBuffer(nullptr);
1516  }
1517  }
1518  }
1519 }
Data_Namespace::MemoryLevel memoryLevel
Definition: UpdelRoll.h:65
bool is_varlen_update
Definition: UpdelRoll.h:67
std::vector< int > ChunkKey
Definition: types.h:37
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:223
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
const Catalog_Namespace::Catalog * catalog
Definition: UpdelRoll.h:63
int getDatabaseId() const
Definition: Catalog.h:277
int logicalTableId
Definition: UpdelRoll.h:64
void setTableEpochs(const int32_t db_id, const std::vector< TableEpochInfo > &table_epochs) const
Definition: Catalog.cpp:3077
#define CHECK(condition)
Definition: Logger.h:206
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
void free(AbstractBuffer *buffer)
Definition: DataMgr.cpp:469
std::vector< TableEpochInfo > getTableEpochs(const int32_t db_id, const int32_t table_id) const
Definition: Catalog.cpp:3049

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool UpdelRoll::commitUpdate ( )

Definition at line 1436 of file UpdelStorage.cpp.

References CHECK, Catalog_Namespace::Catalog::checkpoint(), Data_Namespace::DISK_LEVEL, Catalog_Namespace::Catalog::getDatabaseId(), Catalog_Namespace::Catalog::getMetadataForTable(), Catalog_Namespace::Catalog::getTableEpochs(), lockmgr::TableLockMgrImpl< TableDataLockMgr >::getWriteLockForTable(), TableDescriptor::persistenceLevel, Catalog_Namespace::Catalog::setTableEpochsLogExceptions(), and TableDescriptor::tableId.

Referenced by StorageIOFacility::TransactionParameters::finalizeTransaction().

1436  {
1437  if (nullptr == catalog) {
1438  return false;
1439  }
1440  const auto td = catalog->getMetadataForTable(logicalTableId);
1441  CHECK(td);
1442  ChunkKey chunk_key{catalog->getDatabaseId(), td->tableId};
1443  const auto table_lock = lockmgr::TableDataLockMgr::getWriteLockForTable(chunk_key);
1444 
1445  // Checkpoint all shards. Otherwise, epochs can go out of sync.
1446  if (td->persistenceLevel == Data_Namespace::MemoryLevel::DISK_LEVEL) {
1447  auto table_epochs = catalog->getTableEpochs(catalog->getDatabaseId(), logicalTableId);
1448  try {
1449  // `checkpointWithAutoRollback` is not called here because, if a failure occurs,
1450  // `dirtyChunks` has to be cleared before resetting epochs
1452  } catch (...) {
1453  dirtyChunks.clear();
1455  throw;
1456  }
1457  }
1459  return true;
1460 }
std::vector< int > ChunkKey
Definition: types.h:37
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
void updateFragmenterAndCleanupChunks()
const Catalog_Namespace::Catalog * catalog
Definition: UpdelRoll.h:63
int getDatabaseId() const
Definition: Catalog.h:277
void checkpoint(const int logicalTableId) const
Definition: Catalog.cpp:4210
int logicalTableId
Definition: UpdelRoll.h:64
#define CHECK(condition)
Definition: Logger.h:206
void setTableEpochsLogExceptions(const int32_t db_id, const std::vector< TableEpochInfo > &table_epochs) const
Definition: Catalog.cpp:3114
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
std::vector< TableEpochInfo > getTableEpochs(const int32_t db_id, const int32_t table_id) const
Definition: Catalog.cpp:3049

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void UpdelRoll::stageUpdate ( )

Definition at line 1462 of file UpdelStorage.cpp.

References CHECK, CHECK_EQ, Data_Namespace::DataMgr::checkpoint(), Data_Namespace::CPU_LEVEL, Data_Namespace::DISK_LEVEL, Catalog_Namespace::Catalog::getDatabaseId(), Catalog_Namespace::Catalog::getDataMgr(), and lockmgr::TableLockMgrImpl< TableDataLockMgr >::getWriteLockForTable().

Referenced by TableOptimizer::vacuumFragments().

1462  {
1463  CHECK(catalog);
1464  auto db_id = catalog->getDatabaseId();
1466  auto table_id = table_descriptor->tableId;
1469  const auto table_lock =
1471  try {
1472  catalog->getDataMgr().checkpoint(db_id, table_id, memoryLevel);
1473  } catch (...) {
1474  dirtyChunks.clear();
1475  throw;
1476  }
1478 }
Data_Namespace::MemoryLevel memoryLevel
Definition: UpdelRoll.h:65
#define CHECK_EQ(x, y)
Definition: Logger.h:214
const TableDescriptor * table_descriptor
Definition: UpdelRoll.h:68
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:223
void checkpoint(const int db_id, const int tb_id)
Definition: DataMgr.cpp:489
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
void updateFragmenterAndCleanupChunks()
const Catalog_Namespace::Catalog * catalog
Definition: UpdelRoll.h:63
int getDatabaseId() const
Definition: Catalog.h:277
Data_Namespace::MemoryLevel persistenceLevel
int logicalTableId
Definition: UpdelRoll.h:64
#define CHECK(condition)
Definition: Logger.h:206

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void UpdelRoll::updateFragmenterAndCleanupChunks ( )
private

Definition at line 1480 of file UpdelStorage.cpp.

References Data_Namespace::DataMgr::deleteChunksWithPrefix(), Catalog_Namespace::Catalog::getDataMgr(), and Data_Namespace::GPU_LEVEL.

1480  {
1481  // for each dirty fragment
1482  for (auto& cm : chunkMetadata) {
1483  cm.first.first->fragmenter->updateMetadata(catalog, cm.first, *this);
1484  }
1485  dirtyChunks.clear();
1486  // flush gpu dirty chunks if update was not on gpu
1488  for (const auto& chunkey : dirtyChunkeys) {
1491  }
1492  }
1493 }
Data_Namespace::MemoryLevel memoryLevel
Definition: UpdelRoll.h:65
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:223
std::map< Chunk_NS::Chunk *, std::shared_ptr< Chunk_NS::Chunk > > dirtyChunks
Definition: UpdelRoll.h:52
std::set< ChunkKey > dirtyChunkeys
Definition: UpdelRoll.h:53
const Catalog_Namespace::Catalog * catalog
Definition: UpdelRoll.h:63
void deleteChunksWithPrefix(const ChunkKey &keyPrefix)
Definition: DataMgr.cpp:436
std::map< MetaDataKey, ChunkMetadataMap > chunkMetadata
Definition: UpdelRoll.h:59

+ Here is the call graph for this function:

Member Data Documentation

bool UpdelRoll::is_varlen_update = false
const TableDescriptor* UpdelRoll::table_descriptor {nullptr}

Definition at line 68 of file UpdelRoll.h.

Referenced by TableOptimizer::vacuumFragments().


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