Re: [protobuf] Re: uni64 data to uint32 unit time

2010-04-19 Thread Kenton Varda
On Mon, Apr 19, 2010 at 7:51 AM, ikalbeniz  wrote:

> i have used this API to access to android market:
>
> http://code.google.com/p/android-market-api/ (uses google-protobuff-
> api)
>

Note that the android-market-api project is not from or authorized by
Google.  It looks like they reverse-engineered the protocol.  You might want
to verify that the android market terms of service allow this (I have no
idea if they do or not).


> i have get all the comments from an app and i get that one of the
> comments date is 1269450764071 (the one from ikalbeniz)
>
> in my custom class all the HTTP protocol is developed and works ok but
> when i get the comments data i don know how ti parse some params..
>
> here the comments http response data:
>
> http://i43.tinypic.com/igxp52.jpg
>
> here the proto of the comment taken from android-market-api
>
> message Comment {
>optional string text = 1;
>optional int32 rating = 2;
>optional string authorName = 3;
>optional uint64 creationTime = 4;
>optional string authorId = 5;
> }
>
> i have underlined the bytestring that represents "uint64 creationTime"
> but the android-market-api when i get the creationtime the result is
> 1269450764071.. i have been searching on android-market-api code but i
> have not get any clear info so i have supposed that the conversion is
> made by google-protobuff-api
>

As Marc points out, uint64 is a varint-encoded type.  You have highlighted 7
bytes in your screenshot, and you gave 8 bytes in your original e-mail, but
only the first *six* of these bytes are the actual number (varint-encoded)
-- the bytes after that are part of the next field.  It sounds like the PHP
protobuf implementation you are using may have a bug in the decoder.


>
>
> On 19 abr, 16:40, Kenton Varda  wrote:
> > AFAICT the bytes you gave do, in fact, decode to 1453014483955211943.
>  Where
> > did the 1269450764071 result come from?  Is that from decoding the exact
> > same protocol buffer in Java, or from some other higher-level Java API?
> >
> >
> >
> > On Mon, Apr 19, 2010 at 7:31 AM, ikalbeniz  wrote:
> > > Hi,
> >
> > > I am developing a custom (and more simple) protobuff class for php.
> > > The problem I have is with date format that is stored as uint64. For
> > > example in a stream I have get from google Iknow that the “creation
> > > time” is satored in a bytearray with A7-DE-A5-89-F9-24-2A-14 if I
> > > convert this to uint64 I get this number 1453014483955211943 but I
> > > know (using java appi) that the result is 1269450764071.
> >
> > > I do not know how de conversion has been done and if it is posible to
> > > do this in php.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Protocol Buffers" group.
> > > To post to this group, send email to proto...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > protobuf+unsubscr...@googlegroups.com
> 
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/protobuf?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> > To post to this group, send email to proto...@googlegroups.com.
> > To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com
> .
> > For more options, visit this group athttp://
> groups.google.com/group/protobuf?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



[protobuf] Re: uni64 data to uint32 unit time

2010-04-19 Thread ikalbeniz
ok, i have don some test and works!! i dont know why this conversions
are done but works..

On 19 abr, 17:00, Marc Gravell  wrote:
> Now that is amusing (to me, at least); I decode a variant in "calc", and
> then mess up the field number! It is the field with *binary* 101, i.e. field
> 5.
>
> and note also that I'm treating that as an unsigned variant; a signed
> (zig/zag) variant would give a different answer.
>
> On 19 April 2010 15:57, Marc Gravell  wrote:
>
>
>
> > and you process the last 2 bytes separately, of course; it is field 101 of
> > type string (or sub-message or bytes), length 14, with the actual data
> > missing.
>
> > Marc
>
> > On 19 April 2010 15:53, Marc Gravell  wrote:
>
> >> I know it wasn't the core part of the question, but note that BitConverter
> >> isn't especially helpful for protobuf, unless you happen to be dealing with
> >> [s]fixed{32|64} / float / double (it is unclear whether you mean "uint64" 
> >> as
> >> a protobuf type or a language-specific type).
>
> >> Treating it as fixed/unsigned I get: 1453014483955211943
>
> >> Treat it as a variant, though, and you get:
>
> >> (handle continue bits)
> >>             0100100 001 0001001 0100101 100 0100111
> >> (normalize)
> >>             01 00100111 10010001 00101001 0110 00100111
>
> >> = 1269450764071
>
> >> Marc
>
> >> On 19 April 2010 15:34, ikalbeniz  wrote:
>
> >>> here some test i have been doing with c#:
>
> >>>            byte[] data2byte = new byte[8];
> >>>            data2byte[0] = (byte)167;
> >>>            data2byte[1] = (byte)222;
> >>>            data2byte[2] = (byte)165;
> >>>            data2byte[3] = (byte)137;
> >>>            data2byte[4] = (byte)249;
> >>>            data2byte[5] = (byte)36;
> >>>            data2byte[6] = (byte)42;
> >>>            data2byte[7] = (byte)20;
> >>>            Console.WriteLine(BitConverter.ToString(data2byte));
> >>>            Console.WriteLine(BitConverter.ToUInt64(data2byte,0));
> >>>            Console.WriteLine(BitConverter.ToUInt32(data2byte, 0));
> >>>            Console.WriteLine(BitConverter.ToInt64(data2byte, 0));
> >>>            Console.WriteLine(BitConverter.ToInt32(data2byte, 0));
> >>>            UInt64 result = 1269450764071;
> >>>            byte[] resultbyte = BitConverter.GetBytes(result);
> >>>            Console.WriteLine(BitConverter.ToString(resultbyte));
>
> >>> On 19 abr, 16:31, ikalbeniz  wrote:
> >>> > Hi,
>
> >>> > I am developing a custom (and more simple) protobuff class for php.
> >>> > The problem I have is with date format that is stored as uint64. For
> >>> > example in a stream I have get from google Iknow that the “creation
> >>> > time” is satored in a bytearray with A7-DE-A5-89-F9-24-2A-14 if I
> >>> > convert this to uint64 I get this number 1453014483955211943 but I
> >>> > know (using java appi) that the result is 1269450764071.
>
> >>> > I do not know how de conversion has been done and if it is posible to
> >>> > do this in php.
>
> >>> > --
> >>> > You received this message because you are subscribed to the Google
> >>> Groups "Protocol Buffers" group.
> >>> > To post to this group, send email to proto...@googlegroups.com.
> >>> > To unsubscribe from this group, send email to
> >>> protobuf+unsubscr...@googlegroups.com
> >>> .
> >>> > For more options, visit this group athttp://
> >>> groups.google.com/group/protobuf?hl=en.
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "Protocol Buffers" group.
> >>> To post to this group, send email to proto...@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> protobuf+unsubscr...@googlegroups.com
> >>> .
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/protobuf?hl=en.
>
> >> --
> >> Regards,
>
> >> Marc
>
> > --
> > Regards,
>
> > Marc
>
> --
> Regards,
>
> Marc
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to 
> protobuf+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/protobuf?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



Re: [protobuf] Re: uni64 data to uint32 unit time

2010-04-19 Thread Marc Gravell
Now that is amusing (to me, at least); I decode a variant in "calc", and
then mess up the field number! It is the field with *binary* 101, i.e. field
5.

and note also that I'm treating that as an unsigned variant; a signed
(zig/zag) variant would give a different answer.

On 19 April 2010 15:57, Marc Gravell  wrote:

> and you process the last 2 bytes separately, of course; it is field 101 of
> type string (or sub-message or bytes), length 14, with the actual data
> missing.
>
> Marc
>
>
> On 19 April 2010 15:53, Marc Gravell  wrote:
>
>> I know it wasn't the core part of the question, but note that BitConverter
>> isn't especially helpful for protobuf, unless you happen to be dealing with
>> [s]fixed{32|64} / float / double (it is unclear whether you mean "uint64" as
>> a protobuf type or a language-specific type).
>>
>> Treating it as fixed/unsigned I get: 1453014483955211943
>>
>> Treat it as a variant, though, and you get:
>>
>> (handle continue bits)
>> 0100100 001 0001001 0100101 100 0100111
>> (normalize)
>> 01 00100111 10010001 00101001 0110 00100111
>>
>> = 1269450764071
>>
>> Marc
>>
>>
>> On 19 April 2010 15:34, ikalbeniz  wrote:
>>
>>> here some test i have been doing with c#:
>>>
>>>byte[] data2byte = new byte[8];
>>>data2byte[0] = (byte)167;
>>>data2byte[1] = (byte)222;
>>>data2byte[2] = (byte)165;
>>>data2byte[3] = (byte)137;
>>>data2byte[4] = (byte)249;
>>>data2byte[5] = (byte)36;
>>>data2byte[6] = (byte)42;
>>>data2byte[7] = (byte)20;
>>>Console.WriteLine(BitConverter.ToString(data2byte));
>>>Console.WriteLine(BitConverter.ToUInt64(data2byte,0));
>>>Console.WriteLine(BitConverter.ToUInt32(data2byte, 0));
>>>Console.WriteLine(BitConverter.ToInt64(data2byte, 0));
>>>Console.WriteLine(BitConverter.ToInt32(data2byte, 0));
>>>UInt64 result = 1269450764071;
>>>byte[] resultbyte = BitConverter.GetBytes(result);
>>>Console.WriteLine(BitConverter.ToString(resultbyte));
>>>
>>>
>>> On 19 abr, 16:31, ikalbeniz  wrote:
>>> > Hi,
>>> >
>>> > I am developing a custom (and more simple) protobuff class for php.
>>> > The problem I have is with date format that is stored as uint64. For
>>> > example in a stream I have get from google Iknow that the “creation
>>> > time” is satored in a bytearray with A7-DE-A5-89-F9-24-2A-14 if I
>>> > convert this to uint64 I get this number 1453014483955211943 but I
>>> > know (using java appi) that the result is 1269450764071.
>>> >
>>> > I do not know how de conversion has been done and if it is posible to
>>> > do this in php.
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups "Protocol Buffers" group.
>>> > To post to this group, send email to proto...@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> protobuf+unsubscr...@googlegroups.com
>>> .
>>> > For more options, visit this group athttp://
>>> groups.google.com/group/protobuf?hl=en.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Protocol Buffers" group.
>>> To post to this group, send email to proto...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> protobuf+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/protobuf?hl=en.
>>>
>>>
>>
>>
>> --
>> Regards,
>>
>> Marc
>>
>
>
>
> --
> Regards,
>
> Marc
>



-- 
Regards,

Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



Re: [protobuf] Re: uni64 data to uint32 unit time

2010-04-19 Thread Marc Gravell
and you process the last 2 bytes separately, of course; it is field 101 of
type string (or sub-message or bytes), length 14, with the actual data
missing.

Marc

On 19 April 2010 15:53, Marc Gravell  wrote:

> I know it wasn't the core part of the question, but note that BitConverter
> isn't especially helpful for protobuf, unless you happen to be dealing with
> [s]fixed{32|64} / float / double (it is unclear whether you mean "uint64" as
> a protobuf type or a language-specific type).
>
> Treating it as fixed/unsigned I get: 1453014483955211943
>
> Treat it as a variant, though, and you get:
>
> (handle continue bits)
> 0100100 001 0001001 0100101 100 0100111
> (normalize)
> 01 00100111 10010001 00101001 0110 00100111
>
> = 1269450764071
>
> Marc
>
>
> On 19 April 2010 15:34, ikalbeniz  wrote:
>
>> here some test i have been doing with c#:
>>
>>byte[] data2byte = new byte[8];
>>data2byte[0] = (byte)167;
>>data2byte[1] = (byte)222;
>>data2byte[2] = (byte)165;
>>data2byte[3] = (byte)137;
>>data2byte[4] = (byte)249;
>>data2byte[5] = (byte)36;
>>data2byte[6] = (byte)42;
>>data2byte[7] = (byte)20;
>>Console.WriteLine(BitConverter.ToString(data2byte));
>>Console.WriteLine(BitConverter.ToUInt64(data2byte,0));
>>Console.WriteLine(BitConverter.ToUInt32(data2byte, 0));
>>Console.WriteLine(BitConverter.ToInt64(data2byte, 0));
>>Console.WriteLine(BitConverter.ToInt32(data2byte, 0));
>>UInt64 result = 1269450764071;
>>byte[] resultbyte = BitConverter.GetBytes(result);
>>Console.WriteLine(BitConverter.ToString(resultbyte));
>>
>>
>> On 19 abr, 16:31, ikalbeniz  wrote:
>> > Hi,
>> >
>> > I am developing a custom (and more simple) protobuff class for php.
>> > The problem I have is with date format that is stored as uint64. For
>> > example in a stream I have get from google Iknow that the “creation
>> > time” is satored in a bytearray with A7-DE-A5-89-F9-24-2A-14 if I
>> > convert this to uint64 I get this number 1453014483955211943 but I
>> > know (using java appi) that the result is 1269450764071.
>> >
>> > I do not know how de conversion has been done and if it is posible to
>> > do this in php.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Protocol Buffers" group.
>> > To post to this group, send email to proto...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> protobuf+unsubscr...@googlegroups.com
>> .
>> > For more options, visit this group athttp://
>> groups.google.com/group/protobuf?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Protocol Buffers" group.
>> To post to this group, send email to proto...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> protobuf+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/protobuf?hl=en.
>>
>>
>
>
> --
> Regards,
>
> Marc
>



-- 
Regards,

Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



Re: [protobuf] Re: uni64 data to uint32 unit time

2010-04-19 Thread Marc Gravell
I know it wasn't the core part of the question, but note that BitConverter
isn't especially helpful for protobuf, unless you happen to be dealing with
[s]fixed{32|64} / float / double (it is unclear whether you mean "uint64" as
a protobuf type or a language-specific type).

Treating it as fixed/unsigned I get: 1453014483955211943

Treat it as a variant, though, and you get:

(handle continue bits)
0100100 001 0001001 0100101 100 0100111
(normalize)
01 00100111 10010001 00101001 0110 00100111

= 1269450764071

Marc

On 19 April 2010 15:34, ikalbeniz  wrote:

> here some test i have been doing with c#:
>
>byte[] data2byte = new byte[8];
>data2byte[0] = (byte)167;
>data2byte[1] = (byte)222;
>data2byte[2] = (byte)165;
>data2byte[3] = (byte)137;
>data2byte[4] = (byte)249;
>data2byte[5] = (byte)36;
>data2byte[6] = (byte)42;
>data2byte[7] = (byte)20;
>Console.WriteLine(BitConverter.ToString(data2byte));
>Console.WriteLine(BitConverter.ToUInt64(data2byte,0));
>Console.WriteLine(BitConverter.ToUInt32(data2byte, 0));
>Console.WriteLine(BitConverter.ToInt64(data2byte, 0));
>Console.WriteLine(BitConverter.ToInt32(data2byte, 0));
>UInt64 result = 1269450764071;
>byte[] resultbyte = BitConverter.GetBytes(result);
>Console.WriteLine(BitConverter.ToString(resultbyte));
>
>
> On 19 abr, 16:31, ikalbeniz  wrote:
> > Hi,
> >
> > I am developing a custom (and more simple) protobuff class for php.
> > The problem I have is with date format that is stored as uint64. For
> > example in a stream I have get from google Iknow that the “creation
> > time” is satored in a bytearray with A7-DE-A5-89-F9-24-2A-14 if I
> > convert this to uint64 I get this number 1453014483955211943 but I
> > know (using java appi) that the result is 1269450764071.
> >
> > I do not know how de conversion has been done and if it is posible to
> > do this in php.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> > To post to this group, send email to proto...@googlegroups.com.
> > To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com
> .
> > For more options, visit this group athttp://
> groups.google.com/group/protobuf?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>


-- 
Regards,

Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



[protobuf] Re: uni64 data to uint32 unit time

2010-04-19 Thread ikalbeniz
i have used this API to access to android market:

http://code.google.com/p/android-market-api/ (uses google-protobuff-
api)

i have get all the comments from an app and i get that one of the
comments date is 1269450764071 (the one from ikalbeniz)

in my custom class all the HTTP protocol is developed and works ok but
when i get the comments data i don know how ti parse some params..

here the comments http response data:

http://i43.tinypic.com/igxp52.jpg

here the proto of the comment taken from android-market-api

message Comment {
optional string text = 1;
optional int32 rating = 2;
optional string authorName = 3;
optional uint64 creationTime = 4;
optional string authorId = 5;
}

i have underlined the bytestring that represents "uint64 creationTime"
but the android-market-api when i get the creationtime the result is
1269450764071.. i have been searching on android-market-api code but i
have not get any clear info so i have supposed that the conversion is
made by google-protobuff-api


On 19 abr, 16:40, Kenton Varda  wrote:
> AFAICT the bytes you gave do, in fact, decode to 1453014483955211943.  Where
> did the 1269450764071 result come from?  Is that from decoding the exact
> same protocol buffer in Java, or from some other higher-level Java API?
>
>
>
> On Mon, Apr 19, 2010 at 7:31 AM, ikalbeniz  wrote:
> > Hi,
>
> > I am developing a custom (and more simple) protobuff class for php.
> > The problem I have is with date format that is stored as uint64. For
> > example in a stream I have get from google Iknow that the “creation
> > time” is satored in a bytearray with A7-DE-A5-89-F9-24-2A-14 if I
> > convert this to uint64 I get this number 1453014483955211943 but I
> > know (using java appi) that the result is 1269450764071.
>
> > I do not know how de conversion has been done and if it is posible to
> > do this in php.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Protocol Buffers" group.
> > To post to this group, send email to proto...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > protobuf+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/protobuf?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to 
> protobuf+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/protobuf?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



[protobuf] Re: uni64 data to uint32 unit time

2010-04-19 Thread ikalbeniz
here some test i have been doing with c#:

byte[] data2byte = new byte[8];
data2byte[0] = (byte)167;
data2byte[1] = (byte)222;
data2byte[2] = (byte)165;
data2byte[3] = (byte)137;
data2byte[4] = (byte)249;
data2byte[5] = (byte)36;
data2byte[6] = (byte)42;
data2byte[7] = (byte)20;
Console.WriteLine(BitConverter.ToString(data2byte));
Console.WriteLine(BitConverter.ToUInt64(data2byte,0));
Console.WriteLine(BitConverter.ToUInt32(data2byte, 0));
Console.WriteLine(BitConverter.ToInt64(data2byte, 0));
Console.WriteLine(BitConverter.ToInt32(data2byte, 0));
UInt64 result = 1269450764071;
byte[] resultbyte = BitConverter.GetBytes(result);
Console.WriteLine(BitConverter.ToString(resultbyte));


On 19 abr, 16:31, ikalbeniz  wrote:
> Hi,
>
> I am developing a custom (and more simple) protobuff class for php.
> The problem I have is with date format that is stored as uint64. For
> example in a stream I have get from google Iknow that the “creation
> time” is satored in a bytearray with A7-DE-A5-89-F9-24-2A-14 if I
> convert this to uint64 I get this number 1453014483955211943 but I
> know (using java appi) that the result is 1269450764071.
>
> I do not know how de conversion has been done and if it is posible to
> do this in php.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to 
> protobuf+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/protobuf?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.