OmniSciDB  06b3bd477c
 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 915 of file ResultSet.h.

Member Function Documentation

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

Definition at line 1081 of file ResultSetReduction.cpp.

References rs_.

1081  {
1082  return rs_;
1083 }
std::shared_ptr< ResultSet > rs_
Definition: ResultSet.h:924
ResultSet * ResultSetManager::reduce ( std::vector< ResultSet * > &  result_sets)

Definition at line 1003 of file ResultSetReduction.cpp.

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

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

+ Here is the call graph for this function:

void ResultSetManager::rewriteVarlenAggregates ( ResultSet result_rs)

Definition at line 1085 of file ResultSetReduction.cpp.

1085  {
1086  auto& result_storage = result_rs->storage_;
1087  result_storage->rewriteAggregateBufferOffsets(
1088  result_rs->serialized_varlen_buffer_.front());
1089 }

Member Data Documentation

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

Definition at line 924 of file ResultSet.h.

Referenced by getOwnResultSet(), and reduce().


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