文章来由
正如题目所言,最近笔者在尝试解决Doris的bitmap函数相关的一些issue,如bitmap_max函数、bitmap_andnot函数的实现。
一些值得关注的高光源码
//bitmap_value.h的Roaring64Map类的maximum()函数和minimum()函数
/**
* Return the largest value (if not empty)
*
*/
uint64_t maximum() const {
for (auto roaring_iter = roarings.crbegin(); roaring_iter != roarings.crend();
++roaring_iter) {
if (!roaring_iter->second.isEmpty()) {
return uniteBytes(roaring_iter->first, roaring_iter->second.maximum());
}
}
// we put std::numeric_limits<>::max/min in parenthesis
// to avoid a clash with the Windows.h header under Windows
return (std::numeric_limits<uint64_t>::min)();
}
/**
* Return the smallest value (if not empty)
*
*/
uint64_t minimum() const {
for (auto roaring_iter = roarings.cbegin(); roaring_iter != roarings.cend();
++roaring_iter) {
if (!roaring_iter->second.isEmpty()) {
return uniteBytes(roaring_iter->first, roaring_iter->second.minimum());
}
}
// we put std::numeric_limits<>::max/min in parenthesis
// to avoid a clash with the Windows.h header under Windows
return (std::numeric_limits<uint64_t>::max)();
}
可以看到maximum函数和minimum函数的末尾为了 avoid a clash with the Windows.h header under Windows,选择了返回(std::numeric_limits<uint64_t>::min)()和(std::numeric_limits<uint64_t>::max)(),这么做的进一步解释:
网友评论