Skip to content

Please review my optimizations and code generation fixes #61

Open
wants to merge 18 commits into from

4 participants

@apesternikov

library:

  • thrift's BYTE type is signed (so it is int8, not byte)
  • asynchronous protocol is removed as irrelevant in go code generation:
  • safer constants using typed vars
  • int64 consts over 2^32 dont blow up
  • negative byte consts
  • generated struct doesn't include type metainformation field to avoid metainfo creating for every instance
  • map, list, set initializers didn't work tests:
  • use generated Work and CalculateArgs
Aleksey Pesternikov lot of changes including:
library:
- thrift's BYTE type is signed (so it is int8, not byte)
- asynchronous protocol is removed as irrelevant in go
code generation:
- safer constants using typed vars
- int64 consts over 2^32 dont blow up
- negative byte consts
- generated struct doesn't include type metainformation field to avoid metainfo creating for every instance
- map, list, set initializers didn't work
tests:
- use generated Work and CalculateArgs
d67b4c0
@pomack
Owner
pomack commented Feb 19, 2013

Wow, thanks Aleksey! I don't have time to look through this for the next couple of weeks and I definitely want to take a good look to understand all the changes. I'll try to find some time at the beginning of March.

@apesternikov

sure. I hope I will have my other planned things done by that time. (I started short summary here https://github.com/apesternikov/thrift4go/wiki/Roadmap)

Aleksey Pest... and others added some commits Feb 19, 2013
Aleksey Pesternikov restore tnonblocking_*. it need some better name because it is not ab…
…out nonblocking socket
abd4244
Aleksey Pesternikov code generation:
lists are native (TList -> []elemtype)
maps are native (TMap -> map[keytype]valtype) native types including binary are supported as key type
sets are native (TSet -> map[valtype]bool
optimized struct's Read function
library:
removed types not present in thrift protocol spec
removed Tlist, TSet, TMap, TCompare, all data coercing fun from ttype.go
added TDebugProtocol
0e9a8f9
Aleksey Pesternikov enable disabled test f61e922
Aleksey Pesternikov tests are moved to avoid package namespace pollution 7eaea02
Aleksey Pesternikov Generated code:
ReadFieldN -> readFieldN
remove ReadFieldFIELDNAME
WriteFieldN -> writeFieldN
remove WriteFieldFIELDNAME
445776b
@sdming
sdming commented Mar 12, 2013

it's cool, I tried apesternikov/thrift4go, but i got error when generate code for Hbase thrift api, it stoped at code:
type TRowResult struct {
Row Text "row"; // 1

@sdming
sdming commented Mar 12, 2013

bug of TlLIst, it break when i=0

if len(p.l) >= i {
p.l[i] = data
} else {
p.l = append(p.l, data)
}

Aleksey Pesternikov typedef'd key type 5a69f8c
@apesternikov

sdming,
compiler is fixed, it would be great if you try and tell us how it works.

@sdming
sdming commented Mar 13, 2013

still can not compile Hbase thrift interface

error happen at the logic to handle key of map

you can download hbase thrift interface from http://wiki.apache.org/hadoop/Hbase/ThriftApi

@sdming
sdming commented Mar 13, 2013

type Text []byte

you make a map map[string]XXX

but you set value with
map[Text] = xxx

Aleksey Pesternikov Hbase compilation 7da5ba8
@apesternikov

sorry, I forgot to commit my last changes. please test

@sdming
sdming commented Mar 18, 2013

still many errors

an example

type TRegionInfo struct {
...
Version int8 "version" // 5
...
}

func (p *TRegionInfo) readField5(iprot thrift.TProtocol) {
...
v30, err31 := iprot.ReadByte()

p.Version = v30
...
}

...
cannot use v30 (type byte) as type int8 in assignment
...

@apesternikov

sdming, please make sure that your library is up to date. please update it with
go get -u github.com/apesternikov/thrift4go/lib/go/src/thrift

ReadByte() returns int8:
https://github.com/apesternikov/thrift4go/blob/master/lib/go/src/thrift/tprotocol.go#L65

and this is one of the changes from the original library:
https://github.com/pomack/thrift4go/blob/master/lib/go/src/thrift/tprotocol.go#L65

@sdming
sdming commented Mar 19, 2013

it's strange, go get -u does not work, but git clone works fine

@tmc

Wouldn't this code be best removed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.