示例#1
0
文件: sorter.cpp 项目: cmu-db/peloton
// Iterate over the tuples in the sorter in batches/vectors of the given size
void Sorter::VectorizedIterate(
    CodeGen &codegen, llvm::Value *sorter_ptr, uint32_t vector_size,
    uint64_t offset, Sorter::VectorizedIterateCallback &callback) const {
  llvm::Value *start_pos = codegen.Load(SorterProxy::tuples_start, sorter_ptr);
  llvm::Value *num_tuples = NumTuples(codegen, sorter_ptr);
  num_tuples = codegen->CreateTrunc(num_tuples, codegen.Int32Type());

  if (offset != 0) {
    start_pos = codegen->CreateConstInBoundsGEP1_32(codegen.CharPtrType(),
                                                    start_pos, offset);
    num_tuples = codegen->CreateSub(num_tuples, codegen.Const32(offset));
  }

  lang::VectorizedLoop loop(codegen, num_tuples, vector_size, {});
  {
    // Current loop range
    auto curr_range = loop.GetCurrentRange();

    // Provide an accessor into the sorted space
    SorterAccess sorter_access(*this, start_pos);

    // Issue the callback
    callback.ProcessEntries(codegen, curr_range.start, curr_range.end,
                            sorter_access);

    // That's it
    loop.LoopEnd(codegen, {});
  }
}
示例#2
0
文件: sorter.cpp 项目: cmu-db/peloton
codegen::Value Sorter::SorterAccess::LoadRowValue(
    CodeGen &codegen, Sorter::SorterAccess::Row &row,
    uint32_t column_index) const {
  if (row.row_pos_ == nullptr) {
    auto *addr = codegen->CreateInBoundsGEP(codegen.CharPtrType(), start_pos_,
                                            row.row_idx_);
    row.row_pos_ = codegen->CreateLoad(addr);
  }

  const auto &storage_format = sorter_.GetStorageFormat();
  UpdateableStorage::NullBitmap null_bitmap(codegen, storage_format,
                                            row.row_pos_);
  return storage_format.GetValue(codegen, row.row_pos_, column_index,
                                 null_bitmap);
}
示例#3
0
void Varchar::GetTypeForMaterialization(CodeGen &codegen, llvm::Type *&val_type,
                                        llvm::Type *&len_type) const {
  val_type = codegen.CharPtrType();
  len_type = codegen.Int32Type();
}
示例#4
0
Value Varchar::GetNullValue(CodeGen &codegen) const {
  return Value{Type{TypeId(), true}, codegen.NullPtr(codegen.CharPtrType()),
               codegen.Const32(0), codegen.ConstBool(true)};
}