Re: [protobuf] Re: Import statement semantics

2018-12-04 Thread Josh Humphries
The "public" and "weak" import modifiers are in no way similar to anything
in C++.

A "public" import means that all imported symbols are "transitively"
imported into dependees. It's a little hard to describe, but easier to
understand with an example:

Let's say we have three files.

   1. foo.proto: This file defines message foo.Foo.
   2. bar.proto: This file defines message bar.Bar and imports *public*
"foo.proto".
   3. baz.proto: This imports "bar.proto".

Normally, the import in baz.proto (bullet 3) means that the contents of the
baz.proto file can freely refer to symbols defined in the imported file --
namely, bar.Bar.

However, because the imported file *has public imports (*namely,
foo.proto), it's as if baz.proto imported foo.proto, too. So not only can
baz.proto use the symbols defined in its imports (e.g. bar.proto), *but
also* all of the symbols that are *publicly* imported therein. So, in the
example, the contents of baz.proto (bullet 3) can refer to the symbol
foo.Foo *without * actually importing foo.proto, thanks to the public
import in bar.proto.

Does that make sense? It's like the "public" keyword takes all symbols from
the imported file and adds them to its own set of exported symbols.

There is a brief bit of doc on the main website for public imports. Perhaps
it explains it better than me:
https://developers.google.com/protocol-buffers/docs/proto#importing-definitions


A "weak" import is very different. A weak import is one whose contents are
only *weakly* required. I think the actual implementation varies from
language to language (IIRC, some languages do not even support weak
imports, treating them instead as normal imports). I believe the idea is
that generated code will not have a strong compile-time dependency on the
generated code/library for the imported file. IIUC, fields whose types are
defined in weakly imported files will be treated like unknown fields if the
runtime type is not available (e.g. not linked in).

Despite this being documented

as if supported in the C++ library, I think it's intentionally

 not

supported

in the open-source library (along with lazily-parsed

fields
).
So it's part of the grammar, but perhaps disallowed in practice (or, more
likely, ignored and treated as a normal import).


*Josh Humphries*
jh...@bluegosling.com


On Tue, Dec 4, 2018 at 5:00 PM Michael Powell  wrote:

> On Wed, Nov 7, 2018 at 4:28 PM Michael Powell 
> wrote:
> >
> > Hello,
> >
> > Is there some documentation concerning import semantics?
> >
> > For starters, I assume that you specify the path. This may be further
> > enhanced by specification of an "import path", not unlike in C++
> > wherein you may specify include, library, etc, paths.
>
> I have not received any clarification for this. Can someone please
> clarify? I want to think in terms of C++ access modifiers, private,
> protected, public, etc, but I'm not positive this is analogous, or
> what the ramifications ought to be when "linking" across .proto files.
>
>
> http://developers.google.com/protocol-buffers/docs/reference/proto2-spec#import_statement
>
> > Second, what is the impact of "weak"? "public"? Or an unspecified
> modifier?
> >
> > Thanks!
> >
> > Best regards,
> >
> > Michael Powell
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Re: Import statement semantics

2018-12-04 Thread Michael Powell
On Wed, Nov 7, 2018 at 4:28 PM Michael Powell  wrote:
>
> Hello,
>
> Is there some documentation concerning import semantics?
>
> For starters, I assume that you specify the path. This may be further
> enhanced by specification of an "import path", not unlike in C++
> wherein you may specify include, library, etc, paths.

I have not received any clarification for this. Can someone please
clarify? I want to think in terms of C++ access modifiers, private,
protected, public, etc, but I'm not positive this is analogous, or
what the ramifications ought to be when "linking" across .proto files.

http://developers.google.com/protocol-buffers/docs/reference/proto2-spec#import_statement

> Second, what is the impact of "weak"? "public"? Or an unspecified modifier?
>
> Thanks!
>
> Best regards,
>
> Michael Powell

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] Create proto file in Java

2018-12-04 Thread Derek Perez
Could be extended, patches welcome.

On Tue, Dec 4, 2018 at 2:08 AM X X  wrote:

> Thanks, it`s very helpful. But i need proto2 and proto3. There is only
> proto3.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] Protobuf Binary Size

2018-12-04 Thread 'Adam Cozzette' via Protocol Buffers
For one Android binary I worked on recently, the protobuf runtime used
about 135 KB of space. This was for an ARM build, and I imagine the amount
could vary quite a bit depending on the platform and what runtime code you
end up depending on.

I'm not familiar with that gRPC issue, so you may want to ask the gRPC
folks about that. Does the "stream" modifier prevent you from
setting optimize_for = LITE_RUNTIME in the .proto file?

On Mon, Dec 3, 2018 at 11:05 PM Roy Barda  wrote:

> Thank you Adam for the detailed suggestion.
>
> 1. Can you please let me know what was the addition in KB/MB of protobuf
> usage when you linked it statically to your Android code?
> 2. Using libprotobuf-lite blocks me from using the "stream" modifier
> (streaming feature) in gRPC, anyway to work around it?
>
> Appreciate your help,
> Roy.
>
> On Tuesday, December 4, 2018 at 5:51:57 AM UTC+2, Adam Cozzette wrote:
>>
>> Do you plan to link statically or dynamically against the protobuf
>> library? If you can link against it statically, I think you may find that
>> the linker is able to remove a lot of unused code. For Android (which is an
>> environment where we care a lot about code size), what we generally do is:
>> - Use lite protos only (i.e. set option optimize_for = LITE_RUNTIME in
>> every .proto file)
>> - Link against libprotobuf-lite and not libprotobuf
>> - Pass -ffunction-sections and -fdata-sections to the compiler and
>> -Wl,-gc-sections to the linker to maximize the linker's ability to strip
>> out unused code
>>
>> On Sun, Dec 2, 2018 at 10:34 PM Roy Barda  wrote:
>>
>>> Hi,
>>>
>>> I have build protobuf on my Ubuntu environment and saw that the
>>> libraries size are extremely big.
>>>
>>> 28 MB for libprotobuf.
>>> 4 MB for libprotobuf-lite
>>>
>>> I'm aware of nanopb project but I need to use gRPC with protobuf and
>>> there is no good, working and maintained solution for nanopb.
>>>
>>> I followed the regular build process when I built protobuf (with no
>>> special configuration)
>>>
>>> Is there any way to reduce the protobuf library footprint? We are
>>> looking for a 1MB solution.
>>>
>>> Thanks,
>>>
>>> Roy.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Protocol Buffers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to protobuf+u...@googlegroups.com.
>>> To post to this group, send email to prot...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/protobuf.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] Create proto file in Java

2018-12-04 Thread X X
Thanks, it`s very helpful. But i need proto2 and proto3. There is only proto3.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.