You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/06/10 07:20:25 UTC

[GitHub] [pulsar] eolivelli opened a new pull request #10888: Make KeyValueSchema an interface visible in the public Schema API

eolivelli opened a new pull request #10888:
URL: https://github.com/apache/pulsar/pull/10888


   - allow users of pulsar-client-api to use KeyValueSchema
   - move KeyValueSchema implementation to KeyValueSchemaImpl
   - introduce a new interface KeyValueSchema
   
   ### Verifying this change
   
   The integration test file TestGenericObjectSink has been changed to use the new API class.
   See the comments in https://github.com/apache/pulsar/pull/10878


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli merged pull request #10888: Make KeyValueSchema an interface visible in the public Schema API

Posted by GitBox <gi...@apache.org>.
eolivelli merged pull request #10888:
URL: https://github.com/apache/pulsar/pull/10888


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on a change in pull request #10888: Make KeyValueSchema an interface visible in the public Schema API

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #10888:
URL: https://github.com/apache/pulsar/pull/10888#discussion_r648932108



##########
File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/sink/PulsarSink.java
##########
@@ -364,8 +364,8 @@ public void write(Record<T> record) {
         SinkRecord<T> sinkRecord = (SinkRecord<T>) record;
         TypedMessageBuilder<T> msg = pulsarSinkProcessor.newMessage(sinkRecord);
 
-        if (record.getKey().isPresent() && !(record.getSchema() instanceof KeyValueSchema &&
-                ((KeyValueSchema) record.getSchema()).getKeyValueEncodingType() == KeyValueEncodingType.SEPARATED)) {
+        if (record.getKey().isPresent() && !(record.getSchema() instanceof KeyValueSchemaImpl &&

Review comment:
       makes sense




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on a change in pull request #10888: Make KeyValueSchema an interface visible in the public Schema API

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #10888:
URL: https://github.com/apache/pulsar/pull/10888#discussion_r648929540



##########
File path: pulsar-client-api/src/main/java/org/apache/pulsar/client/api/KeyValueSchema.java
##########
@@ -0,0 +1,53 @@
+/**
+ * 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.pulsar.client.api;
+
+import org.apache.pulsar.common.schema.KeyValue;
+import org.apache.pulsar.common.schema.KeyValueEncodingType;
+
+/**
+ * This interface models a Schema that is composed of two parts.
+ * A Key and a Value.
+ * @param <K> the type of the Key
+ * @param <V> the type of the Value.
+ */
+public interface KeyValueSchema<K,V> extends Schema<KeyValue<K,V>> {
+
+    /**
+     * Get the Schema of the Key.
+     * @return the Schema of the Key
+     */
+    Schema<K> getKeySchema();
+
+    /**
+     * Get the Schema of the Value.
+     *
+     * @return the Schema of the Value
+     */
+    Schema<K> getValueSchema();

Review comment:
       yes, fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on a change in pull request #10888: Make KeyValueSchema an interface visible in the public Schema API

Posted by GitBox <gi...@apache.org>.
lhotari commented on a change in pull request #10888:
URL: https://github.com/apache/pulsar/pull/10888#discussion_r648929056



##########
File path: pulsar-client-api/src/main/java/org/apache/pulsar/client/api/KeyValueSchema.java
##########
@@ -0,0 +1,53 @@
+/**
+ * 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.pulsar.client.api;
+
+import org.apache.pulsar.common.schema.KeyValue;
+import org.apache.pulsar.common.schema.KeyValueEncodingType;
+
+/**
+ * This interface models a Schema that is composed of two parts.
+ * A Key and a Value.
+ * @param <K> the type of the Key
+ * @param <V> the type of the Value.
+ */
+public interface KeyValueSchema<K,V> extends Schema<KeyValue<K,V>> {
+
+    /**
+     * Get the Schema of the Key.
+     * @return the Schema of the Key
+     */
+    Schema<K> getKeySchema();
+
+    /**
+     * Get the Schema of the Value.
+     *
+     * @return the Schema of the Value
+     */
+    Schema<K> getValueSchema();

Review comment:
       Should this be `Schema<V>`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on a change in pull request #10888: Make KeyValueSchema an interface visible in the public Schema API

Posted by GitBox <gi...@apache.org>.
lhotari commented on a change in pull request #10888:
URL: https://github.com/apache/pulsar/pull/10888#discussion_r648930569



##########
File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/sink/PulsarSink.java
##########
@@ -364,8 +364,8 @@ public void write(Record<T> record) {
         SinkRecord<T> sinkRecord = (SinkRecord<T>) record;
         TypedMessageBuilder<T> msg = pulsarSinkProcessor.newMessage(sinkRecord);
 
-        if (record.getKey().isPresent() && !(record.getSchema() instanceof KeyValueSchema &&
-                ((KeyValueSchema) record.getSchema()).getKeyValueEncodingType() == KeyValueEncodingType.SEPARATED)) {
+        if (record.getKey().isPresent() && !(record.getSchema() instanceof KeyValueSchemaImpl &&

Review comment:
       would it make sense to use the interface `KeyValueSchema` in `instanceof` checks?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org