You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "JeffBolle (via GitHub)" <gi...@apache.org> on 2023/06/28 22:10:27 UTC
[GitHub] [pinot] JeffBolle opened a new pull request, #10995: Extract record keys, headers and metadata from Pulsar sources
JeffBolle opened a new pull request, #10995:
URL: https://github.com/apache/pinot/pull/10995
fixes #10994. Adds Metadata parsing to Pulsar sources following the pattern of #9224.
@navina
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "navina (via GitHub)" <gi...@apache.org>.
navina commented on PR #10995:
URL: https://github.com/apache/pinot/pull/10995#issuecomment-1613920121
cc: @icefury71 fyi, this is finally happening! :)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "navina (via GitHub)" <gi...@apache.org>.
navina commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1256439810
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMetadataExtractor.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.RowMetadata;
+import org.apache.pulsar.client.api.Message;
+
+
+public interface PulsarMetadataExtractor {
+ static PulsarMetadataExtractor build(boolean populateMetadata, boolean setRecordTimeFromEventTime) {
+ return message -> {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+ long recordTimestamp = setRecordTimeFromEventTime ? eventTime : publishTime;
+
+ Map<String, String> metadataMap = populateMetadataMap(populateMetadata, message);
+
+ if (!populateMetadata) {
+ return new PulsarStreamMessageMetadata(recordTimestamp, null, metadataMap);
+ }
+ GenericRow headerGenericRow = buildGenericRow(message);
+ return new PulsarStreamMessageMetadata(recordTimestamp, headerGenericRow, metadataMap);
+ };
+ }
+
+ RowMetadata extract(Message<?> record);
+
+ static GenericRow buildGenericRow(Message<?> message) {
+ if (MapUtils.isEmpty(message.getProperties())) {
+ return null;
+ }
+ GenericRow genericRow = new GenericRow();
+ for (Map.Entry<String, String> entry : message.getProperties().entrySet()) {
+ genericRow.putValue(entry.getKey(), entry.getValue());
+ }
+ return genericRow;
+ }
+
+ static Map<String, String> populateMetadataMap(boolean populateAllFields, Message<?> message) {
Review Comment:
> performance considerations surrounding message ingest
exactly my point. Even though most fields are simple, I think it will increase the overall consumption throughput of the plugin with metadataExtraction enabled.
Think about the use-cases where materializing these system metadata fields as a column is actually useful. I can only think of debugging scenarios. The abstractions around `StreamMessageMetadata` was introduced mainly to extract keys and user-provided record headers that typically contains application related data.
To avoid performance degradation, I would suggest making this a configurable list of known metadata fields to extract.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "navina (via GitHub)" <gi...@apache.org>.
navina commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258639629
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarConfig.java:
##########
@@ -46,6 +46,8 @@ public class PulsarConfig {
private final String _authenticationToken;
private final String _tlsTrustCertsFilePath;
private final boolean _enableKeyValueStitch;
+ private final boolean _populateMetadata;
+ private final boolean _populateRecordTimeFromEventTime;
Review Comment:
> Since the broker field is optional, should we use it if present and fall back to the producer timestamp, or just always use the producer timestamp?
I think we can use the `brokerPublishTime` if present, else fallback to producer timestamp.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "navina (via GitHub)" <gi...@apache.org>.
navina commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1256427515
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarConfig.java:
##########
@@ -46,6 +46,8 @@ public class PulsarConfig {
private final String _authenticationToken;
private final String _tlsTrustCertsFilePath;
private final boolean _enableKeyValueStitch;
+ private final boolean _populateMetadata;
+ private final boolean _populateRecordTimeFromEventTime;
Review Comment:
@JeffBolle `StreamMessageMetadata#getRecordIngestionTimeMs()` is used in ingestion delay calculations. So, it would be incorrect to use user's eventTime as Pinot is trying to track the consumption from the stream and needs the time at which the record landed in the source. [See](https://github.com/apache/pinot/blob/68ab6bcd8da321960cbad4715ae80dd33ffd1d60/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java#L1611C38-L1611C38)
Not super familiar with pulsar semantics - is `publishTime` set by the producer of the data or by the broker when it gets persisted in the stream? It should be the latter.
In any case, you should avoid using event time as `recordIngestionTimeMs`
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258372342
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamMessage.java:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import javax.annotation.Nullable;
+import org.apache.pinot.spi.stream.StreamMessage;
+import org.apache.pulsar.client.api.MessageId;
+
+public class PulsarStreamMessage extends StreamMessage<byte[]> {
+
+ private final MessageId _messageId;
Review Comment:
The `PulsarMessageBatch` requires a reference to the `MessageId`. The other option is to put the field in the `PulsarStreamMessageMetadata`. In the Kinesis PR the `_sequenceNumber` was stored in the `KinesisStreamMessage` for an analogous use even though it was also present in the metadata map. Regardless, to properly reconstruct the Message Id would involve:
1. Storing it as a Base64 encoded byte array
2. Re-creating it from the Base64 string in the metadata map
In the conversation regarding adding objects to the metadata fields we seemed to be highly concerned with performance. Is the calling of `getNextStreamPartitionMsgOffsetAtIndex` infrequent enough that the Base64 round trip would be worth the benefit? Additionally, this would require `MessageId` to always be stored in the metadata map, requiring at least 1 of the 3 Base64 encodes. if we keep the reference in `PulsarStreamMessage` I can move the check in `PulsarMetadataExtractor` so that we are only storing the `MessageId` in metadata when `storeMetadata` is true, saving some cycles in the case when metadata extract is not enabled.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1261431874
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamMessage.java:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import javax.annotation.Nullable;
+import org.apache.pinot.spi.stream.StreamMessage;
+import org.apache.pulsar.client.api.MessageId;
+
+public class PulsarStreamMessage extends StreamMessage<byte[]> {
+
+ private final MessageId _messageId;
Review Comment:
Ok. What I'm understanding is that we leave the reference to `MessageId` in `PulsarStreamMessage` and implement the specific metadata field list changes.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "navina (via GitHub)" <gi...@apache.org>.
navina commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258638368
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMetadataExtractor.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.RowMetadata;
+import org.apache.pulsar.client.api.Message;
+
+
+public interface PulsarMetadataExtractor {
+ static PulsarMetadataExtractor build(boolean populateMetadata, boolean setRecordTimeFromEventTime) {
+ return message -> {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+ long recordTimestamp = setRecordTimeFromEventTime ? eventTime : publishTime;
+
+ Map<String, String> metadataMap = populateMetadataMap(populateMetadata, message);
+
+ if (!populateMetadata) {
+ return new PulsarStreamMessageMetadata(recordTimestamp, null, metadataMap);
+ }
+ GenericRow headerGenericRow = buildGenericRow(message);
+ return new PulsarStreamMessageMetadata(recordTimestamp, headerGenericRow, metadataMap);
+ };
+ }
+
+ RowMetadata extract(Message<?> record);
+
+ static GenericRow buildGenericRow(Message<?> message) {
+ if (MapUtils.isEmpty(message.getProperties())) {
+ return null;
+ }
+ GenericRow genericRow = new GenericRow();
+ for (Map.Entry<String, String> entry : message.getProperties().entrySet()) {
+ genericRow.putValue(entry.getKey(), entry.getValue());
+ }
+ return genericRow;
+ }
+
+ static Map<String, String> populateMetadataMap(boolean populateAllFields, Message<?> message) {
Review Comment:
> and use the Pulsar MessageId field to directly extract the full original Message from Pulsar to get the full object
Why is MessageId needed to extract the original pulsar message? And when you say "original message", are you referring to the value in the pulsar message or the whole payload (includes key, value and headers) ?
> I've switched everything over to use the the JDK implementation.
👍
> that is only when the data size approaches 1kb, which I think is highly unlikely for these fields (schema version, ordering key, MessageId).
It's typically the ingestion rate rather than the payload size that can cause a performance or throughput degradation.
> I'd rather not guess at performance implications. Are there some standard pinot benchmarks I can run to get some data on the performance impacts of the metadata changes?
We don't have any standard pinot benchmarks yet. That will be a good thing to have and we are open to suggestions. :)
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMetadataExtractor.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.RowMetadata;
+import org.apache.pulsar.client.api.Message;
+
+
+public interface PulsarMetadataExtractor {
+ static PulsarMetadataExtractor build(boolean populateMetadata, boolean setRecordTimeFromEventTime) {
+ return message -> {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+ long recordTimestamp = setRecordTimeFromEventTime ? eventTime : publishTime;
+
+ Map<String, String> metadataMap = populateMetadataMap(populateMetadata, message);
+
+ if (!populateMetadata) {
+ return new PulsarStreamMessageMetadata(recordTimestamp, null, metadataMap);
+ }
+ GenericRow headerGenericRow = buildGenericRow(message);
+ return new PulsarStreamMessageMetadata(recordTimestamp, headerGenericRow, metadataMap);
+ };
+ }
+
+ RowMetadata extract(Message<?> record);
+
+ static GenericRow buildGenericRow(Message<?> message) {
+ if (MapUtils.isEmpty(message.getProperties())) {
+ return null;
+ }
+ GenericRow genericRow = new GenericRow();
+ for (Map.Entry<String, String> entry : message.getProperties().entrySet()) {
+ genericRow.putValue(entry.getKey(), entry.getValue());
+ }
+ return genericRow;
+ }
+
+ static Map<String, String> populateMetadataMap(boolean populateAllFields, Message<?> message) {
Review Comment:
> and use the Pulsar MessageId field to directly extract the full original Message from Pulsar to get the full object
Why is MessageId needed to extract the original pulsar message? And when you say "original message", are you referring to the value in the pulsar message or the whole payload (includes key, value and headers) ?
> I've switched everything over to use the the JDK implementation.
👍
> that is only when the data size approaches 1kb, which I think is highly unlikely for these fields (schema version, ordering key, MessageId).
It's typically the ingestion rate rather than the payload size that can cause a performance or throughput degradation.
> I'd rather not guess at performance implications. Are there some standard pinot benchmarks I can run to get some data on the performance impacts of the metadata changes?
We don't have any standard pinot benchmarks yet. That will be a good thing to have and we are open to suggestions. :)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "navina (via GitHub)" <gi...@apache.org>.
navina commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1256431282
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamMessage.java:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import javax.annotation.Nullable;
+import org.apache.pinot.spi.stream.StreamMessage;
+import org.apache.pulsar.client.api.MessageId;
+
+public class PulsarStreamMessage extends StreamMessage<byte[]> {
+
+ private final MessageId _messageId;
Review Comment:
If it is already added to metadata, I would avoid the additional reference that is maintained in this class. It is unlikely to be used by realtime engine itself. So, better not to expose something unless it is really needed.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1261432675
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMetadataExtractor.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.RowMetadata;
+import org.apache.pulsar.client.api.Message;
+
+
+public interface PulsarMetadataExtractor {
+ static PulsarMetadataExtractor build(boolean populateMetadata, boolean setRecordTimeFromEventTime) {
+ return message -> {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+ long recordTimestamp = setRecordTimeFromEventTime ? eventTime : publishTime;
+
+ Map<String, String> metadataMap = populateMetadataMap(populateMetadata, message);
+
+ if (!populateMetadata) {
+ return new PulsarStreamMessageMetadata(recordTimestamp, null, metadataMap);
+ }
+ GenericRow headerGenericRow = buildGenericRow(message);
+ return new PulsarStreamMessageMetadata(recordTimestamp, headerGenericRow, metadataMap);
+ };
+ }
+
+ RowMetadata extract(Message<?> record);
+
+ static GenericRow buildGenericRow(Message<?> message) {
+ if (MapUtils.isEmpty(message.getProperties())) {
+ return null;
+ }
+ GenericRow genericRow = new GenericRow();
+ for (Map.Entry<String, String> entry : message.getProperties().entrySet()) {
+ genericRow.putValue(entry.getKey(), entry.getValue());
+ }
+ return genericRow;
+ }
+
+ static Map<String, String> populateMetadataMap(boolean populateAllFields, Message<?> message) {
Review Comment:
Sounds good, will merge that branch with the PR.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1254611955
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMetadataExtractor.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.RowMetadata;
+import org.apache.pulsar.client.api.Message;
+
+
+public interface PulsarMetadataExtractor {
+ static PulsarMetadataExtractor build(boolean populateMetadata, boolean setRecordTimeFromEventTime) {
+ return message -> {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+ long recordTimestamp = setRecordTimeFromEventTime ? eventTime : publishTime;
+
+ Map<String, String> metadataMap = populateMetadataMap(populateMetadata, message);
+
+ if (!populateMetadata) {
+ return new PulsarStreamMessageMetadata(recordTimestamp, null, metadataMap);
+ }
+ GenericRow headerGenericRow = buildGenericRow(message);
+ return new PulsarStreamMessageMetadata(recordTimestamp, headerGenericRow, metadataMap);
+ };
+ }
+
+ RowMetadata extract(Message<?> record);
+
+ static GenericRow buildGenericRow(Message<?> message) {
+ if (MapUtils.isEmpty(message.getProperties())) {
+ return null;
+ }
+ GenericRow genericRow = new GenericRow();
+ for (Map.Entry<String, String> entry : message.getProperties().entrySet()) {
+ genericRow.putValue(entry.getKey(), entry.getValue());
+ }
+ return genericRow;
+ }
+
+ static Map<String, String> populateMetadataMap(boolean populateAllFields, Message<?> message) {
Review Comment:
The only reason that comes to my mind as to why someone would want to configure which specific fields are added to the message metadata would be for performance considerations surrounding message ingest. I believe the slowest operations in this method are the calls to do the Base64 encoding of the `byte[]` fields. The other operations are all very small.
My inclination would be to not introduce the complexity of having a configurable list of fields and leave that modification to whomever has sufficient need to justify the effort.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] Jackie-Jiang merged pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang merged PR #10995:
URL: https://github.com/apache/pinot/pull/10995
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258372342
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamMessage.java:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import javax.annotation.Nullable;
+import org.apache.pinot.spi.stream.StreamMessage;
+import org.apache.pulsar.client.api.MessageId;
+
+public class PulsarStreamMessage extends StreamMessage<byte[]> {
+
+ private final MessageId _messageId;
Review Comment:
The `PulsarMessageBatch` code requires a reference to the `MessageId`. The other option is to put the field in the `PulsarStreamMessageMetadata`. In the Kinesis PR the `_sequenceNumber` was stored in the `KinesisStreamMessage` for an analogous use even though it was also present in the metadata map. Regardless, to properly reconstruct the Message Id would involve:
1. Storing it as a Base64 encoded byte array
2. Re-creating it from the Base64 string in the metadata map
In the conversation regarding adding objects to the metadata fields we seemed to be highly concerned with performance. Is the calling of `getNextStreamPartitionMsgOffsetAtIndex` infrequent enough that the Base64 round trip would be worth the benefit? Additionally, this would require `MessageId` to always be stored in the metadata map, requiring at least 1 of the 3 Base64 encodes. if we keep the reference in `PulsarStreamMessage` I can move the check in `PulsarMetadataExtractor` so that we are only storing the `MessageId` in metadata when `storeMetadata` is true, saving some cycles in the case when metadata extract is not enabled.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "navina (via GitHub)" <gi...@apache.org>.
navina commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258653171
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamMessage.java:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import javax.annotation.Nullable;
+import org.apache.pinot.spi.stream.StreamMessage;
+import org.apache.pulsar.client.api.MessageId;
+
+public class PulsarStreamMessage extends StreamMessage<byte[]> {
+
+ private final MessageId _messageId;
Review Comment:
> Is the calling of getNextStreamPartitionMsgOffsetAtIndex infrequent enough that the Base64 round trip would be worth the benefit?
`getNextStreamPartitionMsgOffsetAtIndex` is called while looping through every message in the batch.
> if we keep the reference in PulsarStreamMessage I can move the check in PulsarMetadataExtractor so that we are only storing the MessageId in metadata when storeMetadata is true, saving some cycles in the case when metadata extract is not enabled.
Yeah. I think you should extract the `MessageId` metadata only when `storeMetadata` is true. This change should not impact existing pulsar consumers that do not enable record metadata extraction. That's my primary concern.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "navina (via GitHub)" <gi...@apache.org>.
navina commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1247212492
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMetadataExtractor.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.RowMetadata;
+import org.apache.pulsar.client.api.Message;
+
+
+public interface PulsarMetadataExtractor {
+ static PulsarMetadataExtractor build(boolean populateMetadata, boolean setRecordTimeFromEventTime) {
+ return message -> {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+ long recordTimestamp = setRecordTimeFromEventTime ? eventTime : publishTime;
+
+ Map<String, String> metadataMap = populateMetadataMap(populateMetadata, message);
+
+ if (!populateMetadata) {
+ return new PulsarStreamMessageMetadata(recordTimestamp, null, metadataMap);
+ }
+ GenericRow headerGenericRow = buildGenericRow(message);
+ return new PulsarStreamMessageMetadata(recordTimestamp, headerGenericRow, metadataMap);
+ };
+ }
+
+ RowMetadata extract(Message<?> record);
+
+ static GenericRow buildGenericRow(Message<?> message) {
+ if (MapUtils.isEmpty(message.getProperties())) {
+ return null;
+ }
+ GenericRow genericRow = new GenericRow();
+ for (Map.Entry<String, String> entry : message.getProperties().entrySet()) {
+ genericRow.putValue(entry.getKey(), entry.getValue());
+ }
+ return genericRow;
+ }
+
+ static Map<String, String> populateMetadataMap(boolean populateAllFields, Message<?> message) {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+
+ Map<String, String> metadataMap = new HashMap<>();
+ if (eventTime > 0) {
+ metadataMap.put(PulsarStreamMessageMetadata.EVENT_TIME_KEY, String.valueOf(eventTime));
+ }
+ if (publishTime > 0) {
+ metadataMap.put(PulsarStreamMessageMetadata.PUBLISH_TIME_KEY, String.valueOf(publishTime));
+ }
+
+ message.getBrokerPublishTime().ifPresent(
+ brokerPublishTime -> metadataMap.put(PulsarStreamMessageMetadata.BROKER_PUBLISH_TIME_KEY,
+ String.valueOf(brokerPublishTime)));
+
+ String key = message.getKey();
+ if (StringUtils.isNotBlank(key)) {
+ metadataMap.put(PulsarStreamMessageMetadata.MESSAGE_KEY_KEY, key);
+ }
+ String messageIdStr = message.getMessageId().toString();
+ metadataMap.put(PulsarStreamMessageMetadata.MESSAGE_ID_KEY, messageIdStr);
+ byte[] messageIdBytes = message.getMessageId().toByteArray();
+ metadataMap.put(PulsarStreamMessageMetadata.MESSAGE_ID_BYTES_B64_KEY, Base64.encodeBase64String(messageIdBytes));
+
+ //From Kafka and Kensis metadata extractors we seem to still populate some timestamps,
Review Comment:
Yes. The ingestion engine uses the record timestamp to calculate lags/delays. That's why we add some metadata about the timestamp.
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamMessage.java:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import javax.annotation.Nullable;
+import org.apache.pinot.spi.stream.StreamMessage;
+import org.apache.pulsar.client.api.MessageId;
+
+public class PulsarStreamMessage extends StreamMessage<byte[]> {
+
+ private final MessageId _messageId;
Review Comment:
is this member variable needed when the same messageId is also added as metadata ?
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamMessageMetadata.java:
##########
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.StreamMessageMetadata;
+public class PulsarStreamMessageMetadata extends StreamMessageMetadata {
Review Comment:
nit: new line
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamMessageMetadata.java:
##########
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.StreamMessageMetadata;
+public class PulsarStreamMessageMetadata extends StreamMessageMetadata {
+ public static final String PUBLISH_TIME_KEY = "publishTime";
Review Comment:
can you add a link to what these metadata represent? perhaps in a javadoc for this class?
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamLevelConsumer.java:
##########
@@ -81,9 +81,9 @@ public GenericRow next(GenericRow destination) {
// Log every minute or 100k events
if (now - _lastLogTime > 60000 || _currentCount - _lastCount >= 100000) {
if (_lastCount == 0) {
- _logger.info("Consumed {} events from kafka stream {}", _currentCount, _streamConfig.getTopicName());
+ _logger.info("Consumed {} events from pulsar stream {}", _currentCount, _streamConfig.getTopicName());
Review Comment:
lol :)) tks for fixing this.
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarConfig.java:
##########
@@ -46,6 +46,8 @@ public class PulsarConfig {
private final String _authenticationToken;
private final String _tlsTrustCertsFilePath;
private final boolean _enableKeyValueStitch;
Review Comment:
I think this can be marked as deprecated now that all the key/values/metadata is parsed into the `PulsarStreamMessage` instance
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMetadataExtractor.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.RowMetadata;
+import org.apache.pulsar.client.api.Message;
+
+
+public interface PulsarMetadataExtractor {
+ static PulsarMetadataExtractor build(boolean populateMetadata, boolean setRecordTimeFromEventTime) {
+ return message -> {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+ long recordTimestamp = setRecordTimeFromEventTime ? eventTime : publishTime;
+
+ Map<String, String> metadataMap = populateMetadataMap(populateMetadata, message);
+
+ if (!populateMetadata) {
+ return new PulsarStreamMessageMetadata(recordTimestamp, null, metadataMap);
+ }
+ GenericRow headerGenericRow = buildGenericRow(message);
+ return new PulsarStreamMessageMetadata(recordTimestamp, headerGenericRow, metadataMap);
+ };
+ }
+
+ RowMetadata extract(Message<?> record);
+
+ static GenericRow buildGenericRow(Message<?> message) {
+ if (MapUtils.isEmpty(message.getProperties())) {
+ return null;
+ }
+ GenericRow genericRow = new GenericRow();
+ for (Map.Entry<String, String> entry : message.getProperties().entrySet()) {
+ genericRow.putValue(entry.getKey(), entry.getValue());
+ }
+ return genericRow;
+ }
+
+ static Map<String, String> populateMetadataMap(boolean populateAllFields, Message<?> message) {
Review Comment:
It's interesting that pulsar has so much metadata in each record. do you see any value in making the list of metadata keys to be parsed as configurable for the pulsar consumer?
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMessageBatch.java:
##########
@@ -56,26 +50,19 @@ public int getMessageCount() {
}
@Override
- public byte[] getMessageAtIndex(int index) {
- Message<byte[]> msg = _messageList.get(index);
- if (_enableKeyValueStitch) {
- return stitchKeyValue(msg.getKeyBytes(), msg.getData());
- }
- return msg.getData();
+ public PulsarStreamMessage getMessageAtIndex(int index) {
+ return _messageList.get(index);
}
@Override
public int getMessageOffsetAtIndex(int index) {
- return ByteBuffer.wrap(_messageList.get(index).getData()).arrayOffset();
+ return ByteBuffer.wrap(_messageList.get(index).getValue()).arrayOffset();
}
@Override
public int getMessageLengthAtIndex(int index) {
- if (_enableKeyValueStitch) {
- Message<byte[]> msg = _messageList.get(index);
- return 8 + msg.getKeyBytes().length + msg.getData().length;
- }
- return _messageList.get(index).getData().length;
+ return _messageList.get(index).getValue().length; //if _enableKeyValueStitch is true, then they are already stitched
Review Comment:
nit: s/they are already stitched/they are already stitched in the consumer/
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarConfig.java:
##########
@@ -46,6 +46,8 @@ public class PulsarConfig {
private final String _authenticationToken;
private final String _tlsTrustCertsFilePath;
private final boolean _enableKeyValueStitch;
+ private final boolean _populateMetadata;
+ private final boolean _populateRecordTimeFromEventTime;
Review Comment:
nit: why is this configuration `_populateRecordTimeFromEventTime` needed ?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1254620691
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarConfig.java:
##########
@@ -46,6 +46,8 @@ public class PulsarConfig {
private final String _authenticationToken;
private final String _tlsTrustCertsFilePath;
private final boolean _enableKeyValueStitch;
+ private final boolean _populateMetadata;
+ private final boolean _populateRecordTimeFromEventTime;
Review Comment:
Pulsar has multiple timestamps associated with each message. If the user has set the `eventTime` on their Pulsar message, that may have more meaning than the `publishTime` assigned at the producer. The configuration parameter allows a user to have their provided `eventTime` timestamp carried over into Pinot as the `_recordIngestionTimeMs` value. I don't know the full effects of setting `_recordIngestionTimeMs` to a user-provided value. Should we force this to be set to an automatically assigned value?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258293030
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMetadataExtractor.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.RowMetadata;
+import org.apache.pulsar.client.api.Message;
+
+
+public interface PulsarMetadataExtractor {
+ static PulsarMetadataExtractor build(boolean populateMetadata, boolean setRecordTimeFromEventTime) {
+ return message -> {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+ long recordTimestamp = setRecordTimeFromEventTime ? eventTime : publishTime;
+
+ Map<String, String> metadataMap = populateMetadataMap(populateMetadata, message);
+
+ if (!populateMetadata) {
+ return new PulsarStreamMessageMetadata(recordTimestamp, null, metadataMap);
+ }
+ GenericRow headerGenericRow = buildGenericRow(message);
+ return new PulsarStreamMessageMetadata(recordTimestamp, headerGenericRow, metadataMap);
+ };
+ }
+
+ RowMetadata extract(Message<?> record);
+
+ static GenericRow buildGenericRow(Message<?> message) {
+ if (MapUtils.isEmpty(message.getProperties())) {
+ return null;
+ }
+ GenericRow genericRow = new GenericRow();
+ for (Map.Entry<String, String> entry : message.getProperties().entrySet()) {
+ genericRow.putValue(entry.getKey(), entry.getValue());
+ }
+ return genericRow;
+ }
+
+ static Map<String, String> populateMetadataMap(boolean populateAllFields, Message<?> message) {
Review Comment:
With respect to Pulsar, the use-case we are using this for is to directly query from Pulsar the full protobuf object that was indexed. Pinot's flat table structure requires us to lose a lot of the structure we have in our native objects during indexing. We don't generally need to search over all of the fields in an object, so we are planning to build indexes around the fields we search on, and use the Pulsar MessageId field to directly extract the full original Message from Pulsar to get the full object.
With respect to performance, the fields are already parsed, and in most cases we are doing a blank or empty check and then setting a value in a Map. Not likely the slowest operations in the message ingest process.
I researched base64 encoding performance and saw some research that there was a substantial performance difference between Apache Commons and the JDK Base64 implementations (https://dkomanov.medium.com/base64-encoding-performance-jdk-vs-apache-commons-3fb83323414b). I've switched everything over to use the the JDK implementation. It appears that given the size of the fields we are talking about, we are in the realm of a few thousand nanos, and that is only when the data size approaches 1kb, which I think is highly unlikely for these fields (schema version, ordering key, MessageId).
I'd rather not guess at performance implications. Are there some standard pinot benchmarks I can run to get some data on the performance impacts of the metadata changes?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258765974
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMetadataExtractor.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.RowMetadata;
+import org.apache.pulsar.client.api.Message;
+
+
+public interface PulsarMetadataExtractor {
+ static PulsarMetadataExtractor build(boolean populateMetadata, boolean setRecordTimeFromEventTime) {
+ return message -> {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+ long recordTimestamp = setRecordTimeFromEventTime ? eventTime : publishTime;
+
+ Map<String, String> metadataMap = populateMetadataMap(populateMetadata, message);
+
+ if (!populateMetadata) {
+ return new PulsarStreamMessageMetadata(recordTimestamp, null, metadataMap);
+ }
+ GenericRow headerGenericRow = buildGenericRow(message);
+ return new PulsarStreamMessageMetadata(recordTimestamp, headerGenericRow, metadataMap);
+ };
+ }
+
+ RowMetadata extract(Message<?> record);
+
+ static GenericRow buildGenericRow(Message<?> message) {
+ if (MapUtils.isEmpty(message.getProperties())) {
+ return null;
+ }
+ GenericRow genericRow = new GenericRow();
+ for (Map.Entry<String, String> entry : message.getProperties().entrySet()) {
+ genericRow.putValue(entry.getKey(), entry.getValue());
+ }
+ return genericRow;
+ }
+
+ static Map<String, String> populateMetadataMap(boolean populateAllFields, Message<?> message) {
Review Comment:
I implemented a config option with a list of fields and pushed it on a branch to give a view into what it looks like:
https://github.com/Q6Cyber/pinot/compare/pulsar-headers...metadata_field_config
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter commented on pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #10995:
URL: https://github.com/apache/pinot/pull/10995#issuecomment-1613940209
## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#10995](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (ed7910d) into [master](https://app.codecov.io/gh/apache/pinot/commit/04bdb9a39743569aaacfcb07e2cc7eaa08854791?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (04bdb9a) will **increase** coverage by `0.00%`.
> The diff coverage is `0.00%`.
```diff
@@ Coverage Diff @@
## master #10995 +/- ##
=========================================
Coverage 0.11% 0.11%
=========================================
Files 2192 2140 -52
Lines 118080 115607 -2473
Branches 17883 17597 -286
=========================================
Hits 137 137
+ Misses 117923 115450 -2473
Partials 20 20
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1temurin11 | `?` | |
| integration1temurin17 | `?` | |
| integration1temurin20 | `?` | |
| integration2temurin11 | `?` | |
| integration2temurin17 | `?` | |
| integration2temurin20 | `?` | |
| unittests1temurin11 | `?` | |
| unittests1temurin17 | `?` | |
| unittests1temurin20 | `?` | |
| unittests2temurin11 | `0.11% <0.00%> (-0.01%)` | :arrow_down: |
| unittests2temurin17 | `?` | |
| unittests2temurin20 | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...pache/pinot/plugin/stream/pulsar/PulsarConfig.java](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zdHJlYW0taW5nZXN0aW9uL3Bpbm90LXB1bHNhci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL3N0cmVhbS9wdWxzYXIvUHVsc2FyQ29uZmlnLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...pinot/plugin/stream/pulsar/PulsarMessageBatch.java](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zdHJlYW0taW5nZXN0aW9uL3Bpbm90LXB1bHNhci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL3N0cmVhbS9wdWxzYXIvUHVsc2FyTWVzc2FnZUJhdGNoLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [.../plugin/stream/pulsar/PulsarMetadataExtractor.java](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zdHJlYW0taW5nZXN0aW9uL3Bpbm90LXB1bHNhci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL3N0cmVhbS9wdWxzYXIvUHVsc2FyTWV0YWRhdGFFeHRyYWN0b3IuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [.../pulsar/PulsarPartitionLevelConnectionHandler.java](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zdHJlYW0taW5nZXN0aW9uL3Bpbm90LXB1bHNhci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL3N0cmVhbS9wdWxzYXIvUHVsc2FyUGFydGl0aW9uTGV2ZWxDb25uZWN0aW9uSGFuZGxlci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...in/stream/pulsar/PulsarPartitionLevelConsumer.java](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zdHJlYW0taW5nZXN0aW9uL3Bpbm90LXB1bHNhci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL3N0cmVhbS9wdWxzYXIvUHVsc2FyUGFydGl0aW9uTGV2ZWxDb25zdW1lci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...lugin/stream/pulsar/PulsarStreamLevelConsumer.java](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zdHJlYW0taW5nZXN0aW9uL3Bpbm90LXB1bHNhci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL3N0cmVhbS9wdWxzYXIvUHVsc2FyU3RyZWFtTGV2ZWxDb25zdW1lci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...inot/plugin/stream/pulsar/PulsarStreamMessage.java](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zdHJlYW0taW5nZXN0aW9uL3Bpbm90LXB1bHNhci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL3N0cmVhbS9wdWxzYXIvUHVsc2FyU3RyZWFtTWVzc2FnZS5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...gin/stream/pulsar/PulsarStreamMessageMetadata.java](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zdHJlYW0taW5nZXN0aW9uL3Bpbm90LXB1bHNhci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL3N0cmVhbS9wdWxzYXIvUHVsc2FyU3RyZWFtTWVzc2FnZU1ldGFkYXRhLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...apache/pinot/plugin/stream/pulsar/PulsarUtils.java](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zdHJlYW0taW5nZXN0aW9uL3Bpbm90LXB1bHNhci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL3N0cmVhbS9wdWxzYXIvUHVsc2FyVXRpbHMuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...apache/pinot/spi/stream/StreamDataDecoderImpl.java](https://app.codecov.io/gh/apache/pinot/pull/10995?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvc3RyZWFtL1N0cmVhbURhdGFEZWNvZGVySW1wbC5qYXZh) | `0.00% <0.00%> (ø)` | |
... and [72 files with indirect coverage changes](https://app.codecov.io/gh/apache/pinot/pull/10995/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1254594828
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarConfig.java:
##########
@@ -46,6 +46,8 @@ public class PulsarConfig {
private final String _authenticationToken;
private final String _tlsTrustCertsFilePath;
private final boolean _enableKeyValueStitch;
Review Comment:
I'm not familiar with the process for deprecating a config param. Should I just add the `@Deprecated` annotation?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1254625815
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamMessage.java:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import javax.annotation.Nullable;
+import org.apache.pinot.spi.stream.StreamMessage;
+import org.apache.pulsar.client.api.MessageId;
+
+public class PulsarStreamMessage extends StreamMessage<byte[]> {
+
+ private final MessageId _messageId;
Review Comment:
The MessageId is a "complex" Java object, and as such a serialized version of it is added to the metadata, as a representational string and as a Base64 encoded byte array. It seemed worth the tradeoff to maintain a pointer to the original object rather than doing a round trip parse from a Base64 encoded byte array stored in the metadata map.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258321352
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarConfig.java:
##########
@@ -46,6 +46,8 @@ public class PulsarConfig {
private final String _authenticationToken;
private final String _tlsTrustCertsFilePath;
private final boolean _enableKeyValueStitch;
+ private final boolean _populateMetadata;
+ private final boolean _populateRecordTimeFromEventTime;
Review Comment:
I'll remove all of the config and code for setting the record time from event time.
From the documentation it appears that the `publishTime` field is populated by the producer running in user code when that producer sends the `Message` to the broker. On the `Message` interface we also have the `brokerPublishTime`, which is documented as:
```
broker publish time from broker entry metadata, or empty if the feature is not enabled in the broker.
```
Since the broker field is optional, should we use it if present and fall back to the producer timestamp, or just always use the producer timestamp?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on PR #10995:
URL: https://github.com/apache/pinot/pull/10995#issuecomment-1633231149
I think we are at a good place. I've pushed the changes to take in a list of fields to parse, and I've got the branch building and passing tests in the `pinot-pulsar` package.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258372342
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamMessage.java:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import javax.annotation.Nullable;
+import org.apache.pinot.spi.stream.StreamMessage;
+import org.apache.pulsar.client.api.MessageId;
+
+public class PulsarStreamMessage extends StreamMessage<byte[]> {
+
+ private final MessageId _messageId;
Review Comment:
The `PulsarMessageBatch` and `MessageIdStreamOffsetFactory` require a reference to the `MessageId`. The other option is to put the field in the `PulsarStreamMessageMetadata`. In the Kinesis PR the `_sequenceNumber` was stored in the `KinesisStreamMessage` for an analogous use even though it was also present in the metadata map. Regardless, to properly reconstruct the Message Id would involve:
1. Storing it as a Base64 encoded byte array
2. Re-creating it from the Base64 string in the metadata map
In the conversation regarding adding objects to the metadata fields we seemed to be highly concerned with performance. Is the calling of `getNextStreamPartitionMsgOffsetAtIndex` infrequent enough that the Base64 round trip would be worth the benefit? Additionally, this would require `MessageId` to always be stored in the metadata map, requiring at least 1 of the 3 Base64 encodes. if we keep the reference in `PulsarStreamMessage` I can move the check in `PulsarMetadataExtractor` so that we are only storing the `MessageId` in metadata when `storeMetadata` is true, saving some cycles in the case when metadata extract is not enabled.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "navina (via GitHub)" <gi...@apache.org>.
navina commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258929528
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMetadataExtractor.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.RowMetadata;
+import org.apache.pulsar.client.api.Message;
+
+
+public interface PulsarMetadataExtractor {
+ static PulsarMetadataExtractor build(boolean populateMetadata, boolean setRecordTimeFromEventTime) {
+ return message -> {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+ long recordTimestamp = setRecordTimeFromEventTime ? eventTime : publishTime;
+
+ Map<String, String> metadataMap = populateMetadataMap(populateMetadata, message);
+
+ if (!populateMetadata) {
+ return new PulsarStreamMessageMetadata(recordTimestamp, null, metadataMap);
+ }
+ GenericRow headerGenericRow = buildGenericRow(message);
+ return new PulsarStreamMessageMetadata(recordTimestamp, headerGenericRow, metadataMap);
+ };
+ }
+
+ RowMetadata extract(Message<?> record);
+
+ static GenericRow buildGenericRow(Message<?> message) {
+ if (MapUtils.isEmpty(message.getProperties())) {
+ return null;
+ }
+ GenericRow genericRow = new GenericRow();
+ for (Map.Entry<String, String> entry : message.getProperties().entrySet()) {
+ genericRow.putValue(entry.getKey(), entry.getValue());
+ }
+ return genericRow;
+ }
+
+ static Map<String, String> populateMetadataMap(boolean populateAllFields, Message<?> message) {
Review Comment:
Looked through the branch and looks good to me.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] JeffBolle commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "JeffBolle (via GitHub)" <gi...@apache.org>.
JeffBolle commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258372342
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarStreamMessage.java:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import javax.annotation.Nullable;
+import org.apache.pinot.spi.stream.StreamMessage;
+import org.apache.pulsar.client.api.MessageId;
+
+public class PulsarStreamMessage extends StreamMessage<byte[]> {
+
+ private final MessageId _messageId;
Review Comment:
The `PulsarMessageBatch` code requires a reference to the `MessageId`. The other option is to put the field in the `KafkaStreamMessageMetadata`. In the Kinesis PR the `_sequenceNumber` was stored in the `KinesisStreamMessage` for an analogous use even though it was also present in the metadata map. Regardless, to properly reconstruct the Message Id would involve:
1. Storing it as a Base64 encoded byte array
2. Re-creating it from the Base64 string in the metadata map
In the conversation regarding adding objects to the metadata fields we seemed to be highly concerned with performance. Is the calling of `getNextStreamPartitionMsgOffsetAtIndex` infrequent enough that the Base64 round trip would be worth the benefit? Additionally, this would require `MessageId` to always be stored in the metadata map, requiring at least 1 of the 3 Base64 encodes. if we keep the reference in `PulsarStreamMessage` I can move the check in `PulsarMetadataExtractor` so that we are only storing the `MessageId` in metadata when `storeMetadata` is true, saving some cycles in the case when metadata extract is not enabled.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "navina (via GitHub)" <gi...@apache.org>.
navina commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1258638368
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarMetadataExtractor.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.pulsar;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.RowMetadata;
+import org.apache.pulsar.client.api.Message;
+
+
+public interface PulsarMetadataExtractor {
+ static PulsarMetadataExtractor build(boolean populateMetadata, boolean setRecordTimeFromEventTime) {
+ return message -> {
+ long eventTime = message.getEventTime();
+ long publishTime = message.getPublishTime();
+ long recordTimestamp = setRecordTimeFromEventTime ? eventTime : publishTime;
+
+ Map<String, String> metadataMap = populateMetadataMap(populateMetadata, message);
+
+ if (!populateMetadata) {
+ return new PulsarStreamMessageMetadata(recordTimestamp, null, metadataMap);
+ }
+ GenericRow headerGenericRow = buildGenericRow(message);
+ return new PulsarStreamMessageMetadata(recordTimestamp, headerGenericRow, metadataMap);
+ };
+ }
+
+ RowMetadata extract(Message<?> record);
+
+ static GenericRow buildGenericRow(Message<?> message) {
+ if (MapUtils.isEmpty(message.getProperties())) {
+ return null;
+ }
+ GenericRow genericRow = new GenericRow();
+ for (Map.Entry<String, String> entry : message.getProperties().entrySet()) {
+ genericRow.putValue(entry.getKey(), entry.getValue());
+ }
+ return genericRow;
+ }
+
+ static Map<String, String> populateMetadataMap(boolean populateAllFields, Message<?> message) {
Review Comment:
> and use the Pulsar MessageId field to directly extract the full original Message from Pulsar to get the full object
Why is MessageId needed to extract the original pulsar message? And when you say "original message", are you referring to the value in the pulsar message or the whole payload (includes key, value and headers) ?
> I've switched everything over to use the the JDK implementation.
👍
> that is only when the data size approaches 1kb, which I think is highly unlikely for these fields (schema version, ordering key, MessageId).
It's typically the ingestion rate rather than the payload size that can cause a performance or throughput degradation. Moreover, in the current stream consumer contract, it is expected to consume raw bytes and de-serialization happens in the stream decoder. Hence, adding any extra decode operation is considered as an overhead for pure ingestion .
As of today, the record metadata extractor is in the consumer layer and hence, the recommendation to avoid any unnecessary overhead. Going forward, we should delegate all payload extraction (key/value/headers) into the decoder stage. We are not there yet. :)
> I'd rather not guess at performance implications. Are there some standard pinot benchmarks I can run to get some data on the performance impacts of the metadata changes?
We don't have any standard pinot benchmarks yet. That will be a good thing to have and we are open to suggestions. :)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on a diff in pull request #10995: Extract record keys, headers and metadata from Pulsar sources
Posted by "navina (via GitHub)" <gi...@apache.org>.
navina commented on code in PR #10995:
URL: https://github.com/apache/pinot/pull/10995#discussion_r1256419574
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/main/java/org/apache/pinot/plugin/stream/pulsar/PulsarConfig.java:
##########
@@ -46,6 +46,8 @@ public class PulsarConfig {
private final String _authenticationToken;
private final String _tlsTrustCertsFilePath;
private final boolean _enableKeyValueStitch;
Review Comment:
Yeah. You can add `@Deprecated(since = "v0.13.* since pulsar support record key extraction")`
Might have to update documentation (if it exists) in the website
--
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.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org