Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation failure with multiple nested messages #2

Open
jdillon opened this issue Nov 1, 2012 · 0 comments
Open

Compilation failure with multiple nested messages #2

jdillon opened this issue Nov 1, 2012 · 0 comments

Comments

@jdillon
Copy link

jdillon commented Nov 1, 2012

Hawtbuf fails to compile this:

// Zapper
package org.sonatype.spice.zapper.internal.protocol;
option java_multiple_files = true;
// reused messages
message Hash {
required string hashAlg = 1; // segment hash algorithm identifier
required bytes hashBytes = 2; // segment hash content (as bytes)
}
// vvv Recipe vvv
// transfer message
message TransferMessage {
required string magic = 1 [default = "zRec"]; // transfer "magic"
required string transferId = 2; // transfer ID
required int64 transferTotalSize = 3; // transfer total "original" size (in bytes)
message File {
required string fileId = 1; // file ID
required string path = 2; // file path
required int64 fileLastModified = 3; // file last modified
repeated Hash hashes = 4; // list of known file hashes
repeated string filters = 5; // optionally, filters applied to file body as whole (in order)
}
repeated File files = 10; // the list of files
}
// segment message
message SegmentsMessage {
required string magic = 1 [default = "zSeg"]; // segments "magic"
required string transferId = 2; // transfer ID
message Segment {
required string segmentId = 1; // segment ID
required int64 offset = 2; // segment offset from file beginning
required int64 length = 3; // segment length
}
message FileSegments {
required string fileId = 1; // file ID
repeated Segment segments = 2; // segments in order needed to reassemble the original
}
repeated FileSegments fileSegments = 10; // the list of file segments
}
// ^^^ Recipe ^^^
// prepended to each segment, followed by (count) bytes of body, and again (or track ends)
message SegmentHeader {
required string magic = 1 [default = "zSeh"]; // segment "magic"
required string fileId = 2; // file ID
required string segmentId = 3; // segment ID
required int64 segmentOffset = 4; // segment offset (in bytes) in final file
required int64 segmentLength = 5; // segment length (in bytes) in final file
repeated string filters = 6; // optionally, filters applied to segment body (in order)
}
// appended to each segment
message SegmentFooter {
required string magic = 1 [default = "zSef"]; // segment "magic"
repeated Hash hashes = 2; // list of known segment hashes
}

Fails with:

[ERROR] Protocol Buffer Compiler failed with the following error(s):
[ERROR]
[ERROR] Field type not found: Segment
[ERROR]

If I change it to not use nested messages, then its happy:


// Zapper

package org.sonatype.spice.zapper.internal.hawtbuf;

option java_multiple_files = true;

// reused messages
message Hash {
  required string hashAlg = 1; // segment hash algorithm identifier
  required bytes hashBytes = 2; // segment hash content (as bytes)
}

// vvv Recipe vvv

message File {
  required string fileId = 1; // file ID
  required string path = 2; // file path
  required int64 fileLastModified = 3; // file last modified
  repeated Hash hashes = 4; // list of known file hashes
  repeated string filters = 5; // optionally, filters applied to file body as whole (in order)
}

// transfer message
message TransferMessage {
  required string magic = 1 [default = "zRec"]; // transfer "magic"
  required string transferId = 2; // transfer ID
  required int64 transferTotalSize = 3; // transfer total "original" size (in bytes)

  repeated File files = 10; // the list of files
}

message Segment {
  required string segmentId = 1; // segment ID
  required int64 offset = 2; // segment offset from file beginning
  required int64 length = 3; // segment length
}

message FileSegments {
  required string fileId = 1; // file ID
  repeated Segment segments = 2; // segments in order needed to reassemble the original
}

// segment message
message SegmentsMessage {
  required string magic = 1 [default = "zSeg"]; // segments "magic"
  required string transferId = 2; // transfer ID

  repeated FileSegments fileSegments = 10; // the list of file segments
}

// ^^^ Recipe ^^^

// prepended to each segment, followed by (count) bytes of body, and again (or track ends)
message SegmentHeader {
  required string magic = 1 [default = "zSeh"]; // segment "magic"
  required string fileId = 2; // file ID
  required string segmentId = 3; // segment ID
  required int64 segmentOffset = 4; // segment offset (in bytes) in final file
  required int64 segmentLength = 5; // segment length (in bytes) in final file
  repeated string filters = 6; // optionally, filters applied to segment body (in order)
}

// appended to each segment
message SegmentFooter {
  required string magic = 1 [default = "zSef"]; // segment "magic"
  repeated Hash hashes = 2; // list of known segment hashes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant