Ejemplo n.º 1
0
TileGroupHeader::TileGroupHeader(BackendType backend_type, int tuple_count)
    : backend_type(backend_type),
      data(nullptr),
      num_tuple_slots(tuple_count),
      next_tuple_slot(0) {
  header_size = num_tuple_slots * header_entry_size;

  // allocate storage space for header
  auto &storage_manager = storage::StorageManager::GetInstance();
  data = reinterpret_cast<char *>(
      storage_manager.Allocate(backend_type, header_size));
  assert(data != nullptr);

  // zero out the data
  std::memset(data, 0, header_size);

  // Set MVCC Initial Value
  for (oid_t tuple_slot_id = START_OID; tuple_slot_id < num_tuple_slots;
       tuple_slot_id++) {
    SetTransactionId(tuple_slot_id, INVALID_TXN_ID);
    SetBeginCommitId(tuple_slot_id, MAX_CID);
    SetEndCommitId(tuple_slot_id, MAX_CID);
    SetInsertCommit(tuple_slot_id, false);
    SetDeleteCommit(tuple_slot_id, false);
  }
}
Ejemplo n.º 2
0
TileGroupHeader::TileGroupHeader(const BackendType &backend_type,
                                 const int &tuple_count)
    : backend_type(backend_type),
      data(nullptr),
      num_tuple_slots(tuple_count),
      next_tuple_slot(0),
      tile_header_lock() {
  header_size = num_tuple_slots * header_entry_size;

  // allocate storage space for header
  auto &storage_manager = storage::StorageManager::GetInstance();
  data = reinterpret_cast<char *>(
      storage_manager.Allocate(backend_type, header_size));
  PL_ASSERT(data != nullptr);

  // zero out the data
  PL_MEMSET(data, 0, header_size);

  // Set MVCC Initial Value
  for (oid_t tuple_slot_id = START_OID; tuple_slot_id < num_tuple_slots;
       tuple_slot_id++) {
    SetTransactionId(tuple_slot_id, INVALID_TXN_ID);
    SetBeginCommitId(tuple_slot_id, MAX_CID);
    SetEndCommitId(tuple_slot_id, MAX_CID);
    SetNextItemPointer(tuple_slot_id, INVALID_ITEMPOINTER);
    SetPrevItemPointer(tuple_slot_id, INVALID_ITEMPOINTER);

    SetInsertCommit(tuple_slot_id, false);  // unused
    SetDeleteCommit(tuple_slot_id, false);  // unused
  }
}
Ejemplo n.º 3
0
std::pair<cid_t, storage::TileGroupHeader *>
WriteBehindFrontendLogger::SetInsertCommitMark(ItemPointer location) {
  auto &manager = catalog::Manager::GetInstance();
  auto tile_group = manager.GetTileGroup(location.block);
  assert(tile_group != nullptr);
  auto tile_group_header = tile_group->GetHeader();
  assert(tile_group_header != nullptr);

  // Set the commit mark
  tile_group_header->SetInsertCommit(location.offset, true);
  LOG_TRACE("<%p, %lu> : slot is insert committed", tile_group.get(),
            location.offset);

  // Update max oid
  if (max_oid < location.block) {
    max_oid = location.block;
  }

  auto begin_commit_id = tile_group_header->GetBeginCommitId(location.offset);
  return std::make_pair(begin_commit_id, tile_group_header);
}