Example #1
0
llvm::Value *Sorter::GetNumberOfStoredTuples(CodeGen &codegen,
                                             llvm::Value *sorter_ptr) const {
  // TODO: util::Sorter has a function to handle this ...
  llvm::Value *start_pos = GetStartPosition(codegen, sorter_ptr);
  llvm::Value *end_pos = GetEndPosition(codegen, sorter_ptr);
  llvm::Value *tuple_size =
      codegen->CreateZExt(GetTupleSize(codegen), codegen.Int64Type());

  llvm::Value *diff_bytes = codegen->CreatePtrDiff(end_pos, start_pos);
  llvm::Value *num_tuples = codegen->CreateUDiv(diff_bytes, tuple_size);
  return codegen->CreateTruncOrBitCast(num_tuples, codegen.Int32Type());
}
Example #2
0
void RowBatch::Row::SetValidity(CodeGen &codegen, llvm::Value *valid) {
  if (valid->getType() != codegen.BoolType()) {
    std::string error_msg;
    llvm::raw_string_ostream rso{error_msg};
    rso << "Validity of row must be a boolean value. Received type: "
        << valid->getType();
    throw Exception{error_msg};
  }

  if (output_tracker_ == nullptr) {
    throw Exception{"You didn't provide an output tracker for the row!"};
  }

  // Append this row to the output
  llvm::Value *delta = codegen->CreateZExt(valid, codegen.Int32Type());
  output_tracker_->AppendRowToOutput(codegen, *this, delta);
}