You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Jonathan Ellis <jb...@gmail.com> on 2009/06/13 06:38:21 UTC
specializing / polymorphic types?
I'd like to define a struct filter_t such that i can define methods
get(string key, filter_t filter) and scan(string start_key, string
end_key, filter_t filter) and then specialize filter_t as
column_filter_t, time_filter_t, etc.
Right now we have a dozen get_ methods, which is bad enough as it is
but now we are facing a copy/paste to make scan versions of each.
Please tell me there is a better way.
-Jonathan
Re: specializing / polymorphic types?
Posted by Bryan Duxbury <br...@rapleaf.com>.
It's still on my mind. I just haven't had the time to get a working
implementation out. The compiler changes are basically optional,
beyond the base stuff - a union will look just like a struct in every
way, except if you generate a different class for it. The patch on
the issue already incorporates this functionality.
We could split up the task into sub-issues by language if you think
that will keep us from stomping on each other.
-Bryan
On Jun 17, 2009, at 3:24 PM, Mark Slee wrote:
> Not sure, tbh. You might want to ping Brian directly on it. It has
> come up multiple times, there's definitely been enough demand for
> the feature to warrant its inclusion.
>
> If you're interested in working on the implementation, I'd just
> check that someone else doesn't have a partially ready patch
> waiting somewhere.
>
> -----Original Message-----
> From: Jonathan Ellis [mailto:jbellis@gmail.com]
> Sent: Wednesday, June 17, 2009 3:13 PM
> To: thrift-user@incubator.apache.org
> Subject: Re: specializing / polymorphic types?
>
> Thanks, Mark.
>
> I see that the last update was in April. Is it dead?
>
> -Jonathan
>
> On Wed, Jun 17, 2009 at 4:57 PM, Mark Slee<ms...@facebook.com> wrote:
>> There has been talk of creating a union type in Thrift which would
>> probably most closely approximate what you want here. It's not
>> true polymorphism or type inheritance, and you'll probably still
>> end up with a switch()-block or equivalent somewhere, but it may
>> help.
>>
>> http://issues.apache.org/jira/browse/THRIFT-409
>>
>>
>> -----Original Message-----
>> From: Jonathan Ellis [mailto:jbellis@gmail.com]
>> Sent: Friday, June 12, 2009 9:38 PM
>> To: thrift-user@incubator.apache.org
>> Subject: specializing / polymorphic types?
>>
>> I'd like to define a struct filter_t such that i can define methods
>> get(string key, filter_t filter) and scan(string start_key, string
>> end_key, filter_t filter) and then specialize filter_t as
>> column_filter_t, time_filter_t, etc.
>>
>> Right now we have a dozen get_ methods, which is bad enough as it is
>> but now we are facing a copy/paste to make scan versions of each.
>> Please tell me there is a better way.
>>
>> -Jonathan
>>
RE: specializing / polymorphic types?
Posted by Mark Slee <ms...@facebook.com>.
Not sure, tbh. You might want to ping Brian directly on it. It has come up multiple times, there's definitely been enough demand for the feature to warrant its inclusion.
If you're interested in working on the implementation, I'd just check that someone else doesn't have a partially ready patch waiting somewhere.
-----Original Message-----
From: Jonathan Ellis [mailto:jbellis@gmail.com]
Sent: Wednesday, June 17, 2009 3:13 PM
To: thrift-user@incubator.apache.org
Subject: Re: specializing / polymorphic types?
Thanks, Mark.
I see that the last update was in April. Is it dead?
-Jonathan
On Wed, Jun 17, 2009 at 4:57 PM, Mark Slee<ms...@facebook.com> wrote:
> There has been talk of creating a union type in Thrift which would probably most closely approximate what you want here. It's not true polymorphism or type inheritance, and you'll probably still end up with a switch()-block or equivalent somewhere, but it may help.
>
> http://issues.apache.org/jira/browse/THRIFT-409
>
>
> -----Original Message-----
> From: Jonathan Ellis [mailto:jbellis@gmail.com]
> Sent: Friday, June 12, 2009 9:38 PM
> To: thrift-user@incubator.apache.org
> Subject: specializing / polymorphic types?
>
> I'd like to define a struct filter_t such that i can define methods
> get(string key, filter_t filter) and scan(string start_key, string
> end_key, filter_t filter) and then specialize filter_t as
> column_filter_t, time_filter_t, etc.
>
> Right now we have a dozen get_ methods, which is bad enough as it is
> but now we are facing a copy/paste to make scan versions of each.
> Please tell me there is a better way.
>
> -Jonathan
>
Re: specializing / polymorphic types?
Posted by Jonathan Ellis <jb...@gmail.com>.
Thanks, Mark.
I see that the last update was in April. Is it dead?
-Jonathan
On Wed, Jun 17, 2009 at 4:57 PM, Mark Slee<ms...@facebook.com> wrote:
> There has been talk of creating a union type in Thrift which would probably most closely approximate what you want here. It's not true polymorphism or type inheritance, and you'll probably still end up with a switch()-block or equivalent somewhere, but it may help.
>
> http://issues.apache.org/jira/browse/THRIFT-409
>
>
> -----Original Message-----
> From: Jonathan Ellis [mailto:jbellis@gmail.com]
> Sent: Friday, June 12, 2009 9:38 PM
> To: thrift-user@incubator.apache.org
> Subject: specializing / polymorphic types?
>
> I'd like to define a struct filter_t such that i can define methods
> get(string key, filter_t filter) and scan(string start_key, string
> end_key, filter_t filter) and then specialize filter_t as
> column_filter_t, time_filter_t, etc.
>
> Right now we have a dozen get_ methods, which is bad enough as it is
> but now we are facing a copy/paste to make scan versions of each.
> Please tell me there is a better way.
>
> -Jonathan
>
RE: specializing / polymorphic types?
Posted by Mark Slee <ms...@facebook.com>.
There has been talk of creating a union type in Thrift which would probably most closely approximate what you want here. It's not true polymorphism or type inheritance, and you'll probably still end up with a switch()-block or equivalent somewhere, but it may help.
http://issues.apache.org/jira/browse/THRIFT-409
-----Original Message-----
From: Jonathan Ellis [mailto:jbellis@gmail.com]
Sent: Friday, June 12, 2009 9:38 PM
To: thrift-user@incubator.apache.org
Subject: specializing / polymorphic types?
I'd like to define a struct filter_t such that i can define methods
get(string key, filter_t filter) and scan(string start_key, string
end_key, filter_t filter) and then specialize filter_t as
column_filter_t, time_filter_t, etc.
Right now we have a dozen get_ methods, which is bad enough as it is
but now we are facing a copy/paste to make scan versions of each.
Please tell me there is a better way.
-Jonathan