Search code examples
dictionarythriftidl

Thrift IDL syntax error - accept and return map


I am writing a thrift server. One of the function is supposed to accept map and return a map as well.

Following is my thrift file:

service base{
    map<string, string>    method_1(1: map<string, double>)
}

service child extends base{
    map<string, string>    method_1(1: map<string, double>),
    void                    method_2(1:string path)
}

It says that

ERROR: someservice.thrift:4] (last token was ')')
syntax error

and I have no idea what is wrong in the syntax.


Solution

  • You have to name your arguments.

    service base{
      map<string, string>    method_1(1: map<string, double> arg1)
    }
    
    service child extends base{
      map<string, string>    method_1(1: map<string, double> arg1),
      void                    method_2(1:string path)
    }
    

    You already did correctly at method_2 whose arguments are (1:string path), but then you forgot it at method_1(1: map<string, double>) - this is not sufficient.

    And by the way, it has absolutely nothing to do with maps.