Repository navigation
pxf-runtime: ship companions for google.protobuf Any, Struct and kin - #185
Merged
Merged
Conversation
…(protowire#539) A lite schema with a google.protobuf.Any, Empty, FieldMask, Struct, Value or ListValue field did not compile: the generated meta named com.google.protobuf.AnyPxfMeta, which nothing generates. PXF reads these types as ordinary messages, so they need ordinary companions. They now ship in org.protowire.pxf.wkt, generated by protoc-gen-pxf-java-meta from the four google files with only the package changed, and the plugin from trendvidia/protowire#550 points there. Pins the plugin at that branch. GoogleMessagesLiteTest round-trips a field of each type, an Any holding bytes no body could reproduce among them, as #168's lite half asks.
| @Override public Map<Integer, String> enumTypes() { return ENUM_TYPES; } | ||
| @Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; } | ||
| @Override public Map<Integer, String> defaults() { return DEFAULTS; } | ||
| public Set<Integer> nullableFields() { return NULLABLE_FIELDS; } |
| @Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; } | ||
| @Override public Map<Integer, String> defaults() { return DEFAULTS; } | ||
| public Set<Integer> nullableFields() { return NULLABLE_FIELDS; } | ||
| public Set<Integer> implicitPresenceFields() { return IMPLICIT_PRESENCE_FIELDS; } |
| @Override public Map<Integer, String> enumTypes() { return ENUM_TYPES; } | ||
| @Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; } | ||
| @Override public Map<Integer, String> defaults() { return DEFAULTS; } | ||
| public Set<Integer> nullableFields() { return NULLABLE_FIELDS; } |
| @Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; } | ||
| @Override public Map<Integer, String> defaults() { return DEFAULTS; } | ||
| public Set<Integer> nullableFields() { return NULLABLE_FIELDS; } | ||
| public Set<Integer> implicitPresenceFields() { return IMPLICIT_PRESENCE_FIELDS; } |
| @Override public Map<Integer, String> enumTypes() { return ENUM_TYPES; } | ||
| @Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; } | ||
| @Override public Map<Integer, String> defaults() { return DEFAULTS; } | ||
| public Set<Integer> nullableFields() { return NULLABLE_FIELDS; } |
| @Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; } | ||
| @Override public Map<Integer, String> defaults() { return DEFAULTS; } | ||
| public Set<Integer> nullableFields() { return NULLABLE_FIELDS; } | ||
| public Set<Integer> implicitPresenceFields() { return IMPLICIT_PRESENCE_FIELDS; } |
| @Override public Map<Integer, String> enumTypes() { return ENUM_TYPES; } | ||
| @Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; } | ||
| @Override public Map<Integer, String> defaults() { return DEFAULTS; } | ||
| public Set<Integer> nullableFields() { return NULLABLE_FIELDS; } |
| @Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; } | ||
| @Override public Map<Integer, String> defaults() { return DEFAULTS; } | ||
| public Set<Integer> nullableFields() { return NULLABLE_FIELDS; } | ||
| public Set<Integer> implicitPresenceFields() { return IMPLICIT_PRESENCE_FIELDS; } |
| @Override public Map<Integer, String> enumTypes() { return ENUM_TYPES; } | ||
| @Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; } | ||
| @Override public Map<Integer, String> defaults() { return DEFAULTS; } | ||
| public Set<Integer> nullableFields() { return NULLABLE_FIELDS; } |
| @Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; } | ||
| @Override public Map<Integer, String> defaults() { return DEFAULTS; } | ||
| public Set<Integer> nullableFields() { return NULLABLE_FIELDS; } | ||
| public Set<Integer> implicitPresenceFields() { return IMPLICIT_PRESENCE_FIELDS; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prototype for trendvidia/protowire#539, as a draft. It needs your decision there. This advances #168: it adds the lite test that #168's lite half asks for.
Problem. A lite schema with a
google.protobuf.Anyfield (orEmpty,FieldMask,Struct,Value,ListValue,NullValue) does not compile. The generated meta namescom.google.protobuf.AnyPxfMeta, and nothing generates that class.What this does
:pxf-runtimeships the companions for these types inorg.protowire.pxf.wkt. They areprotoc-gen-pxf-java-meta's output for the four google files, with only the package line changed.pxf-runtime/scripts/regen-wkt-companions.sh <spec checkout>regenerates them, and--checkdiffs them against fresh output.9e54740). The pin must move to spec main before merge.type_urlandvalue, because the lite tier has no type resolver. The rule in protowire#501 allows that.Evidence
GoogleMessagesLiteTest: 5 tests pass. They round-trip a field of each type, a repeated Any, a map of Any, nested Struct, Value and ListValue, and an Any whose bytes hold an unknown field and a repeated field.compileJavawithcannot find symbolinGoogleMessagesPxfMeta.java. That is #539 reproduced.pxf.Marshalon the same bytes gives text byte-for-byte equal to the lite text. Gopxf.Unmarshalof the lite text gives a messageproto.Equalto the original. (protowire-go at 3331d3b, through a scratch program; this check is not in CI.)./gradlew buildwith the plugin from the spec branch: BUILD SUCCESSFUL, 827 tests, 0 failures.Not done in this prototype
regen-wkt-companions.sh --check, so a plugin change could leave these copies stale without failing anything.google.protobuftype, such asTypeorApi, still does not compile. Protowire#550 lists this.