OmniSciDB  340b00dbf6
 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< JoinHashTableInterface > &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
 
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
< JoinHashTableInterface
partitions_
 
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 118 of file WindowContext.h.

Constructor & Destructor Documentation

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

Definition at line 29 of file WindowContext.cpp.

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

Definition at line 44 of file WindowContext.cpp.

References partition_end_, and partition_start_.

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

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

References order_columns_, and order_columns_owner_.

52  {
53  order_columns_owner_.push_back(chunks_owner);
54  order_columns_.push_back(column);
55 }
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 491 of file WindowContext.cpp.

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

491  {
493  return &aggregate_state_.val;
494 }
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:197

+ Here is the call graph for this function:

const int64_t * WindowFunctionContext::aggregateStateCount ( ) const

Definition at line 496 of file WindowContext.cpp.

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

496  {
498  return &aggregate_state_.count;
499 }
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:197

+ Here is the call graph for this function:

int64_t WindowFunctionContext::aggregateStatePendingOutputs ( ) const

Definition at line 501 of file WindowContext.cpp.

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

501  {
503  return reinterpret_cast<int64_t>(&aggregate_state_.outputs);
504 }
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:197

+ Here is the call graph for this function:

void WindowFunctionContext::compute ( )

Definition at line 403 of file WindowContext.cpp.

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

403  {
404  CHECK(!output_);
405  output_ = static_cast<int8_t*>(row_set_mem_owner_->allocate(
411  }
412  }
413  std::unique_ptr<int64_t[]> scratchpad(new int64_t[elem_count_]);
414  int64_t off = 0;
415  for (size_t i = 0; i < partitionCount(); ++i) {
416  auto partition_size = counts()[i];
417  if (partition_size == 0) {
418  continue;
419  }
420  auto output_for_partition_buff = scratchpad.get() + offsets()[i];
421  std::iota(output_for_partition_buff,
422  output_for_partition_buff + partition_size,
423  int64_t(0));
424  std::vector<Comparator> comparators;
425  const auto& order_keys = window_func_->getOrderKeys();
426  const auto& collation = window_func_->getCollation();
427  CHECK_EQ(order_keys.size(), collation.size());
428  for (size_t order_column_idx = 0; order_column_idx < order_columns_.size();
429  ++order_column_idx) {
430  auto order_column_buffer = order_columns_[order_column_idx];
431  const auto order_col =
432  dynamic_cast<const Analyzer::ColumnVar*>(order_keys[order_column_idx].get());
433  CHECK(order_col);
434  const auto& order_col_collation = collation[order_column_idx];
435  const auto asc_comparator = makeComparator(order_col,
436  order_column_buffer,
437  payload() + offsets()[i],
438  order_col_collation.nulls_first);
439  auto comparator = asc_comparator;
440  if (order_col_collation.is_desc) {
441  comparator = [asc_comparator](const int64_t lhs, const int64_t rhs) {
442  return asc_comparator(rhs, lhs);
443  };
444  }
445  comparators.push_back(comparator);
446  }
447  const auto col_tuple_comparator = [&comparators](const int64_t lhs,
448  const int64_t rhs) {
449  for (const auto& comparator : comparators) {
450  if (comparator(lhs, rhs)) {
451  return true;
452  }
453  }
454  return false;
455  };
456  std::sort(output_for_partition_buff,
457  output_for_partition_buff + partition_size,
458  col_tuple_comparator);
459  computePartition(output_for_partition_buff,
460  partition_size,
461  off,
462  window_func_,
463  col_tuple_comparator);
466  off += partition_size;
467  }
468  }
471  CHECK_EQ(static_cast<size_t>(off), elem_count_);
472  }
473  auto output_i64 = reinterpret_cast<int64_t*>(output_);
475  std::copy(scratchpad.get(), scratchpad.get() + elem_count_, output_i64);
476  } else {
477  for (size_t i = 0; i < elem_count_; ++i) {
478  output_i64[payload()[i]] = scratchpad[i];
479  }
480  }
481 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1447
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
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
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
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:197
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 645 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, SUM, toString(), and window_function_requires_peer_handling().

Referenced by compute().

650  {
651  switch (window_func->getKind()) {
653  const auto row_numbers =
654  index_to_row_number(output_for_partition_buff, partition_size);
655  std::copy(row_numbers.begin(), row_numbers.end(), output_for_partition_buff);
656  break;
657  }
659  const auto rank =
660  index_to_rank(output_for_partition_buff, partition_size, comparator);
661  std::copy(rank.begin(), rank.end(), output_for_partition_buff);
662  break;
663  }
665  const auto dense_rank =
666  index_to_dense_rank(output_for_partition_buff, partition_size, comparator);
667  std::copy(dense_rank.begin(), dense_rank.end(), output_for_partition_buff);
668  break;
669  }
671  const auto percent_rank =
672  index_to_percent_rank(output_for_partition_buff, partition_size, comparator);
673  std::copy(percent_rank.begin(),
674  percent_rank.end(),
675  reinterpret_cast<double*>(may_alias_ptr(output_for_partition_buff)));
676  break;
677  }
679  const auto cume_dist =
680  index_to_cume_dist(output_for_partition_buff, partition_size, comparator);
681  std::copy(cume_dist.begin(),
682  cume_dist.end(),
683  reinterpret_cast<double*>(may_alias_ptr(output_for_partition_buff)));
684  break;
685  }
687  const auto& args = window_func->getArgs();
688  CHECK_EQ(args.size(), size_t(1));
689  const auto n = get_int_constant_from_expr(args.front().get());
690  const auto ntile = index_to_ntile(output_for_partition_buff, partition_size, n);
691  std::copy(ntile.begin(), ntile.end(), output_for_partition_buff);
692  break;
693  }
696  const auto lag_or_lead = get_lag_or_lead_argument(window_func);
697  const auto partition_row_offsets = payload() + off;
699  lag_or_lead, partition_row_offsets, output_for_partition_buff, partition_size);
700  break;
701  }
703  const auto partition_row_offsets = payload() + off;
705  partition_row_offsets, output_for_partition_buff, partition_size);
706  break;
707  }
709  const auto partition_row_offsets = payload() + off;
711  partition_row_offsets, output_for_partition_buff, partition_size);
712  break;
713  }
719  const auto partition_row_offsets = payload() + off;
720  if (window_function_requires_peer_handling(window_func)) {
722  partitionEnd(), off, output_for_partition_buff, partition_size, comparator);
723  }
725  output_for_partition_buff, partition_row_offsets, partition_size);
726  break;
727  }
728  default: {
729  throw std::runtime_error("Window function not supported yet: " +
730  ::toString(window_func->getKind()));
731  }
732  }
733 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
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
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 788 of file WindowContext.cpp.

References device_type_, and partitions_.

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

788  {
789  return reinterpret_cast<const int32_t*>(
790  partitions_->getJoinHashBuffer(device_type_, 0) + partitions_->countBufferOff());
791 }
std::shared_ptr< JoinHashTableInterface > partitions_
const ExecutorDeviceType device_type_

+ Here is the caller graph for this function:

size_t WindowFunctionContext::elementCount ( ) const

Definition at line 514 of file WindowContext.cpp.

References elem_count_.

514  {
515  return elem_count_;
516 }
void WindowFunctionContext::fillPartitionEnd ( )
private

Definition at line 754 of file WindowContext.cpp.

References agg_count_distinct_bitmap(), Bitmap, checked_calloc(), counts(), CPU, elem_count_, partition_end_, and partitionCount().

Referenced by compute().

754  {
756  0,
757  static_cast<int64_t>(elem_count_),
758  false,
760  1};
761  partition_end_ = static_cast<int8_t*>(
762  checked_calloc(partition_start_bitmap.bitmapPaddedSizeBytes(), 1));
763  int64_t partition_count = partitionCount();
764  std::vector<size_t> partition_offsets(partition_count);
765  std::partial_sum(counts(), counts() + partition_count, partition_offsets.begin());
766  auto partition_end_handle = reinterpret_cast<int64_t>(partition_end_);
767  for (int64_t i = 0; i < partition_count - 1; ++i) {
768  if (partition_offsets[i] == 0) {
769  continue;
770  }
771  agg_count_distinct_bitmap(&partition_end_handle, partition_offsets[i] - 1, 0);
772  }
773  if (elem_count_) {
774  agg_count_distinct_bitmap(&partition_end_handle, elem_count_ - 1, 0);
775  }
776 }
const int32_t * counts() const
size_t partitionCount() const
void * checked_calloc(const size_t nmemb, const size_t size)
Definition: checked_alloc.h:52
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 735 of file WindowContext.cpp.

References agg_count_distinct_bitmap(), Bitmap, checked_calloc(), counts(), CPU, elem_count_, partition_start_, and partitionCount().

Referenced by compute().

735  {
737  0,
738  static_cast<int64_t>(elem_count_),
739  false,
741  1};
742  partition_start_ = static_cast<int8_t*>(
743  checked_calloc(partition_start_bitmap.bitmapPaddedSizeBytes(), 1));
744  int64_t partition_count = partitionCount();
745  std::vector<size_t> partition_offsets(partition_count);
746  std::partial_sum(counts(), counts() + partition_count, partition_offsets.begin());
747  auto partition_start_handle = reinterpret_cast<int64_t>(partition_start_);
748  agg_count_distinct_bitmap(&partition_start_handle, 0, 0);
749  for (int64_t i = 0; i < partition_count - 1; ++i) {
750  agg_count_distinct_bitmap(&partition_start_handle, partition_offsets[i], 0);
751  }
752 }
const int32_t * counts() const
size_t partitionCount() const
void * checked_calloc(const size_t nmemb, const size_t size)
Definition: checked_alloc.h:52
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:

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

Definition at line 522 of file WindowContext.cpp.

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

522  {
524 }
AggregateState aggregate_state_
const Analyzer::WindowFunction * WindowFunctionContext::getWindowFunction ( ) const

Definition at line 483 of file WindowContext.cpp.

References window_func_.

Referenced by Executor::codegenWindowFunction().

483  {
484  return window_func_;
485 }
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 581 of file WindowContext.cpp.

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

Referenced by compute().

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

References device_type_, and partitions_.

Referenced by compute(), and partitionCount().

783  {
784  return reinterpret_cast<const int32_t*>(
785  partitions_->getJoinHashBuffer(device_type_, 0) + partitions_->offsetBufferOff());
786 }
std::shared_ptr< JoinHashTableInterface > 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 487 of file WindowContext.cpp.

References output_.

Referenced by CodeGenerator::codegenWindowPosition().

487  {
488  return output_;
489 }

+ Here is the caller graph for this function:

size_t WindowFunctionContext::partitionCount ( ) const
private

Definition at line 793 of file WindowContext.cpp.

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

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

793  {
794  const auto partition_count = counts() - offsets();
795  CHECK_GE(partition_count, 0);
796  return partition_count;
797 }
#define CHECK_GE(x, y)
Definition: Logger.h:210
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 510 of file WindowContext.cpp.

References partition_end_.

Referenced by computePartition().

510  {
511  return partition_end_;
512 }

+ Here is the caller graph for this function:

const int8_t * WindowFunctionContext::partitionStart ( ) const

Definition at line 506 of file WindowContext.cpp.

References partition_start_.

506  {
507  return partition_start_;
508 }
const int32_t * WindowFunctionContext::payload ( ) const
private

Definition at line 778 of file WindowContext.cpp.

References device_type_, and partitions_.

Referenced by compute(), and computePartition().

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

+ Here is the caller graph for this function:

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

Definition at line 518 of file WindowContext.cpp.

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

Referenced by CodeGenerator::codegenWindowPosition().

518  {
519  aggregate_state_.row_number = row_number;
520 }
AggregateState aggregate_state_

+ 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 172 of file WindowContext.h.

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

size_t WindowFunctionContext::elem_count_
private

Definition at line 161 of file WindowContext.h.

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

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

Definition at line 157 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 155 of file WindowContext.h.

Referenced by addOrderColumn().

int8_t* WindowFunctionContext::output_
private

Definition at line 163 of file WindowContext.h.

Referenced by compute(), and output().

int8_t* WindowFunctionContext::partition_end_
private

Definition at line 169 of file WindowContext.h.

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

int8_t* WindowFunctionContext::partition_start_
private

Definition at line 166 of file WindowContext.h.

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

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

Definition at line 159 of file WindowContext.h.

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

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

Definition at line 173 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: