public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.SingleMessageMetadata other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.SingleMessageMetadata.getDefaultInstance()) return this; if (!other.properties_.isEmpty()) { if (properties_.isEmpty()) { properties_ = other.properties_; bitField0_ = (bitField0_ & ~0x00000001); } else { ensurePropertiesIsMutable(); properties_.addAll(other.properties_); } } if (other.hasPartitionKey()) { setPartitionKey(other.getPartitionKey()); } if (other.hasPayloadSize()) { setPayloadSize(other.getPayloadSize()); } if (other.hasCompactedOut()) { setCompactedOut(other.getCompactedOut()); } if (other.hasEventTime()) { setEventTime(other.getEventTime()); } if (other.hasPartitionKeyB64Encoded()) { setPartitionKeyB64Encoded(other.getPartitionKeyB64Encoded()); } return this; }
public static ByteBuf deSerializeSingleMessageInBatch(ByteBuf uncompressedPayload, PulsarApi.SingleMessageMetadata.Builder singleMessageMetadataBuilder, int index, int batchSize) throws IOException { int singleMetaSize = (int) uncompressedPayload.readUnsignedInt(); int writerIndex = uncompressedPayload.writerIndex(); int beginIndex = uncompressedPayload.readerIndex() + singleMetaSize; uncompressedPayload.writerIndex(beginIndex); ByteBufCodedInputStream stream = ByteBufCodedInputStream.get(uncompressedPayload); PulsarApi.SingleMessageMetadata singleMessageMetadata = singleMessageMetadataBuilder.mergeFrom(stream, null) .build(); int singleMessagePayloadSize = singleMessageMetadata.getPayloadSize(); uncompressedPayload.markReaderIndex(); ByteBuf singleMessagePayload = uncompressedPayload.slice(uncompressedPayload.readerIndex(), singleMessagePayloadSize); singleMessagePayload.retain(); uncompressedPayload.writerIndex(writerIndex); uncompressedPayload.resetReaderIndex(); // reader now points to beginning of payload read; so move it past message payload just read if (index < batchSize) { uncompressedPayload.readerIndex(uncompressedPayload.readerIndex() + singleMessagePayloadSize); } return singleMessagePayload; }
public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.SingleMessageMetadata other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.SingleMessageMetadata.getDefaultInstance()) return this; if (!other.properties_.isEmpty()) { if (properties_.isEmpty()) { properties_ = other.properties_; bitField0_ = (bitField0_ & ~0x00000001); } else { ensurePropertiesIsMutable(); properties_.addAll(other.properties_); } } if (other.hasPartitionKey()) { setPartitionKey(other.getPartitionKey()); } if (other.hasPayloadSize()) { setPayloadSize(other.getPayloadSize()); } if (other.hasCompactedOut()) { setCompactedOut(other.getCompactedOut()); } if (other.hasEventTime()) { setEventTime(other.getEventTime()); } if (other.hasPartitionKeyB64Encoded()) { setPartitionKeyB64Encoded(other.getPartitionKeyB64Encoded()); } return this; }