当前位置: 首页>>代码示例>>C++>>正文


C++ Ptr::getTotalCount方法代码示例

本文整理汇总了C++中table::Ptr::getTotalCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::getTotalCount方法的具体用法?C++ Ptr::getTotalCount怎么用?C++ Ptr::getTotalCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在table::Ptr的用法示例。


在下文中一共展示了Ptr::getTotalCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: writeTemporaryTable

void AQMatrix::writeTemporaryTable()
{
  if (this->matrix.empty())
    return;
  uint64_t packet = 0;
  char filename[1024];
  FILE * fd;
  std::vector<std::map<uint64_t, FILE*> > fds(this->matrix.size());
  uint32_t status = 11;
  uint32_t invalid = 0;
  uint32_t pos = 0;
  uint64_t grpIndex = 1;
  uint64_t size = (*this->matrix.begin()).indexes.size();
  for (uint64_t i = 0; i < size; ++i, ++grpIndex)
  {
    for (size_t c = 0; c < this->matrix.size(); ++c)
    {
      pos = static_cast<uint32_t>(this->matrix[c].indexes[i]);
      packet = pos / settings->packSize;
      pos = (pos - 1) % settings->packSize;
      auto it = fds[c].find(packet);
      if (it == fds[c].end())
      {
        sprintf(filename, "%s/B001REG%.4luTMP%.4"PRIu64"P%.12"PRIu64".TMP", this->settings->tmpPath.c_str(), this->matrix[c].table_id, this->uid, packet);
        fd = fopen(filename, "wb");
        if (fd == nullptr)
        {
          throw aq::generic_error(aq::generic_error::COULD_NOT_OPEN_FILE, "cannot create temporary table file '%s'", filename);
        }
        if (!fds[c].insert(std::make_pair(packet, fd)).second)
        {
          throw aq::generic_error(aq::generic_error::GENERIC, "MEMORY ERROR");
        }
        fwrite(&status, sizeof(uint32_t), 1, fd);
      }
      else
      {
        fd = it->second;
      }
      
      fwrite(&invalid, sizeof(uint32_t), 1, fd);
      fwrite(&pos, sizeof(uint32_t), 1, fd);
    }
  }
  
  for (size_t c = 0; c < this->matrix.size(); ++c)
  {
    for (auto& v : fds[c])
    {
      fclose(v.second);
    }
  }
  
  // FIXME : generate empty file => this is temporary
  char tableName[128];
  for (auto it = this->matrix.begin(); it != this->matrix.end(); ++it)
  {
    Table::Ptr table = this->baseDesc->getTable((*it).table_id);
    uint64_t n = table->getTotalCount() / this->settings->packSize;
    for (uint64_t i = 0; i <= n; ++i)
    {
      sprintf(filename, "%s/B001REG%.4luTMP%.4"PRIu64"P%.12"PRIu64".TMP", this->settings->tmpPath.c_str(), (*it).table_id, this->uid, i);
      FILE * fd = fopen(filename, "ab");
      fclose(fd);
    }
    sprintf(tableName, "B001REG%.4luTMP%.4"PRIu64"P%.12"PRIu64, (*it).table_id, this->uid, n + 1);
    (*it).tableName = tableName;
    (*it).baseTableName = table->getName();
  }
}
开发者ID:TMA-AQ,项目名称:AQDisplay,代码行数:70,代码来源:AQMatrix.cpp


注:本文中的table::Ptr::getTotalCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。