GithubHelp home page GithubHelp logo

Comments (8)

jhunters avatar jhunters commented on July 2, 2024

FieldType.FIXED32,FieldType.SFIXED32 size应该是固定值4
FieldType.FIXED64,FieldType.SFIXED64 size 应该是固定值8
正是对应上面代码的实现 ,有什么问题吗?

from jprotobuf.

keepinmind9 avatar keepinmind9 commented on July 2, 2024

CodedConstant.computeSize(int order, Object o, FieldType type, boolean list)
这个方法目前只有在对象或List的时候才会调用
这种情况目前测试用例没有覆盖到。

可以试下下面情况会有异常。
@protobuf(fieldType = FieldType.FIXED32, order = 1)
public List idList ;

from jprotobuf.

Baidu-etech avatar Baidu-etech commented on July 2, 2024

可以试下下面情况会有异常。
@protobuf(fieldType = FieldType.FIXED32, order = 1)
public List idList ;

List必须要有泛型。支持List 或List的嵌套方式。

谢谢~


礼!


Matthew

发件人: keepinmind9 [mailto:[email protected]]
发送时间: 2014年12月4日 14:09
收件人: jhunters/jprotobuf
主题: Re: [jprotobuf] CodedConstant.computeSize 错误? (#10)

CodedConstant.computeSize(int order, Object o, FieldType type, boolean list)
这个方法目前只有在对象或List的时候才会调用
这种情况目前测试用例没有覆盖到。

可以试下下面情况会有异常。
@protobuf(fieldType = FieldType.FIXED32, order = 1)
public List idList ;


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-65542258.

from jprotobuf.

keepinmind9 avatar keepinmind9 commented on July 2, 2024

哦,不好意思
发现 List< Integer > 中间如果没有空格,直接显示为了 List :(
可以试下下面情况会有异常。
@protobuf(fieldType = FieldType.FIXED32, order = 1)
public List< Integer > idList ;
序列化的时候报错,其实就是computeSize 错误导致。

from jprotobuf.

Baidu-etech avatar Baidu-etech commented on July 2, 2024

这种情况暂时的确支持不了,不光是序列化,序列化也会有问题。 computeSize必须要知道对象类型才可以,所以只泛型可以约束集合的元素类型。

谢谢~


礼!


Matthew

发件人: keepinmind9 [mailto:[email protected]]
发送时间: 2014年12月4日 16:59
收件人: jhunters/jprotobuf
抄送: rigel-opensource
主题: Re: [jprotobuf] CodedConstant.computeSize 错误? (#10)

哦,不好意思,少帖了类型了
可以试下下面情况会有异常。
@protobuf(fieldType = FieldType.FIXED32, order = 1)
public List idList ;
序列话的时候报错,其实就是computeSize 错误导致。


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-65554377.

from jprotobuf.

keepinmind9 avatar keepinmind9 commented on July 2, 2024

@Baidu-etech 请看我上面回复,是有泛型, 这里 List< Integer > 中间如果没有空格,直接显示为了 List,所以误导了你 .
@protobuf(fieldType = FieldType.FIXED32, order = 1)
public List< Integer > idList ;
序列化的时候 idList 元素 size 其实是4(FieldType.FIXED32),但 生成的代码是调用的
CodedConstant.computeSize(int order, Object o, FieldType type, boolean list)
计算的size
......
else if (type == FieldType.FIXED32 || type == FieldType.INT32 || type == FieldType.SFIXED32
|| type == FieldType.SINT32 || type == FieldType.UINT32) {
size = CodedOutputStream.computeInt32SizeNoTag(Integer.valueOf(o.toString()));
}
......
这里是有问题的。

from jprotobuf.

Baidu-etech avatar Baidu-etech commented on July 2, 2024

看到,这个目前需要升级, 只实现List和List<对象>的方式, 后续我会进行这一块的改进。
目前单测中也只提供了这两种方式的测试

谢谢~


礼!


Matthew

发件人: keepinmind9 [mailto:[email protected]]
发送时间: 2014年12月4日 17:10
收件人: jhunters/jprotobuf
抄送: rigel-opensource
主题: Re: [jprotobuf] CodedConstant.computeSize 错误? (#10)

@Baidu-etechhttps://github.com/Baidu-etech 请看我上面回复,是有泛型, 这里 List< Integer > 中间如果没有空格,直接显示为了 List,所以误导了你 .
@protobuf(fieldType = FieldType.FIXED32, order = 1)
public List< Integer > idList ;
序列化的时候 idList 元素 size 其实是4(FieldType.FIXED32),但 生成的代码是调用的
CodedConstant.computeSize(int order, Object o, FieldType type, boolean list)
计算的size
......
else if (type == FieldType.FIXED32 || type == FieldType.INT32 || type == FieldType.SFIXED32
|| type == FieldType.SINT32 || type == FieldType.UINT32) {
size = CodedOutputStream.computeInt32SizeNoTag(Integer.valueOf(o.toString()));
}
......
这里是有问题的。


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-65555389.

from jprotobuf.

jhunters avatar jhunters commented on July 2, 2024

该问题已修复,修复版本 1.2.6

from jprotobuf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.