You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Chad Walters (JIRA)" <ji...@apache.org> on 2009/04/05 06:31:13 UTC

[jira] Created: (THRIFT-428) Restrict map keys to integers and strings only

Restrict map keys to integers and strings only
----------------------------------------------

                 Key: THRIFT-428
                 URL: https://issues.apache.org/jira/browse/THRIFT-428
             Project: Thrift
          Issue Type: Improvement
          Components: Compiler (General)
    Affects Versions: 0.1
            Reporter: Chad Walters
             Fix For: 0.1


For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages (David Reiss will elaborate on this).

I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Reiss updated THRIFT-428:
-------------------------------

    Description: 
For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:

C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.

Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)

Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.

Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.

PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.

Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.


I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

  was:
For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages (David Reiss will elaborate on this).

I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.


> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>             Fix For: 0.1
>
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "Jérémie BORDIER (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12695821#action_12695821 ] 

Jérémie BORDIER commented on THRIFT-428:
----------------------------------------

I'm also on board with this ticket. It's a significant step into consistency across language and doesn't involve a lot of code, so let's do this for 0.1. Nevertheless, we should really consider freezing features for 0.1 and rushing into closing tickets to get something out, otherwise it will still go on like this...

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>             Fix For: 0.1
>
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12695939#action_12695939 ] 

Bryan Duxbury commented on THRIFT-428:
--------------------------------------

I'm a little concerned that this ticket is coming in so close to the release. We originally indicated that we wanted to make the release on the 7th, and that the feature freeze was April 1st. At this point, I'd honestly just rather we make the release with no new giant changes like this one. 

Also, I actually make use of structs as map keys. It works perfectly fine in Java and Ruby. If some languages don't support this, that sucks, but I don't think the idea of compound keys is something we should just chuck. It would certainly change my approach in some areas a lot. Is there any way we could make the other languages support this? Granted it might not end up looking that natural in each language, but I think it might be useful anyways.

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>             Fix For: 0.1
>
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "Chad Walters (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12696187#action_12696187 ] 

Chad Walters commented on THRIFT-428:
-------------------------------------

Perhaps I should have said "Do you see any non-ugly workarounds?" ;)

I don't know how people feel about this kind of thing. One of the original goals in Thrift was that the Thrift types should more or less map to the standard types supported in each of the target languages.

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>             Fix For: 0.2
>
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "Chad Walters (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chad Walters updated THRIFT-428:
--------------------------------

    Fix Version/s:     (was: 0.1)
                   0.2

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>             Fix For: 0.2
>
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12895853#action_12895853 ] 

Bryan Duxbury commented on THRIFT-428:
--------------------------------------

I think we should close this issue "wont fix". I don't think it makes sense to gut library capabilities to cater to the least capable language we support.

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "Chad Walters (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12696114#action_12696114 ] 

Chad Walters commented on THRIFT-428:
-------------------------------------

Some of these items are inherent issues with the target languages. For example, I am not sure there are any good approaches for PHP. Do you see any workarounds?

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>             Fix For: 0.2
>
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "Chad Walters (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12695812#action_12695812 ] 

Chad Walters commented on THRIFT-428:
-------------------------------------

One other thing to note: the JSON protocol also currently assumes that map keys are numbers or strings.

I think we would want to exclude floating point types from being map keys because "equals" for floating points is pretty wonky. Come to think of it, we might want to disallow floats in sets for the same reason...

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>             Fix For: 0.1
>
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "Chad Walters (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12695955#action_12695955 ] 

Chad Walters commented on THRIFT-428:
-------------------------------------

Bryan, does the Ruby implementation now support a reasonable hash function for structs?

It's interesting how the importance of smooth interoperability across languages and the importance of flexibility for languages to be independent of the constraints imposed by other languages change places when different use cases and language sets are affected (see discussion in THRIFT-395).

Since there clearly isn't consensus here and we are close to the 0.1 release, I will defer this. If someone wants to implement David's suggestion of a compiler flag to select the behavior, I wouldn't complain.

I will probably keep raising this issue until the community and/or the PMC come up with better guidelines around interoperability vs. flexibility that don't change based on convenience for any particular set of use cases and language choices but rather provide a principled basis for decision-making.

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>             Fix For: 0.2
>
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12696108#action_12696108 ] 

Bryan Duxbury commented on THRIFT-428:
--------------------------------------

Ruby's hash is just as naive as Java's at the moment. I think that could be improved upon without too much trouble, though.

I happen to think my stances on this issue and THRIFT-395 are pretty consistent - if some libraries can't support the feature set, then we should consider enhancing Thrift or the libraries to bring them up to speed. 

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>             Fix For: 0.2
>
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12695809#action_12695809 ] 

David Reiss commented on THRIFT-428:
------------------------------------

I'm on board with this, since the current level of support is not good, the prospects are not great, and the value of these constructs is suspect.  I doubt it will affect many (any?) people.  A few bits of anecdotal evidence:
- I grepped through Facebook's codebase and found about 200 occurrences of "map" types in .thrift files.  Every one was an integer, enum (effectively an integer), string, or typedef of the same.  There were no structures or containers as keys.  We have very few uses of the set type, but it had the same result.
- Using structures or containers as map keys (or set elements) in PHP is currently impossible.  I've never heard someone from Facebook complain about this.  I think one person might have mentioned it on the dev list.

We could possibly preserve the current behavior with a compiler flag for people who need access to saved data.

I'm not aware of any reason to forbid doubles as map keys, but it doesn't seem to be a feature in much demand.

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>             Fix For: 0.1
>
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12696150#action_12696150 ] 

Bryan Duxbury commented on THRIFT-428:
--------------------------------------

PHP supports writing classes, right? We could make a non-native map implementation that has the functionality we're looking for. The same is true in any target language, I'd think. I know it wouldn't be trivial in a lot of languages, but we might be able to turn up a reasonable approximation.

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>             Fix For: 0.2
>
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (THRIFT-428) Restrict map keys to integers and strings only

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury closed THRIFT-428.
--------------------------------

    Resolution: Won't Fix

> Restrict map keys to integers and strings only
> ----------------------------------------------
>
>                 Key: THRIFT-428
>                 URL: https://issues.apache.org/jira/browse/THRIFT-428
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.1
>            Reporter: Chad Walters
>
> For the sake of better interoperability, particularly with PHP, it would be a good idea to restrict map keys to be only of integer and string type. Handling of structures and containers as key types is a pretty mixed bag across the main supported languages.  The current state of affairs is:
> C++: Containers with containers as keys (with no structs involved) are fine.  If a struct (or container of structs, or container of containers of structs, etc.) is to be used as a map key, it must have a comparison (less than) operator defined.
> Java: Containers and structs can be used as map keys or set elements.  It is not entirely safe, but this is the Java convention (trust the application developer).  structs cannot be used in sorted containers.  Using structs as map keys without an optional dependency (apache commons lang) is very inefficient because structures all have a hashCode of 0 without it.  (Can binaries be used as keys?)
> Python: Using mutable containers as map keys is impossible.  Using mutable structures as map keys is possible, but unsafe and goes against a very strong Python convention.  We are pretty close to having implementations of immutable containers and structures, but the code will probably end up being pretty bulky or pretty skeevy.
> Ruby: (Maybe someone can fill in more details?) Structures as map keys are very inefficient because all structures have a hash code of zero.
> PHP: Using structures or containers as map keys (or set elements) in PHP is currently impossible, and might be impossible to implement.  Only strings and numbers can be associative array keys in PHP.
> Erlang: Any struct or container can be a map key or set element.  There are no safety or performance issues.  Erlang is pretty cool like that.
> I'd like us to consider doing this for 0.1 so it's in there for the first official Apache release.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.