16 #ifndef IMPALA_UTIL_TUPLE_ROW_COMPARE_H_
17 #define IMPALA_UTIL_TUPLE_ROW_COMPARE_H_
35 const std::vector<ExprContext*>& key_expr_ctxs_lhs,
36 const std::vector<ExprContext*>& key_expr_ctxs_rhs,
37 const std::vector<bool>& is_asc,
38 const std::vector<bool>& nulls_first)
42 DCHECK_EQ(key_expr_ctxs_lhs.size(), key_expr_ctxs_rhs.size());
43 DCHECK_EQ(key_expr_ctxs_lhs.size(), is_asc.size());
44 DCHECK_EQ(key_expr_ctxs_lhs.size(), nulls_first.size());
46 for (
int i = 0; i < key_expr_ctxs_lhs.size(); ++i) {
52 const std::vector<ExprContext*>& key_expr_ctxs_lhs,
53 const std::vector<ExprContext*>& key_expr_ctxs_rhs,
54 bool is_asc,
bool nulls_first)
57 is_asc_(key_expr_ctxs_lhs.size(), is_asc),
58 nulls_first_(key_expr_ctxs_lhs.size(), nulls_first ? -1 : 1) {
59 DCHECK_EQ(key_expr_ctxs_lhs.size(), key_expr_ctxs_rhs.size());
71 if (lhs_value == NULL && rhs_value == NULL)
continue;
72 if (lhs_value == NULL && rhs_value != NULL)
return nulls_first_[i];
73 if (lhs_value != NULL && rhs_value == NULL)
return -
nulls_first_[i];
77 if (!
is_asc_[i]) result = -result;
78 if (result != 0)
return result;
89 if (result < 0)
return true;
96 return (*
this)(lhs_row, rhs_row);
115 for (
int i = 0; i < slots.size(); ++i) {
146 for (
int i = 0; i < tuple_descs.size(); ++i) {
bool operator()(TupleRow *x, TupleRow *y)
Tuple * GetTuple(int tuple_idx)
static bool Eq(const void *v1, const void *v2, const ColumnType &type)
Compares the equality of two Tuples, going slot by slot.
TupleDescriptor * tuple_desc_
A tuple with 0 materialised slots is represented as NULL.
TupleEqualityChecker(TupleDescriptor *tuple_desc)
Compares the equality of two TupleRows, going tuple by tuple.
void * GetSlot(int offset)
const std::vector< SlotDescriptor * > & slots() const
const NullIndicatorOffset & null_indicator_offset() const
std::vector< TupleEqualityChecker > tuple_checkers_
bool IsNull(const NullIndicatorOffset &offset) const
TupleRowComparator(const std::vector< ExprContext * > &key_expr_ctxs_lhs, const std::vector< ExprContext * > &key_expr_ctxs_rhs, bool is_asc, bool nulls_first)
const ColumnType & type() const
TupleRowComparator(const std::vector< ExprContext * > &key_expr_ctxs_lhs, const std::vector< ExprContext * > &key_expr_ctxs_rhs, const std::vector< bool > &is_asc, const std::vector< bool > &nulls_first)
bool operator()(TupleRow *lhs, TupleRow *rhs) const
const RowDescriptor & row_desc() const
const std::vector< TupleDescriptor * > & tuple_descriptors() const
Return descriptors for all tuples in this row, in order of appearance.
std::vector< bool > is_asc_
std::vector< ExprContext * > key_expr_ctxs_rhs_
bool operator()(Tuple *x, Tuple *y)
static int Compare(const void *v1, const void *v2, const ColumnType &type)
std::vector< ExprContext * > key_expr_ctxs_lhs_
std::vector< int8_t > nulls_first_
RowEqualityChecker(const RowDescriptor &row_desc)
int Compare(TupleRow *lhs, TupleRow *rhs) const