OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WindowFunctionContext Class Reference

#include <WindowContext.h>

+ Collaboration diagram for WindowFunctionContext:

Classes

struct  AggregateState
 

Public Types

using Comparator = std::function< bool(const int64_t lhs, const int64_t rhs)>
 

Public Member Functions

 WindowFunctionContext (const Analyzer::WindowFunction *window_func, const std::shared_ptr< HashJoin > &partitions, const size_t elem_count, const ExecutorDeviceType device_type, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner)
 
 WindowFunctionContext (const WindowFunctionContext &)=delete
 
WindowFunctionContextoperator= (const WindowFunctionContext &)=delete
 
 ~WindowFunctionContext ()
 
void addOrderColumn (const int8_t *column, const Analyzer::ColumnVar *col_var, const std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner)
 
void compute ()
 
const Analyzer::WindowFunctiongetWindowFunction () const
 
const int8_t * output () const
 
const int64_t * aggregateState () const
 
const int64_t * aggregateStateCount () const
 
int64_t aggregateStatePendingOutputs () const
 
const int8_t * partitionStart () const
 
const int8_t * partitionEnd () const
 
size_t elementCount () const
 

Private Member Functions

void computePartition (int64_t *output_for_partition_buff, const size_t partition_size, const size_t off, const Analyzer::WindowFunction *window_func, const std::function< bool(const int64_t lhs, const int64_t rhs)> &comparator)
 
void fillPartitionStart ()
 
void fillPartitionEnd ()
 
const int32_t * payload () const
 
const int32_t * offsets () const
 
const int32_t * counts () const
 
size_t partitionCount () const
 

Static Private Member Functions

static Comparator makeComparator (const Analyzer::ColumnVar *col_var, const int8_t *partition_values, const int32_t *partition_indices, const bool nulls_first)
 

Private Attributes

const Analyzer::WindowFunctionwindow_func_
 
std::vector< std::vector
< std::shared_ptr
< Chunk_NS::Chunk > > > 
order_columns_owner_
 
std::vector< const int8_t * > order_columns_
 
std::shared_ptr< HashJoinpartitions_
 
size_t elem_count_
 
int8_t * output_
 
int8_t * partition_start_
 
int8_t * partition_end_
 
AggregateState aggregate_state_
 
const ExecutorDeviceType device_type_
 
std::shared_ptr
< RowSetMemoryOwner
row_set_mem_owner_
 

Detailed Description

Definition at line 66 of file WindowContext.h.

Member Typedef Documentation

using WindowFunctionContext::Comparator = std::function<bool(const int64_t lhs, const int64_t rhs)>

Definition at line 112 of file WindowContext.h.

Constructor & Destructor Documentation

WindowFunctionContext::WindowFunctionContext ( const Analyzer::WindowFunction window_func,
const std::shared_ptr< HashJoin > &  partitions,
const size_t  elem_count,
const ExecutorDeviceType  device_type,
std::shared_ptr< RowSetMemoryOwner row_set_mem_owner 
)

Definition at line 30 of file WindowContext.cpp.

36  : window_func_(window_func)
37  , partitions_(partitions)
38  , elem_count_(elem_count)
39  , output_(nullptr)
40  , partition_start_(nullptr)
41  , partition_end_(nullptr)
42  , device_type_(device_type)
43  , row_set_mem_owner_(row_set_mem_owner) {}
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
const Analyzer::WindowFunction * window_func_
std::shared_ptr< HashJoin > partitions_
const ExecutorDeviceType device_type_
WindowFunctionContext::WindowFunctionContext ( const WindowFunctionContext )
delete
WindowFunctionContext::~WindowFunctionContext ( )

Definition at line 45 of file WindowContext.cpp.

References partition_end_, and partition_start_.

45  {
46  free(partition_start_);
47  free(partition_end_);
48 }

Member Function Documentation

void WindowFunctionContext::addOrderColumn ( const int8_t *  column,
const Analyzer::ColumnVar col_var,
const std::vector< std::shared_ptr< Chunk_NS::Chunk >> &  chunks_owner 
)

Definition at line 50 of file WindowContext.cpp.

References order_columns_, and order_columns_owner_.

53  {
54  order_columns_owner_.push_back(chunks_owner);
55  order_columns_.push_back(column);
56 }
std::vector< const int8_t * > order_columns_
std::vector< std::vector< std::shared_ptr< Chunk_NS::Chunk > > > order_columns_owner_
const int64_t * WindowFunctionContext::aggregateState ( ) const

Definition at line 495 of file WindowContext.cpp.

References aggregate_state_, CHECK, Analyzer::WindowFunction::getKind(), WindowFunctionContext::AggregateState::val, window_func_, and window_function_is_aggregate().

495  {
497  return &aggregate_state_.val;
498 }
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1447
const Analyzer::WindowFunction * window_func_
AggregateState aggregate_state_
bool window_function_is_aggregate(const SqlWindowFunctionKind kind)
Definition: WindowContext.h:42
#define CHECK(condition)
Definition: Logger.h:206

+ Here is the call graph for this function:

const int64_t * WindowFunctionContext::aggregateStateCount ( ) const

Definition at line 500 of file WindowContext.cpp.

References aggregate_state_, CHECK, WindowFunctionContext::AggregateState::count, Analyzer::WindowFunction::getKind(), window_func_, and window_function_is_aggregate().

500  {
502  return &aggregate_state_.count;
503 }
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1447
const Analyzer::WindowFunction * window_func_
AggregateState aggregate_state_
bool window_function_is_aggregate(const SqlWindowFunctionKind kind)
Definition: WindowContext.h:42
#define CHECK(condition)
Definition: Logger.h:206

+ Here is the call graph for this function:

int64_t WindowFunctionContext::aggregateStatePendingOutputs ( ) const

Definition at line 505 of file WindowContext.cpp.

References aggregate_state_, CHECK, Analyzer::WindowFunction::getKind(), WindowFunctionContext::AggregateState::outputs, window_func_, and window_function_is_aggregate().

505  {
507  return reinterpret_cast<int64_t>(&aggregate_state_.outputs);
508 }
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1447
const Analyzer::WindowFunction * window_func_
AggregateState aggregate_state_
bool window_function_is_aggregate(const SqlWindowFunctionKind kind)
Definition: WindowContext.h:42
#define CHECK(condition)
Definition: Logger.h:206

+ Here is the call graph for this function:

void WindowFunctionContext::compute ( )

Definition at line 406 of file WindowContext.cpp.

References CHECK, CHECK_EQ, computePartition(), gpu_enabled::copy(), counts(), elem_count_, fillPartitionEnd(), fillPartitionStart(), Analyzer::WindowFunction::getCollation(), Analyzer::WindowFunction::getKind(), Analyzer::WindowFunction::getOrderKeys(), i, gpu_enabled::iota(), makeComparator(), offsets(), order_columns_, output_, partitionCount(), payload(), row_set_mem_owner_, gpu_enabled::sort(), window_func_, anonymous_namespace{WindowContext.cpp}::window_function_buffer_element_size(), window_function_is_aggregate(), window_function_is_value(), and window_function_requires_peer_handling().

406  {
407  CHECK(!output_);
408  output_ = static_cast<int8_t*>(row_set_mem_owner_->allocate(
410  /*thread_idx=*/0));
415  }
416  }
417  std::unique_ptr<int64_t[]> scratchpad(new int64_t[elem_count_]);
418  int64_t off = 0;
419  for (size_t i = 0; i < partitionCount(); ++i) {
420  auto partition_size = counts()[i];
421  if (partition_size == 0) {
422  continue;
423  }
424  auto output_for_partition_buff = scratchpad.get() + offsets()[i];
425  std::iota(output_for_partition_buff,
426  output_for_partition_buff + partition_size,
427  int64_t(0));
428  std::vector<Comparator> comparators;
429  const auto& order_keys = window_func_->getOrderKeys();
430  const auto& collation = window_func_->getCollation();
431  CHECK_EQ(order_keys.size(), collation.size());
432  for (size_t order_column_idx = 0; order_column_idx < order_columns_.size();
433  ++order_column_idx) {
434  auto order_column_buffer = order_columns_[order_column_idx];
435  const auto order_col =
436  dynamic_cast<const Analyzer::ColumnVar*>(order_keys[order_column_idx].get());
437  CHECK(order_col);
438  const auto& order_col_collation = collation[order_column_idx];
439  const auto asc_comparator = makeComparator(order_col,
440  order_column_buffer,
441  payload() + offsets()[i],
442  order_col_collation.nulls_first);
443  auto comparator = asc_comparator;
444  if (order_col_collation.is_desc) {
445  comparator = [asc_comparator](const int64_t lhs, const int64_t rhs) {
446  return asc_comparator(rhs, lhs);
447  };
448  }
449  comparators.push_back(comparator);
450  }
451  const auto col_tuple_comparator = [&comparators](const int64_t lhs,
452  const int64_t rhs) {
453  for (const auto& comparator : comparators) {
454  if (comparator(lhs, rhs)) {
455  return true;
456  }
457  }
458  return false;
459  };
460  std::sort(output_for_partition_buff,
461  output_for_partition_buff + partition_size,
462  col_tuple_comparator);
463  computePartition(output_for_partition_buff,
464  partition_size,
465  off,
466  window_func_,
467  col_tuple_comparator);
470  off += partition_size;
471  }
472  }
475  CHECK_EQ(static_cast<size_t>(off), elem_count_);
476  }
477  auto output_i64 = reinterpret_cast<int64_t*>(output_);
479  std::copy(scratchpad.get(), scratchpad.get() + elem_count_, output_i64);
480  } else {
481  for (size_t i = 0; i < elem_count_; ++i) {
482  output_i64[payload()[i]] = scratchpad[i];
483  }
484  }
485 }
#define CHECK_EQ(x, y)
Definition: Logger.h:214
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1447
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
DEVICE void sort(ARGS &&...args)
Definition: gpu_enabled.h:105
const Analyzer::WindowFunction * window_func_
const int32_t * counts() const
const int32_t * offsets() const
const std::vector< std::shared_ptr< Analyzer::Expr > > & getOrderKeys() const
Definition: Analyzer.h:1455
const std::vector< OrderEntry > & getCollation() const
Definition: Analyzer.h:1459
void computePartition(int64_t *output_for_partition_buff, const size_t partition_size, const size_t off, const Analyzer::WindowFunction *window_func, const std::function< bool(const int64_t lhs, const int64_t rhs)> &comparator)
size_t partitionCount() const
bool window_function_is_value(const SqlWindowFunctionKind kind)
Definition: WindowContext.h:27
DEVICE auto copy(ARGS &&...args)
Definition: gpu_enabled.h:51
static Comparator makeComparator(const Analyzer::ColumnVar *col_var, const int8_t *partition_values, const int32_t *partition_indices, const bool nulls_first)
bool window_function_is_aggregate(const SqlWindowFunctionKind kind)
Definition: WindowContext.h:42
DEVICE void iota(ARGS &&...args)
Definition: gpu_enabled.h:69
bool window_function_requires_peer_handling(const Analyzer::WindowFunction *window_func)
size_t window_function_buffer_element_size(const SqlWindowFunctionKind)
#define CHECK(condition)
Definition: Logger.h:206
std::vector< const int8_t * > order_columns_
const int32_t * payload() const

+ Here is the call graph for this function:

void WindowFunctionContext::computePartition ( int64_t *  output_for_partition_buff,
const size_t  partition_size,
const size_t  off,
const Analyzer::WindowFunction window_func,
const std::function< bool(const int64_t lhs, const int64_t rhs)> &  comparator 
)
private

Definition at line 641 of file WindowContext.cpp.

References anonymous_namespace{WindowContext.cpp}::apply_first_value_to_partition(), anonymous_namespace{WindowContext.cpp}::apply_lag_to_partition(), anonymous_namespace{WindowContext.cpp}::apply_last_value_to_partition(), anonymous_namespace{WindowContext.cpp}::apply_permutation_to_partition(), run_benchmark_import::args, AVG, CHECK_EQ, gpu_enabled::copy(), COUNT, CUME_DIST, DENSE_RANK, FIRST_VALUE, anonymous_namespace{WindowContext.cpp}::get_int_constant_from_expr(), anonymous_namespace{WindowContext.cpp}::get_lag_or_lead_argument(), Analyzer::WindowFunction::getArgs(), Analyzer::WindowFunction::getKind(), anonymous_namespace{WindowContext.cpp}::index_to_cume_dist(), anonymous_namespace{WindowContext.cpp}::index_to_dense_rank(), anonymous_namespace{WindowContext.cpp}::index_to_ntile(), anonymous_namespace{WindowContext.cpp}::index_to_partition_end(), anonymous_namespace{WindowContext.cpp}::index_to_percent_rank(), anonymous_namespace{WindowContext.cpp}::index_to_rank(), anonymous_namespace{WindowContext.cpp}::index_to_row_number(), LAG, LAST_VALUE, LEAD, MAX, MIN, NTILE, partitionEnd(), payload(), PERCENT_RANK, RANK, ROW_NUMBER, SUM, toString(), and window_function_requires_peer_handling().

Referenced by compute().

646  {
647  switch (window_func->getKind()) {
649  const auto row_numbers =
650  index_to_row_number(output_for_partition_buff, partition_size);
651  std::copy(row_numbers.begin(), row_numbers.end(), output_for_partition_buff);
652  break;
653  }
655  const auto rank =
656  index_to_rank(output_for_partition_buff, partition_size, comparator);
657  std::copy(rank.begin(), rank.end(), output_for_partition_buff);
658  break;
659  }
661  const auto dense_rank =
662  index_to_dense_rank(output_for_partition_buff, partition_size, comparator);
663  std::copy(dense_rank.begin(), dense_rank.end(), output_for_partition_buff);
664  break;
665  }
667  const auto percent_rank =
668  index_to_percent_rank(output_for_partition_buff, partition_size, comparator);
669  std::copy(percent_rank.begin(),
670  percent_rank.end(),
671  reinterpret_cast<double*>(may_alias_ptr(output_for_partition_buff)));
672  break;
673  }
675  const auto cume_dist =
676  index_to_cume_dist(output_for_partition_buff, partition_size, comparator);
677  std::copy(cume_dist.begin(),
678  cume_dist.end(),
679  reinterpret_cast<double*>(may_alias_ptr(output_for_partition_buff)));
680  break;
681  }
683  const auto& args = window_func->getArgs();
684  CHECK_EQ(args.size(), size_t(1));
685  const auto n = get_int_constant_from_expr(args.front().get());
686  const auto ntile = index_to_ntile(output_for_partition_buff, partition_size, n);
687  std::copy(ntile.begin(), ntile.end(), output_for_partition_buff);
688  break;
689  }
692  const auto lag_or_lead = get_lag_or_lead_argument(window_func);
693  const auto partition_row_offsets = payload() + off;
695  lag_or_lead, partition_row_offsets, output_for_partition_buff, partition_size);
696  break;
697  }
699  const auto partition_row_offsets = payload() + off;
701  partition_row_offsets, output_for_partition_buff, partition_size);
702  break;
703  }
705  const auto partition_row_offsets = payload() + off;
707  partition_row_offsets, output_for_partition_buff, partition_size);
708  break;
709  }
715  const auto partition_row_offsets = payload() + off;
716  if (window_function_requires_peer_handling(window_func)) {
718  partitionEnd(), off, output_for_partition_buff, partition_size, comparator);
719  }
721  output_for_partition_buff, partition_row_offsets, partition_size);
722  break;
723  }
724  default: {
725  throw std::runtime_error("Window function not supported yet: " +
726  ::toString(window_func->getKind()));
727  }
728  }
729 }
#define CHECK_EQ(x, y)
Definition: Logger.h:214
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1447
std::string toString(const ExtArgumentType &sig_type)
std::vector< int64_t > index_to_ntile(const int64_t *index, const size_t index_size, const size_t n)
std::vector< double > index_to_percent_rank(const int64_t *index, const size_t index_size, const std::function< bool(const int64_t lhs, const int64_t rhs)> &comparator)
void apply_permutation_to_partition(int64_t *output_for_partition_buff, const int32_t *original_indices, const size_t partition_size)
int64_t get_lag_or_lead_argument(const Analyzer::WindowFunction *window_func)
void index_to_partition_end(const int8_t *partition_end, const size_t off, const int64_t *index, const size_t index_size, const std::function< bool(const int64_t lhs, const int64_t rhs)> &comparator)
std::vector< int64_t > index_to_row_number(const int64_t *index, const size_t index_size)
std::vector< int64_t > index_to_dense_rank(const int64_t *index, const size_t index_size, const std::function< bool(const int64_t lhs, const int64_t rhs)> &comparator)
void apply_last_value_to_partition(const int32_t *original_indices, int64_t *output_for_partition_buff, const size_t partition_size)
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs() const
Definition: Analyzer.h:1449
const int8_t * partitionEnd() const
DEVICE auto copy(ARGS &&...args)
Definition: gpu_enabled.h:51
void apply_first_value_to_partition(const int32_t *original_indices, int64_t *output_for_partition_buff, const size_t partition_size)
void apply_lag_to_partition(const int64_t lag, const int32_t *original_indices, int64_t *sorted_indices, const size_t partition_size)
bool window_function_requires_peer_handling(const Analyzer::WindowFunction *window_func)
std::vector< double > index_to_cume_dist(const int64_t *index, const size_t index_size, const std::function< bool(const int64_t lhs, const int64_t rhs)> &comparator)
std::vector< int64_t > index_to_rank(const int64_t *index, const size_t index_size, const std::function< bool(const int64_t lhs, const int64_t rhs)> &comparator)
const int32_t * payload() const
size_t get_int_constant_from_expr(const Analyzer::Expr *expr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int32_t * WindowFunctionContext::counts ( ) const
private

Definition at line 784 of file WindowContext.cpp.

References device_type_, and partitions_.

Referenced by compute(), fillPartitionEnd(), fillPartitionStart(), and partitionCount().

784  {
785  return reinterpret_cast<const int32_t*>(
786  partitions_->getJoinHashBuffer(device_type_, 0) + partitions_->countBufferOff());
787 }
std::shared_ptr< HashJoin > partitions_
const ExecutorDeviceType device_type_

+ Here is the caller graph for this function:

size_t WindowFunctionContext::elementCount ( ) const

Definition at line 518 of file WindowContext.cpp.

References elem_count_.

518  {
519  return elem_count_;
520 }
void WindowFunctionContext::fillPartitionEnd ( )
private

Definition at line 750 of file WindowContext.cpp.

References agg_count_distinct_bitmap(), Bitmap, checked_calloc(), counts(), CPU, elem_count_, i, gpu_enabled::partial_sum(), partition_end_, and partitionCount().

Referenced by compute().

750  {
752  0,
753  static_cast<int64_t>(elem_count_),
754  false,
756  1};
757  partition_end_ = static_cast<int8_t*>(
758  checked_calloc(partition_start_bitmap.bitmapPaddedSizeBytes(), 1));
759  int64_t partition_count = partitionCount();
760  std::vector<size_t> partition_offsets(partition_count);
761  std::partial_sum(counts(), counts() + partition_count, partition_offsets.begin());
762  auto partition_end_handle = reinterpret_cast<int64_t>(partition_end_);
763  for (int64_t i = 0; i < partition_count - 1; ++i) {
764  if (partition_offsets[i] == 0) {
765  continue;
766  }
767  agg_count_distinct_bitmap(&partition_end_handle, partition_offsets[i] - 1, 0);
768  }
769  if (elem_count_) {
770  agg_count_distinct_bitmap(&partition_end_handle, elem_count_ - 1, 0);
771  }
772 }
const int32_t * counts() const
size_t partitionCount() const
DEVICE void partial_sum(ARGS &&...args)
Definition: gpu_enabled.h:87
void * checked_calloc(const size_t nmemb, const size_t size)
Definition: checked_alloc.h:53
ALWAYS_INLINE void agg_count_distinct_bitmap(int64_t *agg, const int64_t val, const int64_t min_val)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WindowFunctionContext::fillPartitionStart ( )
private

Definition at line 731 of file WindowContext.cpp.

References agg_count_distinct_bitmap(), Bitmap, checked_calloc(), counts(), CPU, elem_count_, i, gpu_enabled::partial_sum(), partition_start_, and partitionCount().

Referenced by compute().

731  {
733  0,
734  static_cast<int64_t>(elem_count_),
735  false,
737  1};
738  partition_start_ = static_cast<int8_t*>(
739  checked_calloc(partition_start_bitmap.bitmapPaddedSizeBytes(), 1));
740  int64_t partition_count = partitionCount();
741  std::vector<size_t> partition_offsets(partition_count);
742  std::partial_sum(counts(), counts() + partition_count, partition_offsets.begin());
743  auto partition_start_handle = reinterpret_cast<int64_t>(partition_start_);
744  agg_count_distinct_bitmap(&partition_start_handle, 0, 0);
745  for (int64_t i = 0; i < partition_count - 1; ++i) {
746  agg_count_distinct_bitmap(&partition_start_handle, partition_offsets[i], 0);
747  }
748 }
const int32_t * counts() const
size_t partitionCount() const
DEVICE void partial_sum(ARGS &&...args)
Definition: gpu_enabled.h:87
void * checked_calloc(const size_t nmemb, const size_t size)
Definition: checked_alloc.h:53
ALWAYS_INLINE void agg_count_distinct_bitmap(int64_t *agg, const int64_t val, const int64_t min_val)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const Analyzer::WindowFunction * WindowFunctionContext::getWindowFunction ( ) const

Definition at line 487 of file WindowContext.cpp.

References window_func_.

Referenced by Executor::codegenWindowFunction().

487  {
488  return window_func_;
489 }
const Analyzer::WindowFunction * window_func_

+ Here is the caller graph for this function:

std::function< bool(const int64_t lhs, const int64_t rhs)> WindowFunctionContext::makeComparator ( const Analyzer::ColumnVar col_var,
const int8_t *  partition_values,
const int32_t *  partition_indices,
const bool  nulls_first 
)
staticprivate

Definition at line 577 of file WindowContext.cpp.

References logger::FATAL, Analyzer::Expr::get_type_info(), kDOUBLE, kFLOAT, and LOG.

Referenced by compute().

580  {
581  const auto& ti = col_var->get_type_info();
582  if (ti.is_integer() || ti.is_decimal() || ti.is_time() || ti.is_boolean()) {
583  switch (ti.get_size()) {
584  case 8: {
585  return [order_column_buffer, nulls_first, partition_indices, &ti](
586  const int64_t lhs, const int64_t rhs) {
587  return integer_comparator<int64_t>(
588  order_column_buffer, ti, partition_indices, lhs, rhs, nulls_first);
589  };
590  }
591  case 4: {
592  return [order_column_buffer, nulls_first, partition_indices, &ti](
593  const int64_t lhs, const int64_t rhs) {
594  return integer_comparator<int32_t>(
595  order_column_buffer, ti, partition_indices, lhs, rhs, nulls_first);
596  };
597  }
598  case 2: {
599  return [order_column_buffer, nulls_first, partition_indices, &ti](
600  const int64_t lhs, const int64_t rhs) {
601  return integer_comparator<int16_t>(
602  order_column_buffer, ti, partition_indices, lhs, rhs, nulls_first);
603  };
604  }
605  case 1: {
606  return [order_column_buffer, nulls_first, partition_indices, &ti](
607  const int64_t lhs, const int64_t rhs) {
608  return integer_comparator<int8_t>(
609  order_column_buffer, ti, partition_indices, lhs, rhs, nulls_first);
610  };
611  }
612  default: {
613  LOG(FATAL) << "Invalid type size: " << ti.get_size();
614  }
615  }
616  }
617  if (ti.is_fp()) {
618  switch (ti.get_type()) {
619  case kFLOAT: {
620  return [order_column_buffer, nulls_first, partition_indices, &ti](
621  const int64_t lhs, const int64_t rhs) {
622  return fp_comparator<float, int32_t>(
623  order_column_buffer, ti, partition_indices, lhs, rhs, nulls_first);
624  };
625  }
626  case kDOUBLE: {
627  return [order_column_buffer, nulls_first, partition_indices, &ti](
628  const int64_t lhs, const int64_t rhs) {
629  return fp_comparator<double, int64_t>(
630  order_column_buffer, ti, partition_indices, lhs, rhs, nulls_first);
631  };
632  }
633  default: {
634  LOG(FATAL) << "Invalid float type";
635  }
636  }
637  }
638  throw std::runtime_error("Type not supported yet");
639 }
#define LOG(tag)
Definition: Logger.h:200
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int32_t * WindowFunctionContext::offsets ( ) const
private

Definition at line 779 of file WindowContext.cpp.

References device_type_, and partitions_.

Referenced by compute(), and partitionCount().

779  {
780  return reinterpret_cast<const int32_t*>(
781  partitions_->getJoinHashBuffer(device_type_, 0) + partitions_->offsetBufferOff());
782 }
std::shared_ptr< HashJoin > partitions_
const ExecutorDeviceType device_type_

+ Here is the caller graph for this function:

WindowFunctionContext& WindowFunctionContext::operator= ( const WindowFunctionContext )
delete
const int8_t * WindowFunctionContext::output ( ) const

Definition at line 491 of file WindowContext.cpp.

References output_.

Referenced by CodeGenerator::codegenWindowPosition().

491  {
492  return output_;
493 }

+ Here is the caller graph for this function:

size_t WindowFunctionContext::partitionCount ( ) const
private

Definition at line 789 of file WindowContext.cpp.

References CHECK_GE, counts(), and offsets().

Referenced by compute(), fillPartitionEnd(), and fillPartitionStart().

789  {
790  const auto partition_count = counts() - offsets();
791  CHECK_GE(partition_count, 0);
792  return partition_count;
793 }
#define CHECK_GE(x, y)
Definition: Logger.h:219
const int32_t * counts() const
const int32_t * offsets() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int8_t * WindowFunctionContext::partitionEnd ( ) const

Definition at line 514 of file WindowContext.cpp.

References partition_end_.

Referenced by computePartition().

514  {
515  return partition_end_;
516 }

+ Here is the caller graph for this function:

const int8_t * WindowFunctionContext::partitionStart ( ) const

Definition at line 510 of file WindowContext.cpp.

References partition_start_.

510  {
511  return partition_start_;
512 }
const int32_t * WindowFunctionContext::payload ( ) const
private

Definition at line 774 of file WindowContext.cpp.

References device_type_, and partitions_.

Referenced by compute(), and computePartition().

774  {
775  return reinterpret_cast<const int32_t*>(
776  partitions_->getJoinHashBuffer(device_type_, 0) + partitions_->payloadBufferOff());
777 }
std::shared_ptr< HashJoin > partitions_
const ExecutorDeviceType device_type_

+ Here is the caller graph for this function:

Member Data Documentation

AggregateState WindowFunctionContext::aggregate_state_
private
const ExecutorDeviceType WindowFunctionContext::device_type_
private

Definition at line 166 of file WindowContext.h.

Referenced by counts(), offsets(), and payload().

size_t WindowFunctionContext::elem_count_
private

Definition at line 155 of file WindowContext.h.

Referenced by compute(), elementCount(), fillPartitionEnd(), and fillPartitionStart().

std::vector<const int8_t*> WindowFunctionContext::order_columns_
private

Definition at line 151 of file WindowContext.h.

Referenced by addOrderColumn(), and compute().

std::vector<std::vector<std::shared_ptr<Chunk_NS::Chunk> > > WindowFunctionContext::order_columns_owner_
private

Definition at line 149 of file WindowContext.h.

Referenced by addOrderColumn().

int8_t* WindowFunctionContext::output_
private

Definition at line 157 of file WindowContext.h.

Referenced by compute(), and output().

int8_t* WindowFunctionContext::partition_end_
private

Definition at line 163 of file WindowContext.h.

Referenced by fillPartitionEnd(), partitionEnd(), and ~WindowFunctionContext().

int8_t* WindowFunctionContext::partition_start_
private

Definition at line 160 of file WindowContext.h.

Referenced by fillPartitionStart(), partitionStart(), and ~WindowFunctionContext().

std::shared_ptr<HashJoin> WindowFunctionContext::partitions_
private

Definition at line 153 of file WindowContext.h.

Referenced by counts(), offsets(), and payload().

std::shared_ptr<RowSetMemoryOwner> WindowFunctionContext::row_set_mem_owner_
private

Definition at line 167 of file WindowContext.h.

Referenced by compute().

const Analyzer::WindowFunction* WindowFunctionContext::window_func_
private

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