[protobuf] Re: Message missing required fields exception when parsing a message that has required fields defaulted

2010-10-26 Thread locky
Hi Paul.

Apologies for the message definition.  It was a typo and should have
read like so...

message StringTestProto {
  required string property = 1;
}

The C++ side is setting things correctly.  My understanding is that
default values are not sent over the wire.  When building a received
message from a byte[ ] a check is done to see if required fields have
been set.  Any required field that was not sent due to having a
default value on the other side is not marked as being set and the
exception gets thrown.

Any ideas or further input appreciated.

On Oct 25, 5:53 pm, Paul mjpabl...@gmail.com wrote:
 I've gotten this message for reasons other than the field not being
 set.  make sure that you have the number of bytes on the delimiters
 set correctly on the C++ side.  also, maybe stringProperty should be
 string Property (two words).

 On Oct 22, 9:12 am, locky true.n...@gmail.com wrote:

  I have a question regarding required string properties and default
  values.

  Consider the following message definition.

  message StringTestProto {
    required stringProperty = 1;

  }

  I have a C++/Java setup where C++ app is producing a message and a
  Java app is consuming it.

  If the stringProperty value is set to an empty string I get the
  following exception when trying to parse the
  message once I receive it in the the Java app.

  com.google.protobuf.InvalidProtocolBufferException: Message missing
  required fields:

  The message is being read as follows:

  StringTestProto proto = StringTestProto.parseFrom(data);

  From what I can see the issue is as follows:
  As the stringProperty value is the same as the default (an empty
  string) it is not sent over the wire.  When the generated Java code
  tries to build the proto from a byte[ ] (in the buildFrom method), a
  check is done to see if the proto is initialised, this check sees if
  the required fields have been set.  As the stringProperty was never
  sent, the proto does not think it has been set (as it never was) and
  therefore the exception is thrown.

  So, how are you supposed to decode a byte[] that contains required
  properties, that may have default values?

-- 
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] protocol buffer within a protocol buffer from C++ to Java

2010-10-26 Thread Evan Jones

On Oct 25, 2010, at 21:45 , Paul wrote:

 optional string meas_rec_str = 2;


Change this to:

optional bytes meas_rec_str = 2;

Evan

--
Evan Jones
http://evanjones.ca/

--
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: Message missing required fields exception when parsing a message that has required fields defaulted

2010-10-26 Thread Evan Jones

On Oct 26, 2010, at 4:13 , locky wrote:

The C++ side is setting things correctly.  My understanding is that
default values are not sent over the wire.  When building a received
message from a byte[ ] a check is done to see if required fields have
been set.  Any required field that was not sent due to having a
default value on the other side is not marked as being set and the
exception gets thrown.


This is exactly correct. You should do two things:

1. Set this field on the sending side, but you mentioned that you are  
already doing this.


2. Verify that the bytes you are reading in on one side match the  
bytes being sent. I usually get this error when there is some sort of  
message handling error. For example, if you pass protobuf an empty  
array, you'll get this error message. You should write out the bytes  
that you are writing, and the bytes that you are reading and verify  
that they match. Also verify that the size you are passing in matches.


There is a difference between an unset field with a default value of  
 and a set field with a value of . The .hasProperty() method will  
return true for the set field, and false for the unset field. Thus,  
these messages are serialized differently.


Hope this helps,

Evan

--
Evan Jones
http://evanjones.ca/

--
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: protocol buffer within a protocol buffer from C++ to Java

2010-10-26 Thread Paul
ok thanks.  changing to optional bytes worked.  also, instead of
parseFrom, I ended up using parseDelimitedFrom on the Java side, after
serializing with SerializeToCodedStream on the C++ side.

On Oct 26, 4:59 am, Evan Jones ev...@mit.edu wrote:
 On Oct 25, 2010, at 21:45 , Paul wrote:

   optional string meas_rec_str = 2;

 Change this to:

 optional bytes meas_rec_str = 2;

 Evan

 --
 Evan Joneshttp://evanjones.ca/

-- 
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] including common message definitions across .proto files

2010-10-26 Thread Paul
Hi,
Suppose I have two files, file1.proto and file2.proto, and I have a
message defined in file1 that I want to use in file2.  How would I
include the message from file1?  Is there an include statement I
would use as in C or C++?

 file1.proto 
message M1 {
   optional string id = 1;
}

 file2.proto 
message M2 {
  optional string id = 1;
  optional M1 m1;   // how do I include this?
}

-- 
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] including common message definitions across .proto files

2010-10-26 Thread Henner Zeller
On Tue, Oct 26, 2010 at 11:29, Paul mjpabl...@gmail.com wrote:
 Hi,
 Suppose I have two files, file1.proto and file2.proto, and I have a
 message defined in file1 that I want to use in file2.  How would I
 include the message from file1?  Is there an include statement I
 would use as in C or C++?

'import' is the thing you're looking for.

http://code.google.com/apis/protocolbuffers/docs/proto.html#other


  file1.proto 
 message M1 {
   optional string id = 1;
 }

  file2.proto 
 message M2 {
  optional string id = 1;
  optional M1 m1;   // how do I include this?
 }

 --
 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: including common message definitions across .proto files

2010-10-26 Thread Paul
got it, thanks.

On Oct 26, 11:33 am, Henner Zeller henner.zel...@googlemail.com
wrote:
 On Tue, Oct 26, 2010 at 11:29, Paul mjpabl...@gmail.com wrote:
  Hi,
  Suppose I have two files, file1.proto and file2.proto, and I have a
  message defined in file1 that I want to use in file2.  How would I
  include the message from file1?  Is there an include statement I
  would use as in C or C++?

 'import' is the thing you're looking for.

 http://code.google.com/apis/protocolbuffers/docs/proto.html#other



   file1.proto 
  message M1 {
    optional string id = 1;
  }

   file2.proto 
  message M2 {
   optional string id = 1;
   optional M1 m1;   // how do I include this?
  }

  --
  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] Generic Message Dispatch and Message Handler

2010-10-26 Thread maninder batth
Is any one aware of a Sample code that would allow messages to be
dispatched in a generic fashion on the client side and  receive and
locate the correct Message Handler on the server side in Java, given
client and server are remote.
I have a naive approach as follow

message AParticularRequest {
 // fields
required string messageType = x;
}

Using Message interface, i can write any Message to bytes and send
over the network.

On Client Side,
My generic Handler would create a GeneratedMessage and look for the
field messageType. Based on the value of the messageType, a particular
handler will be invoked.

I am wondering if there are better approaches out there.

-- 
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] How to import protocol buffer definitions from another Python package?

2010-10-26 Thread Sancho
I have my directory structure like this:

root/
  sift/
__init__.py
sift_descriptors.proto
sift_descriptors_pb2.py
  project/
__init__.py
filtered_descriptors.proto
filtered_descriptors_pb2.py
filtered_descriptors_test.py
The root directory is in my $PYTHONPATH.

I build root/sift/sift_descriptors_pb2.py using protoc --python_out=./
sift_descriptors.proto

I build root/project/filtered_descriptors_pb2.py using /cs/public/lib/
pkg/protobuf/bin/protoc --proto_path=../sift --proto_path=./ --
python_out=./ filtered_descriptors.proto

In filtered_descriptors.proto, I use import sift_descriptors.proto

The problem is that in filtered_descriptors_pb2.py, there's a
statement that just does this bare import: import
sift_descriptors_pb2.py, without reference via the module name as
would be needed: from sift import sift_descriptors_pb2.py.

What am I doing wrong?

-- 
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: How to import protocol buffer definitions from another Python package?

2010-10-26 Thread Sancho
Sorry, transcription error... I meant import sift_descriptors_pb2
where I wrote import sift_descriptors_pb2.py both times.

On Oct 26, 12:58 pm, Sancho sanc...@gmail.com wrote:
 I have my directory structure like this:

 root/
   sift/
     __init__.py
     sift_descriptors.proto
     sift_descriptors_pb2.py
   project/
     __init__.py
     filtered_descriptors.proto
     filtered_descriptors_pb2.py
     filtered_descriptors_test.py
 The root directory is in my $PYTHONPATH.

 I build root/sift/sift_descriptors_pb2.py using protoc --python_out=./
 sift_descriptors.proto

 I build root/project/filtered_descriptors_pb2.py using /cs/public/lib/
 pkg/protobuf/bin/protoc --proto_path=../sift --proto_path=./ --
 python_out=./ filtered_descriptors.proto

 In filtered_descriptors.proto, I use import sift_descriptors.proto

 The problem is that in filtered_descriptors_pb2.py, there's a
 statement that just does this bare import: import
 sift_descriptors_pb2.py, without reference via the module name as
 would be needed: from sift import sift_descriptors_pb2.py.

 What am I doing wrong?

-- 
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: How to import protocol buffer definitions from another Python package?

2010-10-26 Thread Sancho
Nevermind! I fixed it...

The solution was to use import sift/sift_descriptors.proto in
filtered_descriptors.proto, and then point protoc to --proto_path=../
instead of --proto_path=../sift.
Then, protoc generates python code that does the import as import
sift.sift_descriptors_pb2.

This isn't explained well in the documentation. How can I help write
something?

On Oct 26, 1:03 pm, Sancho sanc...@gmail.com wrote:
 Sorry, transcription error... I meant import sift_descriptors_pb2
 where I wrote import sift_descriptors_pb2.py both times.

 On Oct 26, 12:58 pm, Sancho sanc...@gmail.com wrote:



  I have my directory structure like this:

  root/
    sift/
      __init__.py
      sift_descriptors.proto
      sift_descriptors_pb2.py
    project/
      __init__.py
      filtered_descriptors.proto
      filtered_descriptors_pb2.py
      filtered_descriptors_test.py
  The root directory is in my $PYTHONPATH.

  I build root/sift/sift_descriptors_pb2.py using protoc --python_out=./
  sift_descriptors.proto

  I build root/project/filtered_descriptors_pb2.py using /cs/public/lib/
  pkg/protobuf/bin/protoc --proto_path=../sift --proto_path=./ --
  python_out=./ filtered_descriptors.proto

  In filtered_descriptors.proto, I use import sift_descriptors.proto

  The problem is that in filtered_descriptors_pb2.py, there's a
  statement that just does this bare import: import
  sift_descriptors_pb2.py, without reference via the module name as
  would be needed: from sift import sift_descriptors_pb2.py.

  What am I doing wrong?

-- 
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] Issue 229 in protobuf: TextFormat should have option to silently ignore unknown fields

2010-10-26 Thread protobuf

Status: New
Owner: ken...@google.com
Labels: Type-Defect Priority-Medium

New issue 229 by a...@amazon.com: TextFormat should have option to silently  
ignore unknown fields

http://code.google.com/p/protobuf/issues/detail?id=229

What steps will reproduce the problem?
1. Add an unknown field to a TextFormat file.
2. Try merging the file with your Message.
3. Get an exception indicating unknown field.

What is the expected output? What do you see instead?
This is expected, but I believe protobufs should offer an option of  
silently ignoring these errors.


What version of the product are you using? On what operating system?
Trunk

Please provide any additional information below.

Right now protobufs are a great way to keep services running with an  
evolving data schema. You can update the schema with optional fields and  
existing code continues to work... unless you use TextFormat. TextFormat  
throws a wrench in the plan of data evolution. When you try to merge a  
String of TextFormat data into a Message and the String has fields that  
don't exist in the Message, then TextFormat throws an exception. I think  
TextFormat should be modified to optionally not throw an exception in this  
case since it is normal when evolving data.



--
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] Message vs MessageLite

2010-10-26 Thread Alsmom2005
Hi all,

Is it ok if the serialization is made using libprotobuf library and
the deserialization (on the other end) is made using code built with
libprotobuf-lite library ? That meaning 2 .proto files (the only
difference bw those two file is that one contains 'option optimize_for
= LITE_RUNTIME') .

Thank you in advance!

-- 
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] Message vs MessageLite

2010-10-26 Thread Daniel Wright
Yes -- the serialized format is identical.

On Tue, Oct 26, 2010 at 2:56 PM, Alsmom2005 gundanu...@gmail.com wrote:

 Hi all,

 Is it ok if the serialization is made using libprotobuf library and
 the deserialization (on the other end) is made using code built with
 libprotobuf-lite library ? That meaning 2 .proto files (the only
 difference bw those two file is that one contains 'option optimize_for
 = LITE_RUNTIME') .

 Thank you in advance!

 --
 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.comprotobuf%2bunsubscr...@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: Issue 229 in protobuf: TextFormat should have option to silently ignore unknown fields

2010-10-26 Thread protobuf

Updates:
Status: WorkingAsIntended

Comment #1 on issue 229 by ken...@google.com: TextFormat should have option  
to silently ignore unknown fields

http://code.google.com/p/protobuf/issues/detail?id=229

This has come up before.  Copied from a previous answer:

Text format is designed for communicating with people whereas binary format  
is for communicating with machines. People make mistakes, like spelling  
errors. These mistakes should be caught, not silently ignored. Therefore,  
text format is NOT designed with the same forward- and  
backward-compatibility properties as the binary format, and should not be  
used when such compatibility is desired.


If you find yourself wanting to ignore unknown fields when parsing a  
text-format message, most likely you should be using binary format instead.  
One common use case of this is config files that are distributed to  
production machines where some of those machines may be older and not know  
about newly-added fields. In this case, what you should do is distribute  
these configs as binary messages. You can still edit them in text format,  
but then you should invoke protoc with --encode to produce a binary file  
for distribution. Since you give protoc the newest version of the .proto  
file, it will not need to ignore any fields. Remember that you can always  
use protoc --decode to convert back to text.


--
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: Issue 228 in protobuf: Python reading text_format misses empty extension field

2010-10-26 Thread protobuf

Updates:
Status: Accepted

Comment #2 on issue 228 by ken...@google.com: Python reading text_format  
misses empty extension field

http://code.google.com/p/protobuf/issues/detail?id=228

(No comment was entered for this change.)

--
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] Compiling with Rtools

2010-10-26 Thread Kenton Varda
I'm not sure if the Rprotobuf people read this list.  You might look to see
if they have their own mailing list or contact address.

On Wed, Oct 20, 2010 at 1:39 PM, Travis bacch...@gmail.com wrote:

 Hello all,

 I'm trying to load/save protobuf format data directly in R, so writing
 a R external function in C++. As visual studio doesn't support this
 usage, I have to compile the code with Rtools (which is essentially
 mingw and cygwin). However, when I try to compile it, I receive an
 error because of including the protobuf header.

 C:\tR CMD SHLIB test.cpp
 g++ -IC:/PROGRA~1/R/R-211~1.1/include -O2 -Wall  -c test.cpp
 -o test.o
 In file included from c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-
 sjlj/include/c++/bits/locale_facets.h:1536,
 from c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-
 sjlj/include/c++/bits/basic_ios.h:44,
 from c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-
 sjlj/include/c++/ios:50,
 from c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-
 sjlj/include/c++/ostream:45,
 from c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-
 sjlj/include/c++/iterator:70,
 from C:/PROGRA~1/R/R-211~1.1/include/google/protobuf/
 repeated_field.h:50,
 from Person.pb.h:23,
 from test.cpp:5:
 c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/include/c++/bits/
 codecvt.h:219:45: error: macro length passed 4 arguments, but takes
 just 1
 test.cpp:108:4: warning: no newline at end of file
 In file included from c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-
 sjlj/include/c++/bits/locale_facets.h:1536,
 from c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-
 sjlj/include/c++/bits/basic_ios.h:44,
 from c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-
 sjlj/include/c++/ios:50,
 from c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-
 sjlj/include/c++/ostream:45,
 from c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-
 sjlj/include/c++/iterator:70,
 from C:/PROGRA~1/R/R-211~1.1/include/google/protobuf/
 repeated_field.h:50,
 from Person.pb.h:23,
 from test.cpp:5:
 c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/include/c++/bits/
 codecvt.h:218: error: expected ';' before 'const'
 c:\rtools\mingw\bin\../lib/gcc/mingw32/4.2.1-sjlj/include/c++/bits/
 codecvt.h:222: error: expected `;' before 'int'
 In file included from Person.pb.h:24,
 from test.cpp:5:
 C:/PROGRA~1/R/R-211~1.1/include/google/protobuf/extension_set.h:450:
 error: expected identifier before '(' token
 C:/PROGRA~1/R/R-211~1.1/include/google/protobuf/extension_set.h:450:
 error: expected `)' before ',' token
 test.cpp: In function 'void cpp_test(int*, double*, double*, int*,
 double*, double*)':
 make: *** [test.o] Error 1

 The code in codecvt.h:219:45 is :
  int
  length(state_type __state, const extern_type* __from,
 const extern_type* __end, size_t __max) const
  { return this-do_length(__state, __from, __end, __max); }

 The code in include/google/protobuf/extension_set.h:450 is:
int GetSize() const;
void Free();
int SpaceUsedExcludingSelf() const;

 I'm using windows xp sp3, protobuf 2.3.0, g++ (GCC) 4.2.1-sjlj
 (mingw32-2), R version 2.11.1.

 I suspect the reason that protobuf is just not compatible with g++
 version 4.2.1 or the g++ in Rtools is somewhat downgraded version of
 full g++, thus does not match with protobuf.

 Does anyone have same issues / know how to fix this? Thank you!


 --
 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.comprotobuf%2bunsubscr...@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.



Re: [protobuf] New Ruby Protocol Buffers library

2010-10-26 Thread Kenton Varda
I'd like to add this to the third-party wiki, but I'm not sure which link to
use.  Can you suggest (or create) a general-purpose landing page?

On Thu, Oct 21, 2010 at 10:02 AM, Brian Palmer br...@codekitchen.netwrote:

 Mozy has just open sourced their implementation of Protocol Buffers
 for Ruby. The implementation has been in use internally at Mozy for
 over a year. This implementation has put a lot of focus on
 serialization/deserialization performance, and completeness.

 The ruby protobuf compiler calls out to protoc to do the heavy
 lifting, so it's using the same parser as the official compiler. It
 looks like now there's a plugin system for protoc itself, so if we
 were writing this project today we probably would've just made the
 compile-to-ruby functionality a plugin.

 Enjoy!

 The repo: http://github.com/mozy/ruby-protocol-buffers
 The gem: https://rubygems.org/gems/ruby-protocol-buffers
 The docs: http://rubydoc.info/gems/ruby-protocol-buffers/0.8.4/frames

 -- Brian Palmer

 --
 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.comprotobuf%2bunsubscr...@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.



Re: [protobuf] Extensions Management

2010-10-26 Thread Kenton Varda
First of all, I suggest expanding the extension range:
  extensions 1 to max;

This gives you 2^29 numbers to work with (the remaining three bits are
reserved by the wire format to identify types).

Now you can easily assign a large range of extension numbers to each office,
or even to each developer, and they can use them as they see fit.

Or if you just chose numbers randomly, you'd have to have around 10k
extensions before you'd need to start worrying about collisions.

On Mon, Oct 25, 2010 at 12:03 PM, maninder batth
batth.manin...@gmail.comwrote:

 We have a geographically distributed team and instant communications
 are not possible. Given this constraint in mind, i am wondering how to
 manage extensions. To clarify my question, consider a message like
 message Request {
 extensions 1 to 100;
 }

 Different developers would be working on extending Request. For
 example developer A uses the above request in a Client.proto file,
 such as
 extend Request {
 optional int64 clientId = 1;
 }

 Developer B, uses the above request in a Location.proto file such as
 extend Request {
 optional int64 locationId = 1;
 }
 Question is how can developer A and B, extend the message Request,
 without worrying about extension slots being already occupied by some
 other message?
 As shown above, both developers reserved the slot 1, with different Id
 types.

 --
 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.comprotobuf%2bunsubscr...@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.



Re: [protobuf] Message missing required fields exception when parsing a message that has required fields defaulted

2010-10-26 Thread Kenton Varda
On Fri, Oct 22, 2010 at 9:12 AM, locky true.n...@gmail.com wrote:

 From what I can see the issue is as follows:
 As the stringProperty value is the same as the default (an empty
 string) it is not sent over the wire.


No, this is not correct.  Whether or not a value is sent on the wire depends
only on whether or not you explicitly called the setter.  It doesn't matter
if you set it to its default value.  If you called set_property(), the field
will be sent, even if you set it to the empty string.  If you did not call
set_property(), the field will not be sent.  You can call has_property() to
determine whether or not it was set.

I strongly suspect that your code contains some other bug, and the bytes
being received in Java do not actually match the bytes sent from C++.  The
most common problem we see is that people try to store the bytes in a
C-style NUL-terminated string, like:

  std::string str = message.SerializeAsString();
  char* cstr = str.c_str();   // DOES NOT WORK
  send(cstr);  // DOES NOT WORK

The problem is that encoded protobufs contain arbitrary bytes, some of which
may be zero.  A C-style char* string is considered to end at the first
zero byte, but the encoded protobuf may extend beyond that.  You need to use
code like this instead:

  std::string str = message.SerializeAsString();
  send(str.data(), str.size());

-- 
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] protocol buffer within a protocol buffer from C++ to Java

2010-10-26 Thread Kenton Varda
The others answered your main question, but there is another problem:

On Mon, Oct 25, 2010 at 6:45 PM, Paul mjpabl...@gmail.com wrote:

 char* str_buf;
 str_buf = new char[meas_rec.ByteSize()];
 string str = str_buf;


Here you are allocating a char array, and then *copying* it into a
std::string.  This does nothing useful, and it may actually crash depending
on the random contents of the allocated array.

These three lines should be replaced with just:

  string str;

You do not have to resize the string ahead of time, as this is done
automatically by SerializeToString().


 meas_rec.SerializeToString(str);
 m.set_meas_rec_str(str);


Incidentally, another, more efficient way to write this would be:

meas_req.SerializeToString(m.mutable_meas_rec_str());

Also, you probably know this, but just in case:  You can just do:

message Measurement {
 required string id = 1;
 optional MeasRec meas_rec = 2;
}

message MeasRec {
 optional int id = 1;
}

This way you don't have to manually encode the sub-message.

-- 
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: How to import protocol buffer definitions from another Python package?

2010-10-26 Thread Kenton Varda
Right, --proto_path should always point at the root of your source tree,
and all imports should be fully-qualified.

Probably the documentation for import in the language guide should include
a bit more text on this, as it comes up a lot.  If you file a bug I'll
update it when I get time.

Thanks for offering to help, BTW.  Unfortunately our documentation is not in
a repository that can easily be edited from the outside.  This was a mistake
I made when setting up the project, but oh well...

On Tue, Oct 26, 2010 at 1:10 PM, Sancho sanc...@gmail.com wrote:

 Nevermind! I fixed it...

 The solution was to use import sift/sift_descriptors.proto in
 filtered_descriptors.proto, and then point protoc to --proto_path=../
 instead of --proto_path=../sift.
 Then, protoc generates python code that does the import as import
 sift.sift_descriptors_pb2.

 This isn't explained well in the documentation. How can I help write
 something?

 On Oct 26, 1:03 pm, Sancho sanc...@gmail.com wrote:
  Sorry, transcription error... I meant import sift_descriptors_pb2
  where I wrote import sift_descriptors_pb2.py both times.
 
  On Oct 26, 12:58 pm, Sancho sanc...@gmail.com wrote:
 
 
 
   I have my directory structure like this:
 
   root/
 sift/
   __init__.py
   sift_descriptors.proto
   sift_descriptors_pb2.py
 project/
   __init__.py
   filtered_descriptors.proto
   filtered_descriptors_pb2.py
   filtered_descriptors_test.py
   The root directory is in my $PYTHONPATH.
 
   I build root/sift/sift_descriptors_pb2.py using protoc --python_out=./
   sift_descriptors.proto
 
   I build root/project/filtered_descriptors_pb2.py using /cs/public/lib/
   pkg/protobuf/bin/protoc --proto_path=../sift --proto_path=./ --
   python_out=./ filtered_descriptors.proto
 
   In filtered_descriptors.proto, I use import sift_descriptors.proto
 
   The problem is that in filtered_descriptors_pb2.py, there's a
   statement that just does this bare import: import
   sift_descriptors_pb2.py, without reference via the module name as
   would be needed: from sift import sift_descriptors_pb2.py.
 
   What am I doing wrong?

 --
 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.comprotobuf%2bunsubscr...@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.



Re: [protobuf] Message vs MessageLite

2010-10-26 Thread Kenton Varda
Instead of maintaining two identical files, I suggest writing a build rule
that just constructs the lite version from the regular version.  You could
use a make rule like:

my_lite.proto: my.proto
  cp my.proto my_lite.proto
  echo option optimize_for = LITE_RUNTIME;  my_lite.proto

This way the files cannot get out-of-sync.

See also comment 11 in this thread:
http://code.google.com/p/protobuf/issues/detail?id=187#c11

There I provide a protoc plugin which converts inputs to lite mode.  It's a
more complicated approach but less hacky.

On Tue, Oct 26, 2010 at 2:56 PM, Alsmom2005 gundanu...@gmail.com wrote:

 Hi all,

 Is it ok if the serialization is made using libprotobuf library and
 the deserialization (on the other end) is made using code built with
 libprotobuf-lite library ? That meaning 2 .proto files (the only
 difference bw those two file is that one contains 'option optimize_for
 = LITE_RUNTIME') .

 Thank you in advance!

 --
 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.comprotobuf%2bunsubscr...@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.