Closed PSeitz closed 1 year ago
It looks good!
We can forget about docset_with_value
initially.
into_full
should probably be named differently if it does not consume self.
Weird question: do you think there is a world where we can have one trait and use GAT to deal with Optional / Required / Multi cardinality?
I did some tests with GAT, but did run quickly into issues, because they are not object safe currently.
pub trait GATColumn: Send + Sync {
type T: PartialOrd;
type Item<T>;
fn get_val(&self, idx: u64) -> Self::Item<Self::T>;
fn into_full(
&self,
idx: u64,
) -> Arc<dyn GATColumn<Value = Self::T, Item<Self::T> = Self::T>>;
}
error[E0038]: the trait `GATColumn` cannot be made into an object
--> src/lib.rs:10:14
|
10 | ) -> Arc<dyn GATColumn<Value = Self::Value, Item<Self::Value> = Self::Value>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `GATColumn` cannot be made into an object
haha. I tried to too. It is not GAT, but
trait Column<T> {
type ItemContainer = Into<Option<T>>;
fn get(&self, idx: u64) -> Self::ItemContainer;
}
You then manipulate `Arc<dyn Column
The benefit is that you can use the same code for both containers and get monomorphization.
(hopefully the code for ItemContainer = T
will be as fast as if you did not play with Options.)
You still have to do some juggling/manual dispatch to build the collector though, and manipulate it.
trait Column<T> {
type ItemContainer = Into<Iterator<Item=T>>;
fn get(&self, idx: u64) -> Self::ItemContainer;
}
is even more tempting, as it might make it possible to work for Optional/Required/Multivalued altogether. Unfortunately, I don't know how to work with Multivalued stuff without passing a vec buffer.
OptionalColumn
should be the default, so all consumers would need to handleOption<T>
, or try to convert to full column