[ 
https://issues.apache.org/jira/browse/THRIFT-122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625973#action_12625973
 ] 

Noble Paul commented on THRIFT-122:
-----------------------------------

Let us assume that new 'denseprotocol' is not going to be binary-compatible 
with binaryprotocol because it will have to be so different. We decided that we 
will just keep the API common but wire format different. 

On implementation of this feature on the wire. 

Any wildcard collection will be written down in the following way .

# every element will write down the type associated with the object first . 
# If the type is a STRUCT . The idl name name of the STRUCT will be writtten 
down as an 'extern' string .This ensures that we only write the name once 
per-struct per payload
# then the value is written down using the Object's write(TProtocol ) method

on the read side

# the type is read first . 
# if it is a non-struct type , read the data
# if it is a struct read the struct-name 
# Every language can have specific implementation on how to read this.
#* In java we can keep an idl-name->java-class (in the 
<filename>_constants.java) and do a new instance of the class  and the instance 
can read the struct . If the name is unknown ,skip the object and the value 
will be null
#* C++ can just read field by field into a byte[] and keep a void pointer to 
that. Users can type cast and use as they wish 

The caveat is that every Object they put into the collection must be a known 
'primitive' type or an  idl type.  If it does not meet this criterion it will 
be written down as null 

bq.I see a little problem with versioning, if we have two structures 
bq.Can V2 read data from V1 or the first field should be skipped?

It must be skipped . If somebody wishes to change a type change the 'id' of the 
field also should change because the generated code will be incompatible

> Allow heterogeneous collections
> -------------------------------
>
>                 Key: THRIFT-122
>                 URL: https://issues.apache.org/jira/browse/THRIFT-122
>             Project: Thrift
>          Issue Type: New Feature
>            Reporter: Noble Paul
>
> Currently thrift only supports homogeneous collections . But , that is very 
> restrictive for many languages which allows heterogeneous collections. It 
> does not have to be supported in BinaryProtocol The new DenseProtocol may add 
> support for this
> implementation details 
> the IDL can allow syntax 
> {code}
> list<?>
> set<?>
> map<?,?>
> map<?,the-type>
> map<the-type,?>
> {code}
> While writing down data use a type modifier to say whether key (1), value(2) 
> or both(3) are wild cards
> for a List/Set use a type modifier 1 to specify that it is heterogeneous
> If it is a homogeneous collection do it the way it is done now.
> Or else
> add type information just before the data. So it adds an extra byte/element 
> For ma

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

Reply via email to