Map in .proto doesn't appear to generate anything

62 views
Skip to first unread message

James Cook

unread,
Aug 4, 2017, 10:47:31 PM8/4/17
to protostuff
Hi All,

I am looking to use a map and it appears in the Protostuff doc's this should be possible


However when I have:

message MyMessage {
 map
<int32, int32> weight = 1;
}


The generated code ignores the field and I end up with an "empty" Schema class, i.e.

public void mergeFrom(Input input, com.me.MyMessage message, int fieldIx) throws IOException {
 
switch (fieldIx) {
 
case FIELD_NONE:
 
return;
 
default:
 input
.handleUnknownField(fieldIx, this);
 
}
}


What am I missing?

David Yu

unread,
Aug 4, 2017, 10:49:47 PM8/4/17
to protostuff
On Sat, Aug 5, 2017 at 9:45 AM, James Cook <cooki...@gmail.com> wrote:
Hi All,

I am looking to use a map and it appears in the Protostuff doc's this should be possible



However when I have:

message MyMessage {
 map
<int32, int32> weight = 1;
}


The generated code ignores the field and I end up with an "empty" Schema class, i.e.

public void mergeFrom(Input input, com.me.MyMessage message, int fieldIx) throws IOException {
 
switch (fieldIx) {
 
case FIELD_NONE:
 
return;
 
default:
 input
.handleUnknownField(fieldIx, this);
 
}
}


What am I missing?

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



--
When the cat is away, the mouse is alone.
dyuproject.com

James Cook

unread,
Aug 5, 2017, 1:17:57 AM8/5/17
to protostuff
Hi David,

Thanks for coming back to me.

Yes I am using io.protostuff.compiler.CompilerMain is that correct? - Also I can't see in the stg files were the map methods are created specified:
  • Map<Integer, Integer> getWeightMap(): Returns an unmodifiable Map.
  • Integer getWeight(Integer key): Returns a value mapped to given key if it exists. If mapping does not exist than returns null.
As per the wiki page.

On Saturday, August 5, 2017 at 10:49:47 AM UTC+8, David Yu wrote:
On Sat, Aug 5, 2017 at 9:45 AM, James Cook <cooki...@gmail.com> wrote:
Hi All,

I am looking to use a map and it appears in the Protostuff doc's this should be possible



However when I have:

message MyMessage {
 map
<int32, int32> weight = 1;
}


The generated code ignores the field and I end up with an "empty" Schema class, i.e.

public void mergeFrom(Input input, com.me.MyMessage message, int fieldIx) throws IOException {
 
switch (fieldIx) {
 
case FIELD_NONE:
 
return;
 
default:
 input
.handleUnknownField(fieldIx, this);
 
}
}


What am I missing?

--
You received this message because you are subscribed to the Google Groups "protostuff" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protostuff+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

James Cook

unread,
Aug 5, 2017, 1:44:17 AM8/5/17
to protostuff
I checked out that other repo.

There are appears to be multiple compilers here.

One in the Protostuff/protostuff repo and another in the repo you linked.

Why is there two? What is the correct one to use?


On Saturday, August 5, 2017 at 10:49:47 AM UTC+8, David Yu wrote:
On Sat, Aug 5, 2017 at 9:45 AM, James Cook <cooki...@gmail.com> wrote:
Hi All,

I am looking to use a map and it appears in the Protostuff doc's this should be possible



However when I have:

message MyMessage {
 map
<int32, int32> weight = 1;
}


The generated code ignores the field and I end up with an "empty" Schema class, i.e.

public void mergeFrom(Input input, com.me.MyMessage message, int fieldIx) throws IOException {
 
switch (fieldIx) {
 
case FIELD_NONE:
 
return;
 
default:
 input
.handleUnknownField(fieldIx, this);
 
}
}


What am I missing?

--
You received this message because you are subscribed to the Google Groups "protostuff" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protostuff+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

David Yu

unread,
Aug 5, 2017, 2:05:41 AM8/5/17
to protostuff
On Sat, Aug 5, 2017 at 1:44 PM, James Cook <cooki...@gmail.com> wrote:
I checked out that other repo.

There are appears to be multiple compilers here.

One in the Protostuff/protostuff repo and another in the repo you linked.

Why is there two? What is the correct one to use?
The wiki you posted is the docs for the link I posted.  Use the one I linked. 
To unsubscribe from this group and stop receiving emails from it, send an email to protostuff+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

James Cook

unread,
Aug 5, 2017, 3:00:57 AM8/5/17
to protostuff
Ah ok!

So what is the compiler that is in the protostuff/protostuff repository?

Should I not be using that one at all?

Reply all
Reply to author
Forward
0 new messages