OmniSciDB  16c4e035a1
 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 * > &)
 
std::shared_ptr< ResultSetgetOwnResultSet ()
 
void rewriteVarlenAggregates (ResultSet *)
 

Private Attributes

std::shared_ptr< ResultSetrs_
 

Detailed Description

Definition at line 901 of file ResultSet.h.

Member Function Documentation

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

Definition at line 1135 of file ResultSetReduction.cpp.

References rs_.

1135  {
1136  return rs_;
1137 }
std::shared_ptr< ResultSet > rs_
Definition: ResultSet.h:910
ResultSet * ResultSetManager::reduce ( std::vector< ResultSet * > &  result_sets)

Definition at line 1055 of file ResultSetReduction.cpp.

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

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

+ Here is the call graph for this function:

void ResultSetManager::rewriteVarlenAggregates ( ResultSet result_rs)

Definition at line 1139 of file ResultSetReduction.cpp.

1139  {
1140  auto& result_storage = result_rs->storage_;
1141  result_storage->rewriteAggregateBufferOffsets(
1142  result_rs->serialized_varlen_buffer_.front());
1143 }

Member Data Documentation

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

Definition at line 910 of file ResultSet.h.

Referenced by getOwnResultSet(), and reduce().


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