You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's very easy to do the serializer, but harder to do the deserializer because it's unclear how to represent type tags properly. I'd suggest doing the serializer first and leaving the deserializer for later.
I remember talking with @mlucy about this a while ago and the way that we
both really wanted to see this work is that registered types would
serialized to an object that looked something like:
{reql_type : "pickle", data: ...}
This has some nice properties
it's incredibly easy, it takes 0 server side support and is as simple as
looking up deserialization functions in a map in the drivers.
it's very easy to do the deserialization and I really think this feature
is awfully half baked if you can't get out what you put in.
it degrades somewhat gracefully in drivers that don't support the type.
Pickling is such a python specific thing I doubt that one will ever truly
be usable but for a date type it works great in a language that doesn't
have a native date type. (Which may not exist but somewhere is a good
example)
this paves the way for the server understanding these types where it's
useful. One great place would be with a date type and this we could
overload subtraction on it so we don't need a special datedifference
function.
typeof can give a meaningful result when called on such a value.
It's very easy to do the serializer, but harder to do the deserializer
because it's unclear how to represent type tags properly. I'd suggest doing
the serializer first and leaving the deserializer for later.
I agree with @jdoliner, the depickling and pickling should occur at the same time, otherwise it's a bit crippled. Inserting a dictionary that has type information and the pickled data together is a technique that has worked well for me in the past, in similar situations. +1
I like this idea as well. We should bikeshed for a bit about the magic keyword once this is moved into a milestone, though -- I would prefer __type__ to __rql_type__.
I went with reql_type over type mostly because it seemed like a
.001% chance of collision instead of a .1% chance of collision. Also in the
case that someone does get the raw dict version of the object back there's
a chance they could not know that type is a reql thing rather than
something another developer added. Especially considering we have an
example in this thread of a user who's done something similar himself.
On Jun 16, 2013 4:53 PM, "Michael Lucy" [email protected] wrote:
I like this idea as well. We should bikeshed for a bit about the magic
keyword once this is moved into a milestone, though -- I would prefer type to reql_type.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1016#issuecomment-19518912
.
We have talked a lot about Dates, nested updates, triggers but not custom types for 1.8
It came up twice this morning (for integers and number with bigger precision).
Moving the issue into 1.8 just to make sure we don't forget it.
@neumino I'd really prefer if you left scheduling issues to @coffeemug it's not that I want to impose a hierarchy with this process but I think scheduling things really works a lot better if one person coordinates it. Right now when an issue is in a release milestone I take this to mean 1.8 isn't shipping without this. Which just isn't the case here.
On top of this I think your reasoning for moving this is completely wrong. Adding integers, numbers with bigger precision and dates is a great feature but we certainly don't want those to be types that users have to register for themselves. We'd want those to be builtin types. They'd probably wind up using the reql_type field method but we can easily do that without giving users the ability to register their own types. Registering your own types is both a fairly big api discussion and some non trivial backend work which means I think it's higher cost and lower benefit than everything else we want to do in 1.8.
@jdoliner no problem.
It wasn't an attempt to schedule anything, I was just worried that with the release coming next week, we would somehow forget to take a look at this one.
No worries. If it was indeed the case that this wasn't considered I think there's a decent argument for not scheduling it. But @coffeemug knows better if he did indeed consider this.
My plan was to get together with everyone next week after 1.7 is out and discuss 1.8, but roughly I think the most important things for 1.8 (wrt ReQL) are as follows:
.group.map.reduce
dates
nested objects (extending pluck syntax to other commands, and implementing r.literal)
After these three are done, everything else in ReQL strikes me as a "nice to have" category (in as much as ReQL functionality post these changes will be sufficient to satisfy a huge number of users and will cease to be a bottleneck for product adoption, possibly with triggers and very minor ReQL improvements being notable exceptions). So we can move on to performance and scalability after 1.8 is out.
It seems to me that extending ReQL with more types, and supporting a custom registerType functionality on the drivers are a) mostly orthogonal, and b) not a bottleneck relative to performance/scale issues. One possibility is that we might want to support client-side date types, and can implement it on top of registerType functionality. Since it's entirely a driver-side thing, I wouldn't be opposed to doing it in 1.8 if we have the time.
Also FYI: the 1.8 milestone contains way more than we need for 1.8 as of now. I'll pare it down soon.
I think the correct way to do this would be to have each driver implement a ReQLType abstract class (or equivalent concept) from which the user may subclass to create a new type. Instances of this class could then be passed to and stored in rethinkdb (using any mechanism we want) and retrieving values of the custom type would result in new instances of the class. The details of serialization and deserialization could be hidden from the user rendering arguments like #1149 unnecessary as this would be purely an implementation detail internal to the server.
Most of the hard work would be done within the parent class in the driver but the user would be able to provide fine grained guidance by choosing to overload comparison methods etc.
I think that functionality like this would feel much more like magic than r.register_type and thus get us a little bit closer to closing #1000.
I think the correct way to do this would be to have each driver implement a ReQLType abstract class (or equivalent concept) from which the user may subclass to create a new type.
There are a couple of downsides to this approach:
It wouldn't work well with existing types users might want to store (for example, NumPy types) because they'd have to create wrapper objects which would get rather messy.
It would be very difficult for the abstract type to magically serialize the derived type correctly. For example, many types have transient fields that don't need to be serialized, and the driver wouldn't know that. Supporting this kind of stuff would get really complicated because we'd have to build a declarative serialization framework in each driver, which is hard.
Overall, I think register_type would be much easier to use, and would work for more use cases.
Actually, what I have in mind is mostly an enhancement on top of r.register_type to make it more useful in the common case. Here's how I imagine it might would work:
fromtimeimporttimeclassMyTime(r.CustomType):
def__init__(self, utc_time):
self.utc_time=utc_time@staticmethoddefnow():
returnMyTime(time.now())
# Serialization is handled by the parent class so the user# doesn't have to even think about it.# For more complex cases than this though these methods# can be overloaded.# With just `r.register_type` this is mandatory, not an optiondefserialize(self):
returnjson.dumps(self)
defparse(self, serialized)
self.update(json.parse(serialized))
# We could use the same trick that we do with lambda# functions to serialize a user provided comparison# function. I'm not totally sold on this though.defless_than(self, other):
self.utc_time<other.utc_time# For existing types we basically default to the register type proposalr.CusumType.register(crazy_type,
serialize=lambdaself: ...,
parse=lambdaself: ...,
less_than=lambdaself, other: ...
)
# Again, the serialize and deserialize methods are optional, defaulting# to json serialization of all fields. The inherited method throws on# non serializable fields.r.CustomType.register(complex)
@alexbw -- with dates out, RethinkDB now has a notion of pseudotypes (i.e. types that aren't specified by json, dates being an example). That should make this enhancement easier, but there are still some questions we need to answer about how to structured user-defined types (what's allowed, what's not allowed, how it integrates with the rest of the system, etc.)
Our main priority now is to get Rethink to production-readiness, which means mainly performance, stability, and scalability fixes. I think we won't be able to get to this enhancement until 2.0 is out, but we'll almost certainly do it almost immediately after that.
@alexbwhttps://github.com/alexbw -- with dates out, RethinkDB now has
a notion of pseudotypes (i.e. types that aren't specified by json, dates
being an example). That should make this enhancement easier, but there are
still some questions we need to answer about how to structured user-defined
types (what's allowed, what's not allowed, how it integrates with the rest
of the system, etc.)
Our main priority now is to get Rethink to production-readiness, which
means mainly performance, stability, and scalability fixes. I think we
won't be able to get to this enhancement until 2.0 is out, but we'll almost
certainly do it almost immediately after that.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1016#issuecomment-22854688
.
Activity
jdoliner commentedon Jun 15, 2013
I remember talking with @mlucy about this a while ago and the way that we
both really wanted to see this work is that registered types would
serialized to an object that looked something like:
{reql_type : "pickle", data: ...}
This has some nice properties
looking up deserialization functions in a map in the drivers.
is awfully half baked if you can't get out what you put in.
Pickling is such a python specific thing I doubt that one will ever truly
be usable but for a date type it works great in a language that doesn't
have a native date type. (Which may not exist but somewhere is a good
example)
useful. One great place would be with a date type and this we could
overload subtraction on it so we don't need a special datedifference
function.
On Friday, June 14, 2013, coffeemug wrote:
alexbw commentedon Jun 16, 2013
I agree with @jdoliner, the depickling and pickling should occur at the same time, otherwise it's a bit crippled. Inserting a dictionary that has type information and the pickled data together is a technique that has worked well for me in the past, in similar situations. +1
mlucy commentedon Jun 16, 2013
I like this idea as well. We should bikeshed for a bit about the magic keyword once this is moved into a milestone, though -- I would prefer
__type__to__rql_type__.jdoliner commentedon Jun 17, 2013
I went with reql_type over type mostly because it seemed like a
.001% chance of collision instead of a .1% chance of collision. Also in the
case that someone does get the raw dict version of the object back there's
a chance they could not know that type is a reql thing rather than
something another developer added. Especially considering we have an
example in this thread of a user who's done something similar himself.
On Jun 16, 2013 4:53 PM, "Michael Lucy" [email protected] wrote:
coffeemug commentedon Jun 17, 2013
Ok, I'm moving to backlog for now, but we'll try to get this into 1.8.
neumino commentedon Jun 30, 2013
We have talked a lot about Dates, nested updates, triggers but not custom types for 1.8
It came up twice this morning (for integers and number with bigger precision).
Moving the issue into 1.8 just to make sure we don't forget it.
jdoliner commentedon Jun 30, 2013
@neumino I'd really prefer if you left scheduling issues to @coffeemug it's not that I want to impose a hierarchy with this process but I think scheduling things really works a lot better if one person coordinates it. Right now when an issue is in a release milestone I take this to mean 1.8 isn't shipping without this. Which just isn't the case here.
On top of this I think your reasoning for moving this is completely wrong. Adding integers, numbers with bigger precision and dates is a great feature but we certainly don't want those to be types that users have to register for themselves. We'd want those to be builtin types. They'd probably wind up using the reql_type field method but we can easily do that without giving users the ability to register their own types. Registering your own types is both a fairly big api discussion and some non trivial backend work which means I think it's higher cost and lower benefit than everything else we want to do in 1.8.
neumino commentedon Jun 30, 2013
@jdoliner no problem.
It wasn't an attempt to schedule anything, I was just worried that with the release coming next week, we would somehow forget to take a look at this one.
jdoliner commentedon Jun 30, 2013
No worries. If it was indeed the case that this wasn't considered I think there's a decent argument for not scheduling it. But @coffeemug knows better if he did indeed consider this.
coffeemug commentedon Jun 30, 2013
My plan was to get together with everyone next week after 1.7 is out and discuss 1.8, but roughly I think the most important things for 1.8 (wrt ReQL) are as follows:
.group.map.reduceplucksyntax to other commands, and implementingr.literal)After these three are done, everything else in ReQL strikes me as a "nice to have" category (in as much as ReQL functionality post these changes will be sufficient to satisfy a huge number of users and will cease to be a bottleneck for product adoption, possibly with triggers and very minor ReQL improvements being notable exceptions). So we can move on to performance and scalability after 1.8 is out.
It seems to me that extending ReQL with more types, and supporting a custom
registerTypefunctionality on the drivers are a) mostly orthogonal, and b) not a bottleneck relative to performance/scale issues. One possibility is that we might want to support client-side date types, and can implement it on top ofregisterTypefunctionality. Since it's entirely a driver-side thing, I wouldn't be opposed to doing it in 1.8 if we have the time.Also FYI: the 1.8 milestone contains way more than we need for 1.8 as of now. I'll pare it down soon.
srh commentedon Jul 10, 2013
The time and maybe duration type will have a custom comparison operation that does not map to object comparison.
#977 (comment)
We need a general rule for how objects with different reql_type and no reql_type fields should be ordered.
wmrowan commentedon Jul 11, 2013
I think the correct way to do this would be to have each driver implement a ReQLType abstract class (or equivalent concept) from which the user may subclass to create a new type. Instances of this class could then be passed to and stored in rethinkdb (using any mechanism we want) and retrieving values of the custom type would result in new instances of the class. The details of serialization and deserialization could be hidden from the user rendering arguments like #1149 unnecessary as this would be purely an implementation detail internal to the server.
Most of the hard work would be done within the parent class in the driver but the user would be able to provide fine grained guidance by choosing to overload comparison methods etc.
I think that functionality like this would feel much more like magic than
r.register_typeand thus get us a little bit closer to closing #1000.coffeemug commentedon Jul 11, 2013
There are a couple of downsides to this approach:
Overall, I think
register_typewould be much easier to use, and would work for more use cases.wmrowan commentedon Jul 11, 2013
Actually, what I have in mind is mostly an enhancement on top of
r.register_typeto make it more useful in the common case. Here's how I imagine it might would work:alexbw commentedon Aug 15, 2013
With 1.8 out, and supporting dates, is there any chance this enhancement will get some love?
coffeemug commentedon Aug 19, 2013
@alexbw -- with dates out, RethinkDB now has a notion of pseudotypes (i.e. types that aren't specified by json, dates being an example). That should make this enhancement easier, but there are still some questions we need to answer about how to structured user-defined types (what's allowed, what's not allowed, how it integrates with the rest of the system, etc.)
Our main priority now is to get Rethink to production-readiness, which means mainly performance, stability, and scalability fixes. I think we won't be able to get to this enhancement until 2.0 is out, but we'll almost certainly do it almost immediately after that.
alexbw commentedon Aug 19, 2013
Good to know, thanks.
On Mon, Aug 19, 2013 at 3:23 AM, coffeemug [email protected] wrote: