You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Nathan Marz (JIRA)" <ji...@apache.org> on 2009/01/19 23:02:59 UTC

[jira] Commented: (THRIFT-253) Enhance FieldMetaData

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

Nathan Marz commented on THRIFT-253:
------------------------------------

Overall this is really good. A couple minor suggestions:

1. Instead of having variables isStruct and isContainer, can we have convenience methods instead? Such as:

public boolean isStruct() { return type==TType.STRUCT; }

2. Instead of "default          : return NULL; break; // This should never happen!" is it possible to throw an exception of some sort?


Also, to make the meta data stuff complete, I think we should have a global map from the struct name to the field meta data map. This will make it possible to "search" the meta data without ever resorting to java reflection. Don't really know where this meta data map should go... maybe generate a new class called "GlobalMetaData". This class can go into a "meta_data" subpackage of the generated code to prevent collision with user chosen struct names. Or maybe have a "GlobalMetaData" class in the thrift library, and the static initializers of every thrift struct can add their meta data map to the global class.

> Enhance FieldMetaData
> ---------------------
>
>                 Key: THRIFT-253
>                 URL: https://issues.apache.org/jira/browse/THRIFT-253
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Nathan Marz
>            Assignee: Piotr Kozikowski
>            Priority: Minor
>         Attachments: thrift-253-v1.patch
>
>
> Having more meta data would be useful in the FieldMetaData structure. Specifically, it should be enhanced to contain information about whether the field is a list, set, map, base type, or another thrift structure. If it's a container type, it should contain information about what types are in the container. For base types and other thrift structures, it should specify the type. There's many ways we could encode this information - here's a first proposal and I'm open to suggestions.The idea is to have a "FieldMetaData", which includes data about the field like field name, "required", "optional", etc. It also includes a "FieldValueMetaData" which would have a subclass for regular objects or for containers, which contain further meta data about the types within.
> // need a better name than "Necessity"
> enum Necessity {
>  REQUIRED, OPTIONAL, DEFAULT
> }
> interface FieldValueMetaData {
> }
> class FieldMetaData {
>  String fieldName;
>  Necessity necessity;
>  FieldValueMetaData valueMetaData;
> }
> class ListFieldMetaData implements FieldValueMetaData {
>  FieldValueMetaData type;
> }
> class SetFieldMetaData implements FieldValueMetaData {
>   FieldValueMetaData type;
> }
> class MapFieldMetaData implements FieldValueMetaData {
>  FieldValueMetaData keyType;
>  FieldValueMetaData valueType;
> }
> class ObjectFieldMetaData implements FieldValueMetaData {
>  Class type;
> }
>   
>  

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