boyuanzz commented on a change in pull request #14384:
URL: https://github.com/apache/beam/pull/14384#discussion_r605780315
##########
File path:
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/PubsubUnboundedSource.java
##########
@@ -1336,14 +1334,40 @@ public boolean getNeedsMessageId() {
@Override
public PCollection<PubsubMessage> expand(PBegin input) {
- return input
- .getPipeline()
- .begin()
- .apply(Read.from(new PubsubSource(this)))
- .apply(
- "PubsubUnboundedSource.Stats",
- ParDo.of(
- new StatsFn(pubsubFactory, subscription, topic,
timestampAttribute, idAttribute)));
+ SerializableFunction<byte[], PubsubMessage> function;
+ if (getNeedsAttributes() || getNeedsMessageId()) {
+ function = new PubsubMessages.ParsePubsubMessageProtoAsPayload();
+ } else {
+ function = new DeserializeBytesIntoPubsubMessagePayloadOnly();
+ }
+ PCollection<PubsubMessage> messages =
+ input
+ .getPipeline()
+ .begin()
+ .apply(Read.from(new PubsubSource(this)))
+ .apply(
+ "MapBytesToPubsubMessages",
+
MapElements.into(TypeDescriptor.of(PubsubMessage.class)).via(function));
+ if (usesStatsFn(input.getPipeline().getOptions())) {
+ checkArgument(false);
Review comment:
Yeah...I'll remove these and fix the tests. Will let you know it's ready.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]