OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResultSetManager Class Reference

#include <ResultSet.h>

Public Member Functions

ResultSetreduce (std::vector< ResultSet * > &, const size_t executor_id)
 
std::shared_ptr< ResultSetgetOwnResultSet ()
 
void rewriteVarlenAggregates (ResultSet *)
 

Private Attributes

std::shared_ptr< ResultSetrs_
 

Detailed Description

Definition at line 1033 of file ResultSet.h.

Member Function Documentation

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

Definition at line 1132 of file ResultSetReduction.cpp.

References rs_.

1132  {
1133  return rs_;
1134 }
std::shared_ptr< ResultSet > rs_
Definition: ResultSet.h:1042
ResultSet * ResultSetManager::reduce ( std::vector< ResultSet * > &  result_sets,
const size_t  executor_id 
)

Definition at line 1053 of file ResultSetReduction.cpp.

References gpu_enabled::accumulate(), CHECK, CHECK_EQ, ResultSetReductionJIT::codegen(), CPU, heavyai::GroupByBaselineHash, logger::init(), query_mem_desc, run_benchmark_import::result, and rs_.

1054  {
1055  CHECK(!result_sets.empty());
1056  auto result_rs = result_sets.front();
1057  CHECK(result_rs->storage_);
1058  auto& first_result = *result_rs->storage_;
1059  auto result = &first_result;
1060  const auto row_set_mem_owner = result_rs->row_set_mem_owner_;
1061  for (const auto result_set : result_sets) {
1062  CHECK_EQ(row_set_mem_owner, result_set->row_set_mem_owner_);
1063  }
1064  if (first_result.query_mem_desc_.getQueryDescriptionType() ==
1066  const auto total_entry_count =
1067  std::accumulate(result_sets.begin(),
1068  result_sets.end(),
1069  size_t(0),
1070  [](const size_t init, const ResultSet* rs) {
1071  return init + rs->query_mem_desc_.getEntryCount();
1072  });
1073  CHECK(total_entry_count);
1074  auto query_mem_desc = first_result.query_mem_desc_;
1075  query_mem_desc.setEntryCount(total_entry_count);
1076  rs_.reset(new ResultSet(first_result.targets_,
1079  row_set_mem_owner,
1080  0,
1081  0));
1082  auto result_storage = rs_->allocateStorage(first_result.target_init_vals_);
1083  rs_->initializeStorage();
1084  switch (query_mem_desc.getEffectiveKeyWidth()) {
1085  case 4:
1086  first_result.moveEntriesToBuffer<int32_t>(result_storage->getUnderlyingBuffer(),
1087  query_mem_desc.getEntryCount());
1088  break;
1089  case 8:
1090  first_result.moveEntriesToBuffer<int64_t>(result_storage->getUnderlyingBuffer(),
1091  query_mem_desc.getEntryCount());
1092  break;
1093  default:
1094  CHECK(false);
1095  }
1096  result = rs_->storage_.get();
1097  result_rs = rs_.get();
1098  }
1099 
1100  auto& serialized_varlen_buffer = result_sets.front()->serialized_varlen_buffer_;
1101  if (!serialized_varlen_buffer.empty()) {
1102  result->rewriteAggregateBufferOffsets(serialized_varlen_buffer.front());
1103  for (auto result_it = result_sets.begin() + 1; result_it != result_sets.end();
1104  ++result_it) {
1105  auto& result_serialized_varlen_buffer = (*result_it)->serialized_varlen_buffer_;
1106  CHECK_EQ(result_serialized_varlen_buffer.size(), size_t(1));
1107  serialized_varlen_buffer.emplace_back(
1108  std::move(result_serialized_varlen_buffer.front()));
1109  }
1110  }
1111 
1112  ResultSetReductionJIT reduction_jit(result_rs->getQueryMemDesc(),
1113  result_rs->getTargetInfos(),
1114  result_rs->getTargetInitVals(),
1115  executor_id);
1116  auto reduction_code = reduction_jit.codegen();
1117  size_t ctr = 1;
1118  for (auto result_it = result_sets.begin() + 1; result_it != result_sets.end();
1119  ++result_it) {
1120  if (!serialized_varlen_buffer.empty()) {
1121  result->reduce(*((*result_it)->storage_),
1122  serialized_varlen_buffer[ctr++],
1123  reduction_code,
1124  executor_id);
1125  } else {
1126  result->reduce(*((*result_it)->storage_), {}, reduction_code, executor_id);
1127  }
1128  }
1129  return result_rs;
1130 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
std::shared_ptr< ResultSet > rs_
Definition: ResultSet.h:1042
void init(LogOptions const &log_opts)
Definition: Logger.cpp:364
DEVICE auto accumulate(ARGS &&...args)
Definition: gpu_enabled.h:42
virtual ReductionCode codegen() const
GroupByBaselineHash
Definition: enums.h:58
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

void ResultSetManager::rewriteVarlenAggregates ( ResultSet result_rs)

Definition at line 1136 of file ResultSetReduction.cpp.

1136  {
1137  auto& result_storage = result_rs->storage_;
1138  result_storage->rewriteAggregateBufferOffsets(
1139  result_rs->serialized_varlen_buffer_.front());
1140 }

Member Data Documentation

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

Definition at line 1042 of file ResultSet.h.

Referenced by getOwnResultSet(), and reduce().


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