OmniSciDB  29e35f4d58
ResultSetManager Class Reference

#include <ResultSet.h>

Public Member Functions

ResultSetreduce (std::vector< ResultSet *> &)
 
std::shared_ptr< ResultSetgetOwnResultSet ()
 
void rewriteVarlenAggregates (ResultSet *)
 

Private Attributes

std::shared_ptr< ResultSetrs_
 

Detailed Description

Definition at line 886 of file ResultSet.h.

Member Function Documentation

◆ getOwnResultSet()

std::shared_ptr< ResultSet > ResultSetManager::getOwnResultSet ( )

Definition at line 1080 of file ResultSetReduction.cpp.

1080  {
1081  return rs_;
1082 }
std::shared_ptr< ResultSet > rs_
Definition: ResultSet.h:895

◆ reduce()

ResultSet * ResultSetManager::reduce ( std::vector< ResultSet *> &  result_sets)

Definition at line 1002 of file ResultSetReduction.cpp.

References CHECK, CHECK_EQ, ResultSetReductionJIT::codegen(), CPU, GroupByBaselineHash, logger::init(), run_benchmark_import::result, and ResultSetStorage::ResultSet.

1002  {
1003  CHECK(!result_sets.empty());
1004  auto result_rs = result_sets.front();
1005  CHECK(result_rs->storage_);
1006  auto& first_result = *result_rs->storage_;
1007  auto result = &first_result;
1008  const auto row_set_mem_owner = result_rs->row_set_mem_owner_;
1009  for (const auto result_set : result_sets) {
1010  CHECK_EQ(row_set_mem_owner, result_set->row_set_mem_owner_);
1011  }
1012  const auto executor = result_rs->executor_;
1013  for (const auto result_set : result_sets) {
1014  CHECK_EQ(executor, result_set->executor_);
1015  }
1016  if (first_result.query_mem_desc_.getQueryDescriptionType() ==
1018  const auto total_entry_count =
1019  std::accumulate(result_sets.begin(),
1020  result_sets.end(),
1021  size_t(0),
1022  [](const size_t init, const ResultSet* rs) {
1023  return init + rs->query_mem_desc_.getEntryCount();
1024  });
1025  CHECK(total_entry_count);
1026  auto query_mem_desc = first_result.query_mem_desc_;
1027  query_mem_desc.setEntryCount(total_entry_count);
1028  rs_.reset(new ResultSet(first_result.targets_,
1030  query_mem_desc,
1031  row_set_mem_owner,
1032  executor));
1033  auto result_storage = rs_->allocateStorage(first_result.target_init_vals_);
1034  rs_->initializeStorage();
1035  switch (query_mem_desc.getEffectiveKeyWidth()) {
1036  case 4:
1037  first_result.moveEntriesToBuffer<int32_t>(result_storage->getUnderlyingBuffer(),
1038  query_mem_desc.getEntryCount());
1039  break;
1040  case 8:
1041  first_result.moveEntriesToBuffer<int64_t>(result_storage->getUnderlyingBuffer(),
1042  query_mem_desc.getEntryCount());
1043  break;
1044  default:
1045  CHECK(false);
1046  }
1047  result = rs_->storage_.get();
1048  result_rs = rs_.get();
1049  }
1050 
1051  auto& serialized_varlen_buffer = result_sets.front()->serialized_varlen_buffer_;
1052  if (!serialized_varlen_buffer.empty()) {
1053  result->rewriteAggregateBufferOffsets(serialized_varlen_buffer.front());
1054  for (auto result_it = result_sets.begin() + 1; result_it != result_sets.end();
1055  ++result_it) {
1056  auto& result_serialized_varlen_buffer = (*result_it)->serialized_varlen_buffer_;
1057  CHECK_EQ(result_serialized_varlen_buffer.size(), size_t(1));
1058  serialized_varlen_buffer.emplace_back(
1059  std::move(result_serialized_varlen_buffer.front()));
1060  }
1061  }
1062 
1063  ResultSetReductionJIT reduction_jit(result_rs->getQueryMemDesc(),
1064  result_rs->getTargetInfos(),
1065  result_rs->getTargetInitVals());
1066  auto reduction_code = reduction_jit.codegen();
1067  size_t ctr = 1;
1068  for (auto result_it = result_sets.begin() + 1; result_it != result_sets.end();
1069  ++result_it) {
1070  if (!serialized_varlen_buffer.empty()) {
1071  result->reduce(
1072  *((*result_it)->storage_), serialized_varlen_buffer[ctr++], reduction_code);
1073  } else {
1074  result->reduce(*((*result_it)->storage_), {}, reduction_code);
1075  }
1076  }
1077  return result_rs;
1078 }
#define CHECK_EQ(x, y)
Definition: Logger.h:201
std::shared_ptr< ResultSet > rs_
Definition: ResultSet.h:895
ReductionCode codegen() const
void init(LogOptions const &log_opts)
Definition: Logger.cpp:272
#define CHECK(condition)
Definition: Logger.h:193
+ Here is the call graph for this function:

◆ rewriteVarlenAggregates()

void ResultSetManager::rewriteVarlenAggregates ( ResultSet result_rs)

Definition at line 1084 of file ResultSetReduction.cpp.

1084  {
1085  auto& result_storage = result_rs->storage_;
1086  result_storage->rewriteAggregateBufferOffsets(
1087  result_rs->serialized_varlen_buffer_.front());
1088 }

Member Data Documentation

◆ rs_

std::shared_ptr<ResultSet> ResultSetManager::rs_
private

Definition at line 895 of file ResultSet.h.


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