// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "numeric_sort_blob_writer.h" #include #include #include namespace search::attribute { template NumericSortBlobWriter::NumericSortBlobWriter() noexcept : _best() { } template NumericSortBlobWriter::~NumericSortBlobWriter() noexcept = default; template void NumericSortBlobWriter::candidate(T val) { if constexpr (std::disjunction_v,std::is_same>) { if (std::isnan(val)) { return; } } if (_best.has_value()) { if constexpr (asc) { if (_best.value() <= val) { return; } } else { if (_best.value() >= val) { return; } } } _best = val; } template long NumericSortBlobWriter::write(void *serTo, size_t available) { auto dst = static_cast(serTo); if (_best.has_value()) { if (available < 1 + sizeof(T)) { return -1; } *dst = has_value; auto ret = vespalib::serializeForSort>(_best.value(), dst + 1, available - 1); return (ret >= 0) ? (ret + 1) : -1; } else { if (available < 1) { return -1; } *dst = missing_value; return 1; } } template class NumericSortBlobWriter; template class NumericSortBlobWriter; template class NumericSortBlobWriter; template class NumericSortBlobWriter; template class NumericSortBlobWriter; template class NumericSortBlobWriter; template class NumericSortBlobWriter; template class NumericSortBlobWriter; template class NumericSortBlobWriter; template class NumericSortBlobWriter; template class NumericSortBlobWriter; template class NumericSortBlobWriter; }