OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 806 of file ResultSet.h.

Member Function Documentation

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

Definition at line 1123 of file ResultSetReduction.cpp.

References rs_.

1123  {
1124  return rs_;
1125 }
std::shared_ptr< ResultSet > rs_
Definition: ResultSet.h:815
ResultSet * ResultSetManager::reduce ( std::vector< ResultSet * > &  result_sets)

Definition at line 1043 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_.

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

+ Here is the call graph for this function:

void ResultSetManager::rewriteVarlenAggregates ( ResultSet result_rs)

Definition at line 1127 of file ResultSetReduction.cpp.

1127  {
1128  auto& result_storage = result_rs->storage_;
1129  result_storage->rewriteAggregateBufferOffsets(
1130  result_rs->serialized_varlen_buffer_.front());
1131 }

Member Data Documentation

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

Definition at line 815 of file ResultSet.h.

Referenced by getOwnResultSet(), and reduce().


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