OmniSciDB  04ee39c94c
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 873 of file ResultSet.h.

Member Function Documentation

◆ getOwnResultSet()

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

Definition at line 1214 of file ResultSetReduction.cpp.

1214  {
1215  return rs_;
1216 }
std::shared_ptr< ResultSet > rs_
Definition: ResultSet.h:882

◆ reduce()

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

Definition at line 1132 of file ResultSetReduction.cpp.

References CHECK, CHECK_EQ, ResultSetReductionJIT::codegen(), CPU, GroupByBaselineHash, logger::init(), run-benchmark-import::result, and ResultSetStorage::ResultSet.

Referenced by TEST(), anonymous_namespace{ResultSetTest.cpp}::test_reduce(), and anonymous_namespace{ResultSetTest.cpp}::test_reduce_random_groups().

1132  {
1133  CHECK(!result_sets.empty());
1134  auto result_rs = result_sets.front();
1135  CHECK(result_rs->storage_);
1136  auto& first_result = *result_rs->storage_;
1137  auto result = &first_result;
1138  const auto row_set_mem_owner = result_rs->row_set_mem_owner_;
1139  for (const auto result_set : result_sets) {
1140  CHECK_EQ(row_set_mem_owner, result_set->row_set_mem_owner_);
1141  }
1142  const auto executor = result_rs->executor_;
1143  for (const auto result_set : result_sets) {
1144  CHECK_EQ(executor, result_set->executor_);
1145  }
1146  if (first_result.query_mem_desc_.getQueryDescriptionType() ==
1148  const auto total_entry_count =
1149  std::accumulate(result_sets.begin(),
1150  result_sets.end(),
1151  size_t(0),
1152  [](const size_t init, const ResultSet* rs) {
1153  return init + rs->query_mem_desc_.getEntryCount();
1154  });
1155  CHECK(total_entry_count);
1156  auto query_mem_desc = first_result.query_mem_desc_;
1157  query_mem_desc.setEntryCount(total_entry_count);
1158  rs_.reset(new ResultSet(first_result.targets_,
1160  query_mem_desc,
1161  row_set_mem_owner,
1162  executor));
1163  auto result_storage = rs_->allocateStorage(first_result.target_init_vals_);
1164  rs_->initializeStorage();
1165  switch (query_mem_desc.getEffectiveKeyWidth()) {
1166  case 4:
1167  first_result.moveEntriesToBuffer<int32_t>(result_storage->getUnderlyingBuffer(),
1168  query_mem_desc.getEntryCount());
1169  break;
1170  case 8:
1171  first_result.moveEntriesToBuffer<int64_t>(result_storage->getUnderlyingBuffer(),
1172  query_mem_desc.getEntryCount());
1173  break;
1174  default:
1175  CHECK(false);
1176  }
1177  result = rs_->storage_.get();
1178  result_rs = rs_.get();
1179  }
1180 
1181  auto& serialized_varlen_buffer = result_sets.front()->serialized_varlen_buffer_;
1182  if (!serialized_varlen_buffer.empty()) {
1183  result->rewriteAggregateBufferOffsets(serialized_varlen_buffer.front());
1184  for (auto result_it = result_sets.begin() + 1; result_it != result_sets.end();
1185  ++result_it) {
1186  auto& result_serialized_varlen_buffer = (*result_it)->serialized_varlen_buffer_;
1187  CHECK_EQ(result_serialized_varlen_buffer.size(), size_t(1));
1188  serialized_varlen_buffer.emplace_back(
1189  std::move(result_serialized_varlen_buffer.front()));
1190  }
1191  }
1192 
1193 #ifdef WITH_REDUCTION_JIT
1194  ResultSetReductionJIT reduction_jit(result_rs->getQueryMemDesc(),
1195  result_rs->getTargetInfos(),
1196  result_rs->getTargetInitVals());
1197  auto reduction_code = reduction_jit.codegen();
1198 #else
1199  ReductionCode reduction_code{};
1200 #endif // WITH_REDUCTION_JIT
1201  size_t ctr = 1;
1202  for (auto result_it = result_sets.begin() + 1; result_it != result_sets.end();
1203  ++result_it) {
1204  if (!serialized_varlen_buffer.empty()) {
1205  result->reduce(
1206  *((*result_it)->storage_), serialized_varlen_buffer[ctr++], reduction_code);
1207  } else {
1208  result->reduce(*((*result_it)->storage_), {}, reduction_code);
1209  }
1210  }
1211  return result_rs;
1212 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::shared_ptr< ResultSet > rs_
Definition: ResultSet.h:882
ReductionCode codegen() const
void init(LogOptions const &log_opts)
Definition: Logger.cpp:260
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rewriteVarlenAggregates()

void ResultSetManager::rewriteVarlenAggregates ( ResultSet result_rs)

Definition at line 1218 of file ResultSetReduction.cpp.

1218  {
1219  auto& result_storage = result_rs->storage_;
1220  result_storage->rewriteAggregateBufferOffsets(
1221  result_rs->serialized_varlen_buffer_.front());
1222 }

Member Data Documentation

◆ rs_

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

Definition at line 882 of file ResultSet.h.


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