OmniSciDB  04ee39c94c
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< JoinHashTableInterface > &partitions, const size_t elem_count, const ExecutorDeviceType device_type)
 
 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
 
void setRowNumber (llvm::Value *row_number)
 
llvm::Value * getRowNumber () 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< JoinHashTableInterfacepartitions_
 
size_t elem_count_
 
int8_t * output_
 
int8_t * partition_start_
 
int8_t * partition_end_
 
AggregateState aggregate_state_
 
const ExecutorDeviceType device_type_
 

Detailed Description

Definition at line 64 of file WindowContext.h.

Member Typedef Documentation

◆ Comparator

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

Definition at line 115 of file WindowContext.h.

Constructor & Destructor Documentation

◆ WindowFunctionContext() [1/2]

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

Definition at line 27 of file WindowContext.cpp.

32  : window_func_(window_func)
33  , partitions_(partitions)
34  , elem_count_(elem_count)
35  , output_(nullptr)
36  , partition_start_(nullptr)
37  , partition_end_(nullptr)
38  , device_type_(device_type) {}
const Analyzer::WindowFunction * window_func_
std::shared_ptr< JoinHashTableInterface > partitions_
const ExecutorDeviceType device_type_

◆ WindowFunctionContext() [2/2]

WindowFunctionContext::WindowFunctionContext ( const WindowFunctionContext )
delete

◆ ~WindowFunctionContext()

WindowFunctionContext::~WindowFunctionContext ( )

Definition at line 40 of file WindowContext.cpp.

References output_, partition_end_, and partition_start_.

40  {
41  free(output_);
42  free(partition_start_);
43  free(partition_end_);
44 }

Member Function Documentation

◆ addOrderColumn()

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 46 of file WindowContext.cpp.

References order_columns_, and order_columns_owner_.

49  {
50  order_columns_owner_.push_back(chunks_owner);
51  order_columns_.push_back(column);
52 }
std::vector< const int8_t * > order_columns_
std::vector< std::vector< std::shared_ptr< Chunk_NS::Chunk > > > order_columns_owner_

◆ aggregateState()

const int64_t * WindowFunctionContext::aggregateState ( ) const

Definition at line 487 of file WindowContext.cpp.

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

487  {
489  return &aggregate_state_.val;
490 }
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:187
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1339
+ Here is the call graph for this function:

◆ aggregateStateCount()

const int64_t * WindowFunctionContext::aggregateStateCount ( ) const

Definition at line 492 of file WindowContext.cpp.

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

492  {
494  return &aggregate_state_.count;
495 }
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:187
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1339
+ Here is the call graph for this function:

◆ aggregateStatePendingOutputs()

int64_t WindowFunctionContext::aggregateStatePendingOutputs ( ) const

Definition at line 497 of file WindowContext.cpp.

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

497  {
499  return reinterpret_cast<int64_t>(&aggregate_state_.outputs);
500 }
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:187
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1339
+ Here is the call graph for this function:

◆ compute()

void WindowFunctionContext::compute ( )

Definition at line 399 of file WindowContext.cpp.

References CHECK, CHECK_EQ, checked_malloc(), computePartition(), counts(), elem_count_, fillPartitionEnd(), fillPartitionStart(), Analyzer::WindowFunction::getCollation(), Analyzer::WindowFunction::getKind(), Analyzer::WindowFunction::getOrderKeys(), makeComparator(), offsets(), order_columns_, output_, partitionCount(), payload(), 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().

399  {
400  CHECK(!output_);
401  output_ = static_cast<int8_t*>(checked_malloc(
407  }
408  }
409  std::unique_ptr<int64_t[]> scratchpad(new int64_t[elem_count_]);
410  int64_t off = 0;
411  for (size_t i = 0; i < partitionCount(); ++i) {
412  auto partition_size = counts()[i];
413  if (partition_size == 0) {
414  continue;
415  }
416  auto output_for_partition_buff = scratchpad.get() + offsets()[i];
417  std::iota(output_for_partition_buff,
418  output_for_partition_buff + partition_size,
419  int64_t(0));
420  std::vector<Comparator> comparators;
421  const auto& order_keys = window_func_->getOrderKeys();
422  const auto& collation = window_func_->getCollation();
423  CHECK_EQ(order_keys.size(), collation.size());
424  for (size_t order_column_idx = 0; order_column_idx < order_columns_.size();
425  ++order_column_idx) {
426  auto order_column_buffer = order_columns_[order_column_idx];
427  const auto order_col =
428  dynamic_cast<const Analyzer::ColumnVar*>(order_keys[order_column_idx].get());
429  CHECK(order_col);
430  const auto& order_col_collation = collation[order_column_idx];
431  const auto asc_comparator = makeComparator(order_col,
432  order_column_buffer,
433  payload() + offsets()[i],
434  order_col_collation.nulls_first);
435  auto comparator = asc_comparator;
436  if (order_col_collation.is_desc) {
437  comparator = [asc_comparator](const int64_t lhs, const int64_t rhs) {
438  return asc_comparator(rhs, lhs);
439  };
440  }
441  comparators.push_back(comparator);
442  }
443  const auto col_tuple_comparator = [&comparators](const int64_t lhs,
444  const int64_t rhs) {
445  for (const auto& comparator : comparators) {
446  if (comparator(lhs, rhs)) {
447  return true;
448  }
449  }
450  return false;
451  };
452  std::sort(output_for_partition_buff,
453  output_for_partition_buff + partition_size,
454  col_tuple_comparator);
455  computePartition(output_for_partition_buff,
456  partition_size,
457  off,
458  window_func_,
459  col_tuple_comparator);
462  off += partition_size;
463  }
464  }
467  CHECK_EQ(static_cast<size_t>(off), elem_count_);
468  }
469  auto output_i64 = reinterpret_cast<int64_t*>(output_);
471  std::copy(scratchpad.get(), scratchpad.get() + elem_count_, output_i64);
472  } else {
473  for (size_t i = 0; i < elem_count_; ++i) {
474  output_i64[payload()[i]] = scratchpad[i];
475  }
476  }
477 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
const int32_t * payload() const
const std::vector< std::shared_ptr< Analyzer::Expr > > & getOrderKeys() const
Definition: Analyzer.h:1347
const int32_t * counts() const
const Analyzer::WindowFunction * window_func_
size_t partitionCount() const
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)
bool window_function_is_value(const SqlWindowFunctionKind kind)
Definition: WindowContext.h:27
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:40
const std::vector< OrderEntry > & getCollation() const
Definition: Analyzer.h:1351
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
const int32_t * offsets() const
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:187
std::vector< const int8_t * > order_columns_
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1339
+ Here is the call graph for this function:

◆ computePartition()

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, 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, sql_window_function_to_str(), SUM, 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  sql_window_function_to_str(window_func->getKind()));
727  }
728  }
729 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
const int32_t * payload() const
void apply_lag_to_partition(const ssize_t lag, const int32_t *original_indices, int64_t *sorted_indices, const size_t partition_size)
std::vector< int64_t > index_to_ntile(const int64_t *index, const size_t index_size, const size_t n)
ssize_t get_lag_or_lead_argument(const Analyzer::WindowFunction *window_func)
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)
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)
void apply_first_value_to_partition(const int32_t *original_indices, int64_t *output_for_partition_buff, const size_t partition_size)
std::string sql_window_function_to_str(const SqlWindowFunctionKind kind)
bool window_function_requires_peer_handling(const Analyzer::WindowFunction *window_func)
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs() const
Definition: Analyzer.h:1341
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)
size_t get_int_constant_from_expr(const Analyzer::Expr *expr)
const int8_t * partitionEnd() const
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1339
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ counts()

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< JoinHashTableInterface > partitions_
const ExecutorDeviceType device_type_
+ Here is the caller graph for this function:

◆ elementCount()

size_t WindowFunctionContext::elementCount ( ) const

Definition at line 510 of file WindowContext.cpp.

References elem_count_.

510  {
511  return elem_count_;
512 }

◆ fillPartitionEnd()

void WindowFunctionContext::fillPartitionEnd ( )
private

Definition at line 750 of file WindowContext.cpp.

References agg_count_distinct_bitmap(), Bitmap, checked_calloc(), counts(), CPU, elem_count_, 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  ssize_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 (ssize_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
void * checked_calloc(const size_t nmemb, const size_t size)
Definition: checked_alloc.h:48
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:

◆ fillPartitionStart()

void WindowFunctionContext::fillPartitionStart ( )
private

Definition at line 731 of file WindowContext.cpp.

References agg_count_distinct_bitmap(), Bitmap, checked_calloc(), counts(), CPU, elem_count_, 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  ssize_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 (ssize_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
void * checked_calloc(const size_t nmemb, const size_t size)
Definition: checked_alloc.h:48
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:

◆ getRowNumber()

llvm::Value * WindowFunctionContext::getRowNumber ( ) const

Definition at line 518 of file WindowContext.cpp.

References aggregate_state_, and WindowFunctionContext::AggregateState::row_number.

518  {
520 }
AggregateState aggregate_state_

◆ getWindowFunction()

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

Definition at line 479 of file WindowContext.cpp.

References window_func_.

Referenced by Executor::codegenWindowFunction().

479  {
480  return window_func_;
481 }
const Analyzer::WindowFunction * window_func_
+ Here is the caller graph for this function:

◆ makeComparator()

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:182
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ offsets()

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< JoinHashTableInterface > partitions_
const ExecutorDeviceType device_type_
+ Here is the caller graph for this function:

◆ operator=()

WindowFunctionContext& WindowFunctionContext::operator= ( const WindowFunctionContext )
delete

◆ output()

const int8_t * WindowFunctionContext::output ( ) const

Definition at line 483 of file WindowContext.cpp.

References output_.

Referenced by CodeGenerator::codegenWindowPosition().

483  {
484  return output_;
485 }
+ Here is the caller graph for this function:

◆ partitionCount()

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 }
const int32_t * counts() const
#define CHECK_GE(x, y)
Definition: Logger.h:200
const int32_t * offsets() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ partitionEnd()

const int8_t * WindowFunctionContext::partitionEnd ( ) const

Definition at line 506 of file WindowContext.cpp.

References partition_end_.

Referenced by computePartition().

506  {
507  return partition_end_;
508 }
+ Here is the caller graph for this function:

◆ partitionStart()

const int8_t * WindowFunctionContext::partitionStart ( ) const

Definition at line 502 of file WindowContext.cpp.

References partition_start_.

502  {
503  return partition_start_;
504 }

◆ payload()

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< JoinHashTableInterface > partitions_
const ExecutorDeviceType device_type_
+ Here is the caller graph for this function:

◆ setRowNumber()

void WindowFunctionContext::setRowNumber ( llvm::Value *  row_number)

Definition at line 514 of file WindowContext.cpp.

References aggregate_state_, and WindowFunctionContext::AggregateState::row_number.

Referenced by CodeGenerator::codegenWindowPosition().

514  {
515  aggregate_state_.row_number = row_number;
516 }
AggregateState aggregate_state_
+ Here is the caller graph for this function:

Member Data Documentation

◆ aggregate_state_

AggregateState WindowFunctionContext::aggregate_state_
private

◆ device_type_

const ExecutorDeviceType WindowFunctionContext::device_type_
private

Definition at line 169 of file WindowContext.h.

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

◆ elem_count_

size_t WindowFunctionContext::elem_count_
private

Definition at line 158 of file WindowContext.h.

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

◆ order_columns_

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

Definition at line 154 of file WindowContext.h.

Referenced by addOrderColumn(), and compute().

◆ order_columns_owner_

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

Definition at line 152 of file WindowContext.h.

Referenced by addOrderColumn().

◆ output_

int8_t* WindowFunctionContext::output_
private

Definition at line 160 of file WindowContext.h.

Referenced by compute(), output(), and ~WindowFunctionContext().

◆ partition_end_

int8_t* WindowFunctionContext::partition_end_
private

Definition at line 166 of file WindowContext.h.

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

◆ partition_start_

int8_t* WindowFunctionContext::partition_start_
private

Definition at line 163 of file WindowContext.h.

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

◆ partitions_

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

Definition at line 156 of file WindowContext.h.

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

◆ window_func_

const Analyzer::WindowFunction* WindowFunctionContext::window_func_
private

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