OmniSciDB  b24e664e58
 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 879 of file ResultSet.h.

Member Function Documentation

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

Definition at line 1075 of file ResultSetReduction.cpp.

References rs_.

1075  {
1076  return rs_;
1077 }
std::shared_ptr< ResultSet > rs_
Definition: ResultSet.h:888
ResultSet * ResultSetManager::reduce ( std::vector< ResultSet * > &  result_sets)

Definition at line 997 of file ResultSetReduction.cpp.

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

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

+ Here is the call graph for this function:

void ResultSetManager::rewriteVarlenAggregates ( ResultSet result_rs)

Definition at line 1079 of file ResultSetReduction.cpp.

1079  {
1080  auto& result_storage = result_rs->storage_;
1081  result_storage->rewriteAggregateBufferOffsets(
1082  result_rs->serialized_varlen_buffer_.front());
1083 }

Member Data Documentation

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

Definition at line 888 of file ResultSet.h.

Referenced by getOwnResultSet(), and reduce().


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