OmniSciDB  2e3a973ef4
SpeculativeTopN.h File Reference

Speculative top N algorithm. More...

#include <cstddef>
#include <cstdint>
#include <memory>
#include <mutex>
#include <stdexcept>
#include <unordered_map>
#include <vector>
+ Include dependency graph for SpeculativeTopN.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SpeculativeTopNVal
 
struct  SpeculativeTopNEntry
 
class  SpeculativeTopNMap
 
class  SpeculativeTopNFailed
 
class  SpeculativeTopNBlacklist
 

Namespaces

 Analyzer
 

Functions

bool use_speculative_top_n (const RelAlgExecutionUnit &, const QueryMemoryDescriptor &)
 

Detailed Description

Speculative top N algorithm.

Author
Alex Suhan alex@.nosp@m.mapd.nosp@m..com Copyright (c) 2016 MapD Technologies, Inc. All rights reserved.

Definition in file SpeculativeTopN.h.

Function Documentation

◆ use_speculative_top_n()

bool use_speculative_top_n ( const RelAlgExecutionUnit ra_exe_unit,
const QueryMemoryDescriptor query_mem_desc 
)

SpeculativeTopN sort is used when there are multiple already sorted results (when GPU sort is used on multiple devices, refer to GroupByAndAggregate::gpuCanHandleOrderEntries), and we want to pick top n elements (LIMIT caluse exists), and we have already chosen this algorithm when creating the proper work unit (refer to RelAlgExecutor::createSortInputWorkUnit).

Besides, we currently only support cases with 2 target expressions and only with COUNT aggregate (similar limitations exists in whether or not we support GPU sort).

Definition at line 187 of file SpeculativeTopN.cpp.

References SortInfo::algorithm, g_cluster, kCOUNT, SortInfo::limit, RelAlgExecutionUnit::sort_info, QueryMemoryDescriptor::sortOnGpu(), SpeculativeTopN, and RelAlgExecutionUnit::target_exprs.

Referenced by Executor::collectAllDeviceResults(), RelAlgExecutor::executeSort(), and QueryExecutionContext::launchGpuCode().

188  {
189  if (g_cluster) {
190  return false;
191  }
192  if (ra_exe_unit.target_exprs.size() != 2) {
193  return false;
194  }
195  for (const auto target_expr : ra_exe_unit.target_exprs) {
196  const auto agg_expr = dynamic_cast<const Analyzer::AggExpr*>(target_expr);
197  if (agg_expr && agg_expr->get_aggtype() != kCOUNT) {
198  return false;
199  }
200  }
201  return query_mem_desc.sortOnGpu() && ra_exe_unit.sort_info.limit &&
203 }
std::vector< Analyzer::Expr * > target_exprs
const SortAlgorithm algorithm
const size_t limit
const SortInfo sort_info
Definition: sqldefs.h:76
bool g_cluster
+ Here is the call graph for this function:
+ Here is the caller graph for this function: