Explain why floats are different with respect to indexing
This commit is contained in:
parent
8cc5b92808
commit
df108f581c
1 changed files with 14 additions and 2 deletions
|
|
@ -15,8 +15,20 @@ pub type Uuid = u64;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum Value {
|
pub enum Value {
|
||||||
Number(f64), // TODO: Can't put floats as keys in maps, since they don't implement Eq. What to
|
// Note that it doesn't really make sense to compare floats on equality without specifying
|
||||||
// do?
|
// precision. You can ofcourse convert a float to string or to a bytevector and then compare
|
||||||
|
// equality of those, but that's not the right equality. And ofcourse Rust designers are aware
|
||||||
|
// of this, so floats don't implement the Eq trait.
|
||||||
|
// This ofcourse complicates indexing of Number columns.
|
||||||
|
//
|
||||||
|
// Either we'd have to design a specific key-value map data-structure where keys are floats,
|
||||||
|
// s.t. to index with a given float K you also specify a tolerance error so that the resulting
|
||||||
|
// value set will contain all values whose keys are close to K within that tolerence. This
|
||||||
|
// seems highly non-trivial.
|
||||||
|
//
|
||||||
|
// So we choose to make a distinction between indexable and non-indexable types, and Number is
|
||||||
|
// not indexable.
|
||||||
|
Number(f64),
|
||||||
Indexable(IndexableValue),
|
Indexable(IndexableValue),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue