public static MessageId fromByteArray(byte[] data) throws IOException { checkNotNull(data); ByteBufCodedInputStream inputStream = ByteBufCodedInputStream.get(Unpooled.wrappedBuffer(data, 0, data.length)); PulsarApi.MessageIdData.Builder builder = PulsarApi.MessageIdData.newBuilder(); PulsarApi.MessageIdData idData; try { idData = builder.mergeFrom(inputStream, null).build(); } catch (UninitializedMessageException e) { throw new IOException(e); } MessageIdImpl messageId; if (idData.hasBatchIndex()) { messageId = new BatchMessageIdImpl(idData.getLedgerId(), idData.getEntryId(), idData.getPartition(), idData.getBatchIndex()); } else { messageId = new MessageIdImpl(idData.getLedgerId(), idData.getEntryId(), idData.getPartition()); } inputStream.recycle(); builder.recycle(); idData.recycle(); return messageId; }
public static MessageId fromByteArrayWithTopic(byte[] data, TopicName topicName) throws IOException { checkNotNull(data); ByteBufCodedInputStream inputStream = ByteBufCodedInputStream.get(Unpooled.wrappedBuffer(data, 0, data.length)); PulsarApi.MessageIdData.Builder builder = PulsarApi.MessageIdData.newBuilder(); PulsarApi.MessageIdData idData; try { idData = builder.mergeFrom(inputStream, null).build(); } catch (UninitializedMessageException e) { throw new IOException(e); } MessageId messageId; if (idData.hasBatchIndex()) { messageId = new BatchMessageIdImpl(idData.getLedgerId(), idData.getEntryId(), idData.getPartition(), idData.getBatchIndex()); } else { messageId = new MessageIdImpl(idData.getLedgerId(), idData.getEntryId(), idData.getPartition()); } if (idData.getPartition() > -1 && topicName != null) { messageId = new TopicMessageIdImpl( topicName.getPartition(idData.getPartition()).toString(), topicName.toString(), messageId); } inputStream.recycle(); builder.recycle(); idData.recycle(); return messageId; }
public static MessageId fromByteArray(byte[] data) throws IOException { checkNotNull(data); ByteBufCodedInputStream inputStream = ByteBufCodedInputStream.get(Unpooled.wrappedBuffer(data, 0, data.length)); PulsarApi.MessageIdData.Builder builder = PulsarApi.MessageIdData.newBuilder(); PulsarApi.MessageIdData idData; try { idData = builder.mergeFrom(inputStream, null).build(); } catch (UninitializedMessageException e) { throw new IOException(e); } MessageIdImpl messageId; if (idData.hasBatchIndex()) { messageId = new BatchMessageIdImpl(idData.getLedgerId(), idData.getEntryId(), idData.getPartition(), idData.getBatchIndex()); } else { messageId = new MessageIdImpl(idData.getLedgerId(), idData.getEntryId(), idData.getPartition()); } inputStream.recycle(); builder.recycle(); idData.recycle(); return messageId; }
public static MessageId fromByteArrayWithTopic(byte[] data, TopicName topicName) throws IOException { checkNotNull(data); ByteBufCodedInputStream inputStream = ByteBufCodedInputStream.get(Unpooled.wrappedBuffer(data, 0, data.length)); PulsarApi.MessageIdData.Builder builder = PulsarApi.MessageIdData.newBuilder(); PulsarApi.MessageIdData idData; try { idData = builder.mergeFrom(inputStream, null).build(); } catch (UninitializedMessageException e) { throw new IOException(e); } MessageId messageId; if (idData.hasBatchIndex()) { messageId = new BatchMessageIdImpl(idData.getLedgerId(), idData.getEntryId(), idData.getPartition(), idData.getBatchIndex()); } else { messageId = new MessageIdImpl(idData.getLedgerId(), idData.getEntryId(), idData.getPartition()); } if (idData.getPartition() > -1 && topicName != null) { messageId = new TopicMessageIdImpl( topicName.getPartition(idData.getPartition()).toString(), topicName.toString(), messageId); } inputStream.recycle(); builder.recycle(); idData.recycle(); return messageId; }
public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData.getDefaultInstance()) return this; if (other.hasLedgerId()) { setLedgerId(other.getLedgerId()); } if (other.hasEntryId()) { setEntryId(other.getEntryId()); } if (other.hasPartition()) { setPartition(other.getPartition()); } if (other.hasBatchIndex()) { setBatchIndex(other.getBatchIndex()); } return this; }
public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData.getDefaultInstance()) return this; if (other.hasLedgerId()) { setLedgerId(other.getLedgerId()); } if (other.hasEntryId()) { setEntryId(other.getEntryId()); } if (other.hasPartition()) { setPartition(other.getPartition()); } if (other.hasBatchIndex()) { setBatchIndex(other.getBatchIndex()); } return this; }