[protobuf] Re: Problem with java generation when using imports

2011-01-12 Thread Meghana
Thanks for the reply Kenton.

Here's the example -
proto files :

option java_outer_classname = KmObjectProtos;

message KmObject {
optional string id = 1;
optional string eTag = 2;
optional string eTagContents = 3;
optional string cDate = 4;
optional string uDate = 5;
optional bool sysInternal = 6;
}


option java_outer_classname = ArtifactProtos;

import KmObject.proto;

message Artifact {
optional KmObject kmobject = 1;
optional string artifactType = 2;
optional string contentHash = 3;
}

Generated Java -

 // optional .KmObject kmobject = 1;
public static final int KMOBJECT_FIELD_NUMBER = 1;
private boolean hasKmobject;
private KmObject.KmObject kmobject_;
public boolean hasKmobject() { return hasKmobject; }
public KmObject.KmObject getKmobject() { return kmobject_; }


I was expecting it to be KmObjectProtos.KmObject.


On Jan 12, 2:26 am, Kenton Varda ken...@google.com wrote:
 Can you provide a small, self-contained example?

 On Mon, Jan 10, 2011 at 7:13 AM, Meghana meghana.vishwan...@gmail.comwrote:

  Hi,

  I am using imports in my proto files. So, B has an import of A. When I
  generate the java code for B, all references to A are specified as A.A
  i.e. A(dot)A. It does not seem to be picking up the
  java_outer_classname from A.

  Any idea what's going wrong?

  Thanks.

  --
  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] Large message vs. a list message for smaller messages

2011-01-12 Thread Meghana
In the protobuf documentation, it says that protobuf is good for
working with small messages but not messages larger than 1MB in size.
I think that this would still be true if a message was created only to
handle lists of other message types.

For ex.
message A {
  optional int32 a1 = 1;
  optional string a2 = 2;
  optional string a3 = 3;
}

message ListA {
  repeated A a = 1;
}

Would ListA also be considered a large message or will the encoding be
done on each individual A message making it immune to the large
message problem?

-- 
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] Java Newbie Question: Attaching a CodedInputStream to an NIO Socket

2011-01-12 Thread Nader Salehi
Hi Guys,

I have a Java-base TCP server which needs some modification.  It has
to accept messages as CodedInputStream from C++ clients that send
CodedOutputStream.  The server uses NIO class
java.nio.channels.SocketChannel to read from the socket.  What would
be the easiest way to attach a CodedInputStream to this?

Thanks,
Nader

-- 
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: Problem with java generation when using imports

2011-01-12 Thread Kenton Varda
I get:

// optional .KmObject kmobject = 1;
public static final int KMOBJECT_FIELD_NUMBER = 1;
private boolean hasKmobject;
private KmObjectProtos.KmObject kmobject_ =
KmObjectProtos.KmObject.getDefaultInstance();
public boolean hasKmobject() { return hasKmobject; }
public KmObjectProtos.KmObject getKmobject() { return kmobject_; }

On Wed, Jan 12, 2011 at 3:23 AM, Meghana meghana.vishwan...@gmail.comwrote:

 Thanks for the reply Kenton.

 Here's the example -
 proto files :

 option java_outer_classname = KmObjectProtos;

 message KmObject {
optional string id = 1;
optional string eTag = 2;
optional string eTagContents = 3;
optional string cDate = 4;
optional string uDate = 5;
optional bool sysInternal = 6;
 }


 option java_outer_classname = ArtifactProtos;

 import KmObject.proto;

 message Artifact {
optional KmObject kmobject = 1;
optional string artifactType = 2;
optional string contentHash = 3;
 }

 Generated Java -

  // optional .KmObject kmobject = 1;
public static final int KMOBJECT_FIELD_NUMBER = 1;
private boolean hasKmobject;
private KmObject.KmObject kmobject_;
public boolean hasKmobject() { return hasKmobject; }
public KmObject.KmObject getKmobject() { return kmobject_; }


 I was expecting it to be KmObjectProtos.KmObject.


 On Jan 12, 2:26 am, Kenton Varda ken...@google.com wrote:
  Can you provide a small, self-contained example?
 
  On Mon, Jan 10, 2011 at 7:13 AM, Meghana meghana.vishwan...@gmail.com
 wrote:
 
   Hi,
 
   I am using imports in my proto files. So, B has an import of A. When I
   generate the java code for B, all references to A are specified as A.A
   i.e. A(dot)A. It does not seem to be picking up the
   java_outer_classname from A.
 
   Any idea what's going wrong?
 
   Thanks.
 
   --
   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
 protobuf%2bunsubscr...@googlegroups.comprotobuf%252bunsubscr...@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] Issue 250 in protobuf: [PATCH] Maven-plugin does not work with M2Eclipse

2011-01-12 Thread protobuf

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

New issue 250 by adrian.wilkins: [PATCH] Maven-plugin does not work with  
M2Eclipse

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

maven-plugin always expects to add jar files to the classpath for .proto  
files, but when used in Eclipse with M2Eclipse, the classpath can include  
folders.


Patch below clarifies an error message and adds naked directories to  
classpath as well as JAR files, thus working with both M2Eclipse and  
command line.



=== modified  
file 'tools/maven-plugin/src/main/java/com/google/protobuf/maven/AbstractProtocMojo.java'
---  
tools/maven-plugin/src/main/java/com/google/protobuf/maven/AbstractProtocMojo.java	 
2009-02-10 18:34:50 +
+++  
tools/maven-plugin/src/main/java/com/google/protobuf/maven/AbstractProtocMojo.java	 
2010-12-30 22:08:25 +

@@ -191,29 +191,32 @@
 }
 SetFile protoDirectories = newHashSet();
 for (File classpathElementFile : classpathElementFiles) {
-  checkArgument(classpathElementFile.isFile(), %s is not a file,
-  classpathElementFile);
-  // create the jar file. the constructor validates.
-  JarFile classpathJar = null;
-  try {
-classpathJar = new JarFile(classpathElementFile);
-  } catch (IOException e) {
-throw new IllegalArgumentException(format(
-%s was not a readable artifact, classpathElementFile));
-  }
-  for (JarEntry jarEntry : list(classpathJar.entries())) {
-final String jarEntryName = jarEntry.getName();
-if (jarEntry.getName().endsWith(PROTO_FILE_SUFFIX)) {
-  final File uncompressedCopy =
-  new File(new File(temporaryProtoFileDirectory, classpathJar
-  .getName()), jarEntryName);
-  uncompressedCopy.getParentFile().mkdirs();
-  copyStreamToFile(new RawInputStreamFacade(classpathJar
-  .getInputStream(jarEntry)), uncompressedCopy);
-  protoDirectories.add(uncompressedCopy);
-}
-  }
-
+
+   if(classpathElementFile.isDirectory()) {
+ protoDirectories.add(classpathElementFile);
+  } else {
+   
+ // create the jar file. the constructor validates.
+ JarFile classpathJar = null;
+ try {
+   classpathJar = new JarFile(classpathElementFile);
+ } catch (IOException e) {
+   throw new IllegalArgumentException(format(
+   %s was not a readable artifact, classpathElementFile));
+ }
+ for (JarEntry jarEntry : list(classpathJar.entries())) {
+   final String jarEntryName = jarEntry.getName();
+   if (jarEntry.getName().endsWith(PROTO_FILE_SUFFIX)) {
+ final File uncompressedCopy =
+ new File(new File(temporaryProtoFileDirectory, 
classpathJar
+ .getName()), jarEntryName);
+ uncompressedCopy.getParentFile().mkdirs();
+ copyStreamToFile(new RawInputStreamFacade(classpathJar
+ .getInputStream(jarEntry)), uncompressedCopy);
+ protoDirectories.add(uncompressedCopy.getParentFile());
+   }
+ }
+  }
 }
 forceDeleteOnExit(temporaryProtoFileDirectory);
 return ImmutableSet.copyOf(protoDirectories);

=== modified  
file 'tools/maven-plugin/src/main/java/com/google/protobuf/maven/Protoc.java'
--- tools/maven-plugin/src/main/java/com/google/protobuf/maven/Protoc.java	 
2009-02-10 18:34:50 +
+++ tools/maven-plugin/src/main/java/com/google/protobuf/maven/Protoc.java	 
2010-12-30 22:08:25 +

@@ -174,8 +174,9 @@
  * directory.
  */
 public Builder addProtopathElement(File protopathElement) {
-  checkNotNull(protopathElement);
-  checkArgument(protopathElement.isDirectory());
+  checkNotNull(protopathElement, path element is null);
+  checkArgument(protopathElement.isDirectory(),
+ String.format(%1$s is not a directory, protopathElement));
   protopathElements.add(protopathElement);
   return 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.



[protobuf] Re: Issue 119 in protobuf: TYPE_BOOL collides with MacOS macro

2011-01-12 Thread protobuf


Comment #4 on issue 119 by dgivone: TYPE_BOOL collides with MacOS macro
http://code.google.com/p/protobuf/issues/detail?id=119

Could we rename the FieldType values to FIELDTYPE_* instead of TYPE_*.   
This would also be more consistent with the WireType and CppType enums.


--
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] Java Newbie Question: Attaching a CodedInputStream to an NIO Socket

2011-01-12 Thread Evan Jones

On Jan 12, 2011, at 12:57 , Nader Salehi wrote:

I have a Java-base TCP server which needs some modification.  It has
to accept messages as CodedInputStream from C++ clients that send
CodedOutputStream.  The server uses NIO class
java.nio.channels.SocketChannel to read from the socket.  What would
be the easiest way to attach a CodedInputStream to this?


I created a really thin InputStream implementation that wrapped my NIO  
ByteBuffer(s), then use CodedInputStream.newInstance(InputStream  
stream). You really only need to implement the read(byte[]  
destination, int offset, int length) method of this class, so it is  
actually pretty straightforward. There might be a better way but it  
works for me. 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 protobuf@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] Large message vs. a list message for smaller messages

2011-01-12 Thread Evan Jones

On Jan 12, 2011, at 8:38 , Meghana wrote:

Would ListA also be considered a large message or will the encoding be
done on each individual A message making it immune to the large
message problem?


ListA itself will be a large message if it contains a large message of  
a sub-messages. If you are really sending / writing a large number of  
messages, you want to read something like:


http://code.google.com/apis/protocolbuffers/docs/techniques.html#streaming

Good luck,

Evan Jones

--
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 protobuf@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] Java Newbie Question: Attaching a CodedInputStream to an NIO Socket

2011-01-12 Thread Nader Salehi
On 1/13/2011 00:56 Evan Jones writes:
 On Jan 12, 2011, at 12:57 , Nader Salehi wrote:
  I have a Java-base TCP server which needs some modification.  It has
  to accept messages as CodedInputStream from C++ clients that send
  CodedOutputStream.  The server uses NIO class
  java.nio.channels.SocketChannel to read from the socket.  What would
  be the easiest way to attach a CodedInputStream to this?
 
 I created a really thin InputStream implementation that wrapped my NIO  
 ByteBuffer(s), then use CodedInputStream.newInstance(InputStream  
 stream). You really only need to implement the read(byte[]  
 destination, int offset, int length) method of this class, so it is  
 actually pretty straightforward. There might be a better way but it  
 works for me. Hope this helps,

It does help.  However, I seem to have some problem reading messages
that way.  My guess is that it has something to do with the fact that
the channels are non-blocking.  Is there any special thing to consider
when working with such channels?

Nader

 
 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 protobuf@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 deal with the byte 0xFF in the business logic?

2011-01-12 Thread 飞 杨
Dear sir,

I found, in the protocolbuf int encode, the byte 0xFF may appear, then
how can i distinguish the EOS and the business -1, the two both are -1
when use the inputstream.read()..
i my sense, -1 shouldn't appear in the business logic if use UTF-8
encode as -1 means the end of the stream and goodbye, but protocolbuf
does...
any suggestion?

Regards,
Youngphy

-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To post to this group, send email to protobuf@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.