[jira] [Commented] (THRIFT-2063) Go compiler cannot create code for maps with complex/binary keys

2017-07-14 Thread Davin Chia (JIRA)

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

Davin Chia commented on THRIFT-2063:


Bumping this. I know this is an old issue, but I am currently running into this 
problem while introducing go into our code base. I am compiling using thrift 
0.10.0. Is there an update on this? Has there been a consensus to write thrift 
definitions without complex keys to avoid this problem and are there current 
work arounds? Or Is this still an open issue with solutions open to discussion? 
 

> Go compiler cannot create code for maps with complex/binary keys
> 
>
> Key: THRIFT-2063
> URL: https://issues.apache.org/jira/browse/THRIFT-2063
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Reporter: Remo Hertig
>
> trying to generate code for ThriftTest leads to:
> {code}
> ../../compiler/cpp/thrift --gen go ../ThriftTest.thrift 
> [WARNING:/tbHD/Home/nairboon/dev/thrift/test/ThriftTest.thrift:41] No 
> generator named 'noexist' could be found!
> [WARNING:/tbHD/Home/nairboon/dev/thrift/test/ThriftTest.thrift:42] cpp 
> generator does not accept 'noexist' as sub-namespace!
> Error: Cannot produce a valid type for a Go map key: map[int32]bool - 
> aborting.{code}
> the affected struct seems to be #3: 
> {code}
> struct CrazyNesting {
>   1: string string_field,
>   2: optional set set_field,
>   3: required list< map,map> 
> list_field,
>   4: binary binary_field
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Comment Edited] (THRIFT-2063) Go compiler cannot create code for maps with complex/binary keys

2017-07-17 Thread Davin Chia (JIRA)

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

Davin Chia edited comment on THRIFT-2063 at 7/17/17 8:00 PM:
-

Bumping this. I know this is an old issue, but I am currently running into this 
problem while introducing go into our code base. I am compiling using thrift 
0.10.0. Is there an update on this? Has there been a consensus to write thrift 
definitions without complex keys to avoid this problem and are there current 
work arounds? Or Is this still an open issue with solutions open to discussion? 
 [~apesternikov]


was (Author: davinc):
Bumping this. I know this is an old issue, but I am currently running into this 
problem while introducing go into our code base. I am compiling using thrift 
0.10.0. Is there an update on this? Has there been a consensus to write thrift 
definitions without complex keys to avoid this problem and are there current 
work arounds? Or Is this still an open issue with solutions open to discussion? 
 

> Go compiler cannot create code for maps with complex/binary keys
> 
>
> Key: THRIFT-2063
> URL: https://issues.apache.org/jira/browse/THRIFT-2063
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Reporter: Remo Hertig
>
> trying to generate code for ThriftTest leads to:
> {code}
> ../../compiler/cpp/thrift --gen go ../ThriftTest.thrift 
> [WARNING:/tbHD/Home/nairboon/dev/thrift/test/ThriftTest.thrift:41] No 
> generator named 'noexist' could be found!
> [WARNING:/tbHD/Home/nairboon/dev/thrift/test/ThriftTest.thrift:42] cpp 
> generator does not accept 'noexist' as sub-namespace!
> Error: Cannot produce a valid type for a Go map key: map[int32]bool - 
> aborting.{code}
> the affected struct seems to be #3: 
> {code}
> struct CrazyNesting {
>   1: string string_field,
>   2: optional set set_field,
>   3: required list< map,map> 
> list_field,
>   4: binary binary_field
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Created] (THRIFT-4253) Go generator assigns strings to field in const instead of pointers.

2017-07-17 Thread Davin Chia (JIRA)
Davin Chia created THRIFT-4253:
--

 Summary: Go generator assigns strings to field in const instead of 
pointers.
 Key: THRIFT-4253
 URL: https://issues.apache.org/jira/browse/THRIFT-4253
 Project: Thrift
  Issue Type: Bug
  Components: Go - Compiler
Affects Versions: 0.10.0
 Environment: Generated using docker-thrift.
Reporter: Davin Chia


Given the follow thrift definition:
{code:java}
struct custom {
  1: required string field_a;
  2: optional string field_b;
}
{code}

with the following constant map defined in the same file:

{code:java}
const map custom_map = {
  ...,
  42 : { 'field_a':'www.testa.com', 'field_b':'www.testb.com'},
  ...,
}
{code}

Thrift generates the following go struct in the main {code:java}x.go{code} file:
{code:java}
type Custom struct {
  FieldA string `thrift:"field_a,required" db:"field_a" json:"field_a"`
  FieldB *string `thrift:"field_b,2" db:"field_b" json:"field_b,omitempty"`
}
{code}
with the corresponding assignments in the {code:java} X-consts.go {code} file:

{code:java}
CUSTOM_MAP = map[int]*Custom {
  ...,
  42: &Custom {FieldA: "www.testa.com", FieldB: "www.testb.com"},
  ...,
}
{code}

I assume field_b's pointer type is to allow for null values as per the 
optional. The generator should be assigning pointers instead of strings. 

I'm not sure how much effort it would take to fix this. I am encountering this 
problem at work right and would be very happy to starting working on this with 
some guidance from experts around here. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Comment Edited] (THRIFT-2063) Go compiler cannot create code for maps with complex/binary keys

2017-07-17 Thread Davin Chia (JIRA)

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

Davin Chia edited comment on THRIFT-2063 at 7/17/17 8:57 PM:
-

Bumping this. I know this is an old issue, but I am currently running into this 
problem while introducing go into our code base. I am compiling using thrift 
0.10.0. Is there an update on this? Has there been a consensus to write thrift 
definitions without complex keys to avoid this problem and are there current 
work arounds? Or Is this still an open issue with solutions open to discussion? 
 [~apesternikov] [~jensg] [~traviscline]


was (Author: davinc):
Bumping this. I know this is an old issue, but I am currently running into this 
problem while introducing go into our code base. I am compiling using thrift 
0.10.0. Is there an update on this? Has there been a consensus to write thrift 
definitions without complex keys to avoid this problem and are there current 
work arounds? Or Is this still an open issue with solutions open to discussion? 
 [~apesternikov]

> Go compiler cannot create code for maps with complex/binary keys
> 
>
> Key: THRIFT-2063
> URL: https://issues.apache.org/jira/browse/THRIFT-2063
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Reporter: Remo Hertig
>
> trying to generate code for ThriftTest leads to:
> {code}
> ../../compiler/cpp/thrift --gen go ../ThriftTest.thrift 
> [WARNING:/tbHD/Home/nairboon/dev/thrift/test/ThriftTest.thrift:41] No 
> generator named 'noexist' could be found!
> [WARNING:/tbHD/Home/nairboon/dev/thrift/test/ThriftTest.thrift:42] cpp 
> generator does not accept 'noexist' as sub-namespace!
> Error: Cannot produce a valid type for a Go map key: map[int32]bool - 
> aborting.{code}
> the affected struct seems to be #3: 
> {code}
> struct CrazyNesting {
>   1: string string_field,
>   2: optional set set_field,
>   3: required list< map,map> 
> list_field,
>   4: binary binary_field
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (THRIFT-2063) Go compiler cannot create code for maps with complex/binary keys

2017-07-17 Thread Davin Chia (JIRA)

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

Davin Chia commented on THRIFT-2063:


Ah sorry for the noise. I am definitely going to fix this. My intention on 
opening discussion was to arrive at a community accepted solution. This is 
because I am not a Go expert and so am not sure about the best solution. The 
current monkey patch I am using is to convert all complex keys into strings, 
which is definitely only temporary. I will get to this after tackling 
*https://issues.apache.org/jira/browse/THRIFT-4253*.

> Go compiler cannot create code for maps with complex/binary keys
> 
>
> Key: THRIFT-2063
> URL: https://issues.apache.org/jira/browse/THRIFT-2063
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Reporter: Remo Hertig
>
> trying to generate code for ThriftTest leads to:
> {code}
> ../../compiler/cpp/thrift --gen go ../ThriftTest.thrift 
> [WARNING:/tbHD/Home/nairboon/dev/thrift/test/ThriftTest.thrift:41] No 
> generator named 'noexist' could be found!
> [WARNING:/tbHD/Home/nairboon/dev/thrift/test/ThriftTest.thrift:42] cpp 
> generator does not accept 'noexist' as sub-namespace!
> Error: Cannot produce a valid type for a Go map key: map[int32]bool - 
> aborting.{code}
> the affected struct seems to be #3: 
> {code}
> struct CrazyNesting {
>   1: string string_field,
>   2: optional set set_field,
>   3: required list< map,map> 
> list_field,
>   4: binary binary_field
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (THRIFT-4253) Go generator assigns strings to field in const instead of pointers.

2017-07-17 Thread Davin Chia (JIRA)

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

Davin Chia commented on THRIFT-4253:


Thanks for the quick reply [~jensg]. This is the first time I am contributing 
to a large C++ open source project, or writing much C++ to be honest, and it 
will be good to get some guidance on development workflow.  

Immediate questions are (Again sorry if they sound newbie, because I am): Where 
can I check the code out? What is the typical build for C++ projects? I also 
have a question about testing, but I now know where to do that 
(ConstantsDemo.thrift).

If you spare a few minutes, it will also be nice to have a point in the code I 
can start from. Thanks.

> Go generator assigns strings to field in const instead of pointers.
> ---
>
> Key: THRIFT-4253
> URL: https://issues.apache.org/jira/browse/THRIFT-4253
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
> Environment: Generated using docker-thrift.
>Reporter: Davin Chia
>
> Given the follow thrift definition:
> {code:java}
> struct custom {
>   1: required string field_a;
>   2: optional string field_b;
> }
> {code}
> with the following constant map defined in the same file:
> {code:java}
> const map custom_map = {
>   ...,
>   42 : { 'field_a':'www.testa.com', 'field_b':'www.testb.com'},
>   ...,
> }
> {code}
> Thrift generates the following go struct in the main {code:java}x.go{code} 
> file:
> {code:java}
> type Custom struct {
>   FieldA string `thrift:"field_a,required" db:"field_a" json:"field_a"`
>   FieldB *string `thrift:"field_b,2" db:"field_b" json:"field_b,omitempty"`
> }
> {code}
> with the corresponding assignments in the {code:java} X-consts.go {code} file:
> {code:java}
> CUSTOM_MAP = map[int]*Custom {
>   ...,
>   42: &Custom {FieldA: "www.testa.com", FieldB: "www.testb.com"},
>   ...,
> }
> {code}
> I assume field_b's pointer type is to allow for null values as per the 
> optional. The generator should be assigning pointers instead of strings. 
> I'm not sure how much effort it would take to fix this. I am encountering 
> this problem at work right and would be very happy to starting working on 
> this with some guidance from experts around here. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Created] (THRIFT-4254) Go generator does not respect typedef types when generating read/write functions.

2017-07-17 Thread Davin Chia (JIRA)
Davin Chia created THRIFT-4254:
--

 Summary: Go generator does not respect typedef types when 
generating read/write functions.
 Key: THRIFT-4254
 URL: https://issues.apache.org/jira/browse/THRIFT-4254
 Project: Thrift
  Issue Type: Bug
  Components: Go - Compiler
Affects Versions: 0.10.0
Reporter: Davin Chia


Give the following thrift definitions:
 
{code:java}
typedef i64   RequestId 

struct Custom {
  optional set field_a;
}
{code}

The following go code is generated:

{code:java}
type RequestId int64

type Custom struct {
  FieldA map[RequestId]struct{}
}

...

func (p *Custom)  ReadField1(iprot thrift.TProtocol) error {
  _, size, err := iprot.ReadSetBegin()
  if err != nil {
return thrift.PrependError("error reading set begin: ", err)
  }
  tSet := make(map[int64]struct{}, size)
  p.ActiveImportIds =  tSet
  for i := 0; i < size; i ++ {
var _elem1 int64
if v, err := iprot.ReadI64(); err != nil {
return thrift.PrependError("error reading field 0: ", err)
} else {
_elem1 = v
}
p.FieldA[_elem1] = struct{}{}
  }
  if err := iprot.ReadSetEnd(); err != nil {
return thrift.PrependError("error reading set end: ", err)
  }
  return nil
}
{code}

There are two errors here:
1. {code:java}tSet{code} should be {code:java} map[RequestId]struct{} {code} 
and not {code:java}map[int64]struct{}{code}.
2. {code:java} elem_1 {code}should be of type {code:java}RequestId{code} and 
the values need to be case to {code:java}RequestId{code} before assigning to 
{code:java}elem_1{code}.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Comment Edited] (THRIFT-4253) Go generator assigns strings to field in const instead of pointers.

2017-07-17 Thread Davin Chia (JIRA)

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

Davin Chia edited comment on THRIFT-4253 at 7/18/17 3:13 AM:
-

Thanks for the quick reply [~jensg]. This is the first time I am contributing 
to a large C++ open source project, or writing much C++ to be honest, and it 
will be good to get some guidance on development workflow. I'm assuming I clone 
https://github.com/apache/thrift, make a branch and start working.

If you spare a few minutes, it will also be nice to have a point in the code I 
can start from. Thanks.


was (Author: davinc):
Thanks for the quick reply [~jensg]. This is the first time I am contributing 
to a large C++ open source project, or writing much C++ to be honest, and it 
will be good to get some guidance on development workflow.  

Immediate questions are (Again sorry if they sound newbie, because I am): Where 
can I check the code out? What is the typical build for C++ projects? I also 
have a question about testing, but I now know where to do that 
(ConstantsDemo.thrift).

If you spare a few minutes, it will also be nice to have a point in the code I 
can start from. Thanks.

> Go generator assigns strings to field in const instead of pointers.
> ---
>
> Key: THRIFT-4253
> URL: https://issues.apache.org/jira/browse/THRIFT-4253
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
> Environment: Generated using docker-thrift.
>Reporter: Davin Chia
>
> Given the follow thrift definition:
> {code:java}
> struct custom {
>   1: required string field_a;
>   2: optional string field_b;
> }
> {code}
> with the following constant map defined in the same file:
> {code:java}
> const map custom_map = {
>   ...,
>   42 : { 'field_a':'www.testa.com', 'field_b':'www.testb.com'},
>   ...,
> }
> {code}
> Thrift generates the following go struct in the main {code:java}x.go{code} 
> file:
> {code:java}
> type Custom struct {
>   FieldA string `thrift:"field_a,required" db:"field_a" json:"field_a"`
>   FieldB *string `thrift:"field_b,2" db:"field_b" json:"field_b,omitempty"`
> }
> {code}
> with the corresponding assignments in the {code:java} X-consts.go {code} file:
> {code:java}
> CUSTOM_MAP = map[int]*Custom {
>   ...,
>   42: &Custom {FieldA: "www.testa.com", FieldB: "www.testb.com"},
>   ...,
> }
> {code}
> I assume field_b's pointer type is to allow for null values as per the 
> optional. The generator should be assigning pointers instead of strings. 
> I'm not sure how much effort it would take to fix this. I am encountering 
> this problem at work right and would be very happy to starting working on 
> this with some guidance from experts around here. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Comment Edited] (THRIFT-4253) Go generator assigns strings to field in const instead of pointers.

2017-07-17 Thread Davin Chia (JIRA)

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

Davin Chia edited comment on THRIFT-4253 at 7/18/17 3:15 AM:
-

Thanks for the quick reply [~jensg]. This is the first time I am contributing 
to a large C++ open source project, or writing much C++ to be honest, and it 
will be good to get some guidance on development workflow. I'm assuming I clone 
https://github.com/apache/thrift, make a branch and start working. Happy to 
jump on some other communication medium if that is better for you.

If you spare a few minutes, it will also be nice to have a point in the code I 
can start from. Thanks.


was (Author: davinc):
Thanks for the quick reply [~jensg]. This is the first time I am contributing 
to a large C++ open source project, or writing much C++ to be honest, and it 
will be good to get some guidance on development workflow. I'm assuming I clone 
https://github.com/apache/thrift, make a branch and start working.

If you spare a few minutes, it will also be nice to have a point in the code I 
can start from. Thanks.

> Go generator assigns strings to field in const instead of pointers.
> ---
>
> Key: THRIFT-4253
> URL: https://issues.apache.org/jira/browse/THRIFT-4253
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
> Environment: Generated using docker-thrift.
>Reporter: Davin Chia
>
> Given the follow thrift definition:
> {code:java}
> struct custom {
>   1: required string field_a;
>   2: optional string field_b;
> }
> {code}
> with the following constant map defined in the same file:
> {code:java}
> const map custom_map = {
>   ...,
>   42 : { 'field_a':'www.testa.com', 'field_b':'www.testb.com'},
>   ...,
> }
> {code}
> Thrift generates the following go struct in the main {code:java}x.go{code} 
> file:
> {code:java}
> type Custom struct {
>   FieldA string `thrift:"field_a,required" db:"field_a" json:"field_a"`
>   FieldB *string `thrift:"field_b,2" db:"field_b" json:"field_b,omitempty"`
> }
> {code}
> with the corresponding assignments in the {code:java} X-consts.go {code} file:
> {code:java}
> CUSTOM_MAP = map[int]*Custom {
>   ...,
>   42: &Custom {FieldA: "www.testa.com", FieldB: "www.testb.com"},
>   ...,
> }
> {code}
> I assume field_b's pointer type is to allow for null values as per the 
> optional. The generator should be assigning pointers instead of strings. 
> I'm not sure how much effort it would take to fix this. I am encountering 
> this problem at work right and would be very happy to starting working on 
> this with some guidance from experts around here. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Comment Edited] (THRIFT-4253) Go generator assigns strings to field in const instead of pointers.

2017-07-17 Thread Davin Chia (JIRA)

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

Davin Chia edited comment on THRIFT-4253 at 7/18/17 3:44 AM:
-

Thanks for the quick reply [~jensg]. This is the first time I am contributing 
to a large C++ open source project, or writing much C++ to be honest, and it 
will be good to get some guidance on development workflow. I'm assuming I clone 
https://github.com/apache/thrift, make a branch and start working. Happy to 
jump on some other communication medium if that is better for you.

If you can spare a few minutes, it will also be nice to have a point in the 
code I can start from. Thanks.


was (Author: davinc):
Thanks for the quick reply [~jensg]. This is the first time I am contributing 
to a large C++ open source project, or writing much C++ to be honest, and it 
will be good to get some guidance on development workflow. I'm assuming I clone 
https://github.com/apache/thrift, make a branch and start working. Happy to 
jump on some other communication medium if that is better for you.

If you spare a few minutes, it will also be nice to have a point in the code I 
can start from. Thanks.

> Go generator assigns strings to field in const instead of pointers.
> ---
>
> Key: THRIFT-4253
> URL: https://issues.apache.org/jira/browse/THRIFT-4253
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
> Environment: Generated using docker-thrift.
>Reporter: Davin Chia
>
> Given the follow thrift definition:
> {code:java}
> struct custom {
>   1: required string field_a;
>   2: optional string field_b;
> }
> {code}
> with the following constant map defined in the same file:
> {code:java}
> const map custom_map = {
>   ...,
>   42 : { 'field_a':'www.testa.com', 'field_b':'www.testb.com'},
>   ...,
> }
> {code}
> Thrift generates the following go struct in the main {code:java}x.go{code} 
> file:
> {code:java}
> type Custom struct {
>   FieldA string `thrift:"field_a,required" db:"field_a" json:"field_a"`
>   FieldB *string `thrift:"field_b,2" db:"field_b" json:"field_b,omitempty"`
> }
> {code}
> with the corresponding assignments in the {code:java} X-consts.go {code} file:
> {code:java}
> CUSTOM_MAP = map[int]*Custom {
>   ...,
>   42: &Custom {FieldA: "www.testa.com", FieldB: "www.testb.com"},
>   ...,
> }
> {code}
> I assume field_b's pointer type is to allow for null values as per the 
> optional. The generator should be assigning pointers instead of strings. 
> I'm not sure how much effort it would take to fix this. I am encountering 
> this problem at work right and would be very happy to starting working on 
> this with some guidance from experts around here. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Created] (THRIFT-4255) Go generator has type errors when in read/write functions for set

2017-07-17 Thread Davin Chia (JIRA)
Davin Chia created THRIFT-4255:
--

 Summary: Go generator has type errors when in read/write functions 
for set
 Key: THRIFT-4255
 URL: https://issues.apache.org/jira/browse/THRIFT-4255
 Project: Thrift
  Issue Type: Bug
  Components: Go - Compiler
Affects Versions: 0.10.0
Reporter: Davin Chia


Given the following thrift definition:

{code:java} struct CustomSet {
  1: required set values;
}{code}

The following go code is generated:
{code:java}
type CustomSet struct {
  Values map[string]struct{} `thrift:"values,1,required" db:"values" 
json:"values"`
}

func (p *ByteArraySet)  ReadField1(iprot thrift.TProtocol) error {
  _, size, err := iprot.ReadSetBegin()
  if err != nil {
return thrift.PrependError("error reading set begin: ", err)
  }
  tSet := make(map[string]struct{}, size)
  p.Values =  tSet
  for i := 0; i < size; i ++ {
var _elem2 []byte
if v, err := iprot.ReadBinary(); err != nil {
return thrift.PrependError("error reading field 0: ", err)
} else {
_elem2 = v
}
p.Values[_elem2] = struct{}{}
  }
  if err := iprot.ReadSetEnd(); err != nil {
return thrift.PrependError("error reading set end: ", err)
  }
  return nil
}

func (p *ByteArraySet) writeField1(oprot thrift.TProtocol) (err error) {
  if err := oprot.WriteFieldBegin("values", thrift.SET, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 
1:values: ", p), err) }
  if err := oprot.WriteSetBegin(thrift.STRING, len(p.Values)); err != nil {
return thrift.PrependError("error writing set begin: ", err)
  }
  for v, _ := range p.Values {
if err := oprot.WriteBinary(v); err != nil {
return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), 
err) }
  }
  if err := oprot.WriteSetEnd(); err != nil {
return thrift.PrependError("error writing set end: ", err)
  }
  if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:values: 
", p), err) }
  return err
}
{code}

In the *Read* function, *elem_2* needs to be cast to *string* before its used 
as a key to *Values*.
In the *Write* function, *v* needs to be case to *byte[]* before its passed to 
*WriteBinary*.

I have opened a couple of issues today and will slowly work through them as 
time frees up.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Resolved] (THRIFT-4255) Go generator has type errors when in read/write functions for set

2017-07-20 Thread Davin Chia (JIRA)

 [ 
https://issues.apache.org/jira/browse/THRIFT-4255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Davin Chia resolved THRIFT-4255.

Resolution: Fixed

> Go generator has type errors when in read/write functions for set
> -
>
> Key: THRIFT-4255
> URL: https://issues.apache.org/jira/browse/THRIFT-4255
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
>Reporter: Davin Chia
>
> Given the following thrift definition:
> {code:java} struct CustomSet {
>   1: required set values;
> }{code}
> The following go code is generated:
> {code:java}
> type CustomSet struct {
>   Values map[string]struct{} `thrift:"values,1,required" db:"values" 
> json:"values"`
> }
> func (p *ByteArraySet)  ReadField1(iprot thrift.TProtocol) error {
>   _, size, err := iprot.ReadSetBegin()
>   if err != nil {
> return thrift.PrependError("error reading set begin: ", err)
>   }
>   tSet := make(map[string]struct{}, size)
>   p.Values =  tSet
>   for i := 0; i < size; i ++ {
> var _elem2 []byte
> if v, err := iprot.ReadBinary(); err != nil {
> return thrift.PrependError("error reading field 0: ", err)
> } else {
> _elem2 = v
> }
> p.Values[_elem2] = struct{}{}
>   }
>   if err := iprot.ReadSetEnd(); err != nil {
> return thrift.PrependError("error reading set end: ", err)
>   }
>   return nil
> }
> func (p *ByteArraySet) writeField1(oprot thrift.TProtocol) (err error) {
>   if err := oprot.WriteFieldBegin("values", thrift.SET, 1); err != nil {
> return thrift.PrependError(fmt.Sprintf("%T write field begin error 
> 1:values: ", p), err) }
>   if err := oprot.WriteSetBegin(thrift.STRING, len(p.Values)); err != nil {
> return thrift.PrependError("error writing set begin: ", err)
>   }
>   for v, _ := range p.Values {
> if err := oprot.WriteBinary(v); err != nil {
> return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), 
> err) }
>   }
>   if err := oprot.WriteSetEnd(); err != nil {
> return thrift.PrependError("error writing set end: ", err)
>   }
>   if err := oprot.WriteFieldEnd(); err != nil {
> return thrift.PrependError(fmt.Sprintf("%T write field end error 
> 1:values: ", p), err) }
>   return err
> }
> {code}
> In the *Read* function, *elem_2* needs to be cast to *string* before its used 
> as a key to *Values*.
> In the *Write* function, *v* needs to be case to *byte[]* before its passed 
> to *WriteBinary*.
> I have opened a couple of issues today and will slowly work through them as 
> time frees up.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (THRIFT-4255) Go generator has type errors when in read/write functions for set

2017-07-20 Thread Davin Chia (JIRA)

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

Davin Chia commented on THRIFT-4255:


Seems this has been fixed in 
https://issues.apache.org/jira/browse/THRIFT-4011?jql=text%20~%20%22go%20set%22

> Go generator has type errors when in read/write functions for set
> -
>
> Key: THRIFT-4255
> URL: https://issues.apache.org/jira/browse/THRIFT-4255
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
>Reporter: Davin Chia
>
> Given the following thrift definition:
> {code:java} struct CustomSet {
>   1: required set values;
> }{code}
> The following go code is generated:
> {code:java}
> type CustomSet struct {
>   Values map[string]struct{} `thrift:"values,1,required" db:"values" 
> json:"values"`
> }
> func (p *ByteArraySet)  ReadField1(iprot thrift.TProtocol) error {
>   _, size, err := iprot.ReadSetBegin()
>   if err != nil {
> return thrift.PrependError("error reading set begin: ", err)
>   }
>   tSet := make(map[string]struct{}, size)
>   p.Values =  tSet
>   for i := 0; i < size; i ++ {
> var _elem2 []byte
> if v, err := iprot.ReadBinary(); err != nil {
> return thrift.PrependError("error reading field 0: ", err)
> } else {
> _elem2 = v
> }
> p.Values[_elem2] = struct{}{}
>   }
>   if err := iprot.ReadSetEnd(); err != nil {
> return thrift.PrependError("error reading set end: ", err)
>   }
>   return nil
> }
> func (p *ByteArraySet) writeField1(oprot thrift.TProtocol) (err error) {
>   if err := oprot.WriteFieldBegin("values", thrift.SET, 1); err != nil {
> return thrift.PrependError(fmt.Sprintf("%T write field begin error 
> 1:values: ", p), err) }
>   if err := oprot.WriteSetBegin(thrift.STRING, len(p.Values)); err != nil {
> return thrift.PrependError("error writing set begin: ", err)
>   }
>   for v, _ := range p.Values {
> if err := oprot.WriteBinary(v); err != nil {
> return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), 
> err) }
>   }
>   if err := oprot.WriteSetEnd(); err != nil {
> return thrift.PrependError("error writing set end: ", err)
>   }
>   if err := oprot.WriteFieldEnd(); err != nil {
> return thrift.PrependError(fmt.Sprintf("%T write field end error 
> 1:values: ", p), err) }
>   return err
> }
> {code}
> In the *Read* function, *elem_2* needs to be cast to *string* before its used 
> as a key to *Values*.
> In the *Write* function, *v* needs to be case to *byte[]* before its passed 
> to *WriteBinary*.
> I have opened a couple of issues today and will slowly work through them as 
> time frees up.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (THRIFT-4254) Go generator does not respect typedef types when generating read/write functions.

2017-07-21 Thread Davin Chia (JIRA)

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

Davin Chia commented on THRIFT-4254:


Seems to be solved in current version. Closing for now.

> Go generator does not respect typedef types when generating read/write 
> functions.
> -
>
> Key: THRIFT-4254
> URL: https://issues.apache.org/jira/browse/THRIFT-4254
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
>Reporter: Davin Chia
>
> Give the following thrift definitions:
>  
> {code:java}
> typedef i64   RequestId 
> struct Custom {
>   optional set field_a;
> }
> {code}
> The following go code is generated:
> {code:java}
> type RequestId int64
> type Custom struct {
>   FieldA map[RequestId]struct{}
> }
> ...
> func (p *Custom)  ReadField1(iprot thrift.TProtocol) error {
>   _, size, err := iprot.ReadSetBegin()
>   if err != nil {
> return thrift.PrependError("error reading set begin: ", err)
>   }
>   tSet := make(map[int64]struct{}, size)
>   p.ActiveImportIds =  tSet
>   for i := 0; i < size; i ++ {
> var _elem1 int64
> if v, err := iprot.ReadI64(); err != nil {
> return thrift.PrependError("error reading field 0: ", err)
> } else {
> _elem1 = v
> }
> p.FieldA[_elem1] = struct{}{}
>   }
>   if err := iprot.ReadSetEnd(); err != nil {
> return thrift.PrependError("error reading set end: ", err)
>   }
>   return nil
> }
> {code}
> There are two errors here:
> 1. {code:java}tSet{code} should be {code:java} map[RequestId]struct{} {code} 
> and not {code:java}map[int64]struct{}{code}.
> 2. {code:java} elem_1 {code}should be of type {code:java}RequestId{code} and 
> the values need to be case to {code:java}RequestId{code} before assigning to 
> {code:java}elem_1{code}.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Resolved] (THRIFT-4254) Go generator does not respect typedef types when generating read/write functions.

2017-07-21 Thread Davin Chia (JIRA)

 [ 
https://issues.apache.org/jira/browse/THRIFT-4254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Davin Chia resolved THRIFT-4254.

Resolution: Fixed

> Go generator does not respect typedef types when generating read/write 
> functions.
> -
>
> Key: THRIFT-4254
> URL: https://issues.apache.org/jira/browse/THRIFT-4254
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
>Reporter: Davin Chia
>
> Give the following thrift definitions:
>  
> {code:java}
> typedef i64   RequestId 
> struct Custom {
>   optional set field_a;
> }
> {code}
> The following go code is generated:
> {code:java}
> type RequestId int64
> type Custom struct {
>   FieldA map[RequestId]struct{}
> }
> ...
> func (p *Custom)  ReadField1(iprot thrift.TProtocol) error {
>   _, size, err := iprot.ReadSetBegin()
>   if err != nil {
> return thrift.PrependError("error reading set begin: ", err)
>   }
>   tSet := make(map[int64]struct{}, size)
>   p.ActiveImportIds =  tSet
>   for i := 0; i < size; i ++ {
> var _elem1 int64
> if v, err := iprot.ReadI64(); err != nil {
> return thrift.PrependError("error reading field 0: ", err)
> } else {
> _elem1 = v
> }
> p.FieldA[_elem1] = struct{}{}
>   }
>   if err := iprot.ReadSetEnd(); err != nil {
> return thrift.PrependError("error reading set end: ", err)
>   }
>   return nil
> }
> {code}
> There are two errors here:
> 1. {code:java}tSet{code} should be {code:java} map[RequestId]struct{} {code} 
> and not {code:java}map[int64]struct{}{code}.
> 2. {code:java} elem_1 {code}should be of type {code:java}RequestId{code} and 
> the values need to be case to {code:java}RequestId{code} before assigning to 
> {code:java}elem_1{code}.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (THRIFT-4253) Go generator assigns strings to field in const instead of pointers.

2017-07-29 Thread Davin Chia (JIRA)

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

Davin Chia commented on THRIFT-4253:


[~jensg] 

Made the whitespace changes. 

Will be happy to write some tests. Can I have a brief introduction to the 
testing workflow? Spent half an hour looking at the code but don't really know 
where to start. Is {{make cross}} the command to run the test suite? Is there 
any specific place you want me to insert the test or do I create my own test 
file?

> Go generator assigns strings to field in const instead of pointers.
> ---
>
> Key: THRIFT-4253
> URL: https://issues.apache.org/jira/browse/THRIFT-4253
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
> Environment: Generated using docker-thrift.
>Reporter: Davin Chia
>
> Given the follow thrift definition:
> {code:java}
> struct custom {
>   1: required string field_a;
>   2: optional string field_b;
> }
> {code}
> with the following constant map defined in the same file:
> {code:java}
> const map custom_map = {
>   ...,
>   42 : { 'field_a':'www.testa.com', 'field_b':'www.testb.com'},
>   ...,
> }
> {code}
> Thrift generates the following go struct in the main {code:java}x.go{code} 
> file:
> {code:java}
> type Custom struct {
>   FieldA string `thrift:"field_a,required" db:"field_a" json:"field_a"`
>   FieldB *string `thrift:"field_b,2" db:"field_b" json:"field_b,omitempty"`
> }
> {code}
> with the corresponding assignments in the {code:java} X-consts.go {code} file:
> {code:java}
> CUSTOM_MAP = map[int]*Custom {
>   ...,
>   42: &Custom {FieldA: "www.testa.com", FieldB: "www.testb.com"},
>   ...,
> }
> {code}
> I assume field_b's pointer type is to allow for null values as per the 
> optional. The generator should be assigning pointers instead of strings. 
> I'm not sure how much effort it would take to fix this. I am encountering 
> this problem at work right and would be very happy to starting working on 
> this with some guidance from experts around here. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)