Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite
Dimension::overlap_ratio
to remove overflow, underflow, and…
… divide by zero (#2304) (#2349) * Add tests for overflow defects in overlap_ratio. Minor (non-fix) changes to overlap_ratio. Most importantly, add an assert() to verify the postcondition. Add helpers-dimension.h with some utility functions. Fix an iteration error in a caller of overlap_ratio. Fix typos. * Rewrote Dimension::overlap_ratio to pass all the tests it was failing before. Added some test tags. Reverted a change in subarray.cc * clang format * More clang-format * Use the limits function that returns the actual minimum element for floating point, not the minimum-positive element. * Fix Hilbert test now that size estimate is correct Now that the overlap ratio is correct, we get proper size estimation and the partitioner doesn't do an unnecessary split of the results anymore. * Comment changes. clang-format Co-authored-by: Luc Rancourt <lucrancourt@gmail.com> Co-authored-by: eric-hughes-tiledb <82400964+eric-hughes-tiledb@users.noreply.github.com> Co-authored-by: Luc Rancourt <lucrancourt@gmail.com>
- Loading branch information
1 parent
0b00402
commit 4a0d431
Showing
6 changed files
with
286 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/** | ||
* @file helpers-dimension.h | ||
* | ||
* @section LICENSE | ||
* | ||
* The MIT License | ||
* | ||
* @copyright Copyright (c) 2017-2021 TileDB, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
* @section DESCRIPTION | ||
* | ||
* Helpers for tests involving dimensions. | ||
*/ | ||
|
||
#include "tiledb/sm/enums/datatype.h" | ||
#include "tiledb/sm/misc/types.h" | ||
|
||
#ifndef TILEDB_HELPERS_DIMENSION_H | ||
#define TILEDB_HELPERS_DIMENSION_H | ||
|
||
namespace tiledb { | ||
namespace test { | ||
|
||
/** | ||
* A typed version of the standard range class. Constructs Range objects without | ||
* requiring the caller to know anything about its data structures. | ||
* | ||
* @tparam T | ||
*/ | ||
template <class T> | ||
class TypedRange : public tiledb::sm::Range { | ||
public: | ||
/** | ||
* Construct a Range from a single interval. | ||
* @param low Lower bound of interval | ||
* @param high Upper bound of interval | ||
* @pre low <= high | ||
*/ | ||
TypedRange(T low, T high) { | ||
T x[2] = {low, high}; | ||
set_range(&x[0], 2 * sizeof(T)); | ||
/* Commentary: There's no way of initializing a Range without copying from | ||
* existing memory. As a result any value-initializing constructor first | ||
* needs to build an array and then copy it. | ||
*/ | ||
} | ||
}; | ||
|
||
using Datatype = tiledb::sm::Datatype; | ||
|
||
template <class T> | ||
struct RangeTraits { | ||
static Datatype datatype; | ||
}; | ||
|
||
template <> | ||
struct RangeTraits<int32_t> { | ||
static constexpr Datatype datatype = Datatype::INT32; | ||
}; | ||
|
||
template <> | ||
struct RangeTraits<int64_t> { | ||
static constexpr Datatype datatype = Datatype::INT64; | ||
}; | ||
|
||
template <> | ||
struct RangeTraits<uint32_t> { | ||
static constexpr Datatype datatype = Datatype::UINT32; | ||
}; | ||
|
||
template <> | ||
struct RangeTraits<uint64_t> { | ||
static constexpr Datatype datatype = Datatype::UINT64; | ||
}; | ||
|
||
template <> | ||
struct RangeTraits<float> { | ||
static constexpr Datatype datatype = Datatype::FLOAT32; | ||
}; | ||
|
||
template <> | ||
struct RangeTraits<double> { | ||
static constexpr Datatype datatype = Datatype::FLOAT64; | ||
}; | ||
|
||
} // namespace test | ||
} // namespace tiledb | ||
|
||
#endif // TILEDB_HELPERS_DIMENSION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.