6 #ifndef TURI_QUERY_EVAL_SORT_COMPARATOR_HPP 7 #define TURI_QUERY_EVAL_SORT_COMPARATOR_HPP 9 #include <core/data/flexible_type/flexible_type.hpp> 13 namespace query_eval {
31 m_sort_orders(sort_orders) {}
40 return compare(v1_v, v2_v);
44 inline bool operator() (
const std::vector<flexible_type>& v1,
const std::vector<flexible_type>& v2)
const {
45 return compare(v1, v2);
48 inline bool operator() (
const std::pair<std::vector<flexible_type>, std::string>& v1,
49 const std::pair<std::vector<flexible_type>, std::string>& v2)
const {
50 return compare(v1.first, v2.first);
53 inline bool compare(
const std::vector<flexible_type>& v1,
const std::vector<flexible_type>& v2)
const {
57 for(
size_t i = 0; i < m_sort_orders.size(); i++) {
58 bool ascending = m_sort_orders[i];
72 if (v1[i] < v2[i])
return ascending;
73 if (v1[i] > v2[i])
return !ascending;
78 std::vector<bool> m_sort_orders;
92 const std::vector<bool>& sort_orders)
93 : m_sort_columns(sort_columns), m_sort_orders(sort_orders)
98 inline bool operator() (
const std::vector<flexible_type>& v1,
const std::vector<flexible_type>& v2)
103 for(
auto column_idx: m_sort_columns) {
105 bool ascending = m_sort_orders[i++];
116 if (v1[column_idx] < v2[column_idx])
return ascending;
117 if (v1[column_idx] > v2[column_idx])
return !ascending;
122 std::vector<size_t> m_sort_columns;
123 std::vector<bool> m_sort_orders;
flex_type_enum get_type() const
static flexible_type FLEX_UNDEFINED
std::vector< flexible_type > flex_list
#define DASSERT_TRUE(cond)