javrasya commented on code in PR #9464:
URL: https://github.com/apache/iceberg/pull/9464#discussion_r1567891507


##########
flink/v1.18/flink/src/main/java/org/apache/iceberg/flink/source/split/SerializerHelper.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.iceberg.flink.source.split;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.io.UTFDataFormatException;
+import org.apache.flink.core.memory.DataInputDeserializer;
+import org.apache.flink.core.memory.DataOutputSerializer;
+
+/**
+ * Helper class to serialize and deserialize strings longer than 65K. The 
inspiration is mostly
+ * taken from the class 
org.apache.flink.core.memory.DataInputSerializer.readUTF and
+ * org.apache.flink.core.memory.DataOutputSerializer.writeUTF.
+ */
+public class SerializerHelper implements Serializable {
+
+  /**
+   * Similar to {@link DataOutputSerializer#writeUTF(String)}. Except this 
supports larger payloads
+   * which is up to max integer value.
+   *
+   * @param out the output stream to write the string to.
+   * @param str the string value to be written.
+   * @deprecated This method is deprecated because there will be a method 
within the {@link
+   *     DataOutputSerializer} already which does the same thing, so use that 
one instead once that
+   *     is released on Flink version 1.20.
+   *     <p>See * <a 
href="https://issues.apache.org/jira/browse/FLINK-34228";>FLINK-34228</a> * <a
+   *     
href="https://github.com/apache/flink/pull/24191";>https://github.com/apache/flink/pull/24191</a>
+   */
+  @Deprecated
+  public static void writeLongUTF(DataOutputSerializer out, String str) throws 
IOException {
+    int strlen = str.length();
+    long utflen = 0;
+    int c;
+
+    /* use charAt instead of copying String to char array */
+    for (int i = 0; i < strlen; i++) {
+      c = str.charAt(i);
+      utflen += getUTFBytesSize(c);
+
+      if (utflen > Integer.MAX_VALUE) {
+        throw new UTFDataFormatException("Encoded string reached maximum 
length: " + utflen);
+      }
+    }
+    if (utflen > Integer.MAX_VALUE - 4) {
+      throw new UTFDataFormatException("Encoded string is too long: " + 
utflen);
+    }
+
+    out.writeInt((int) utflen);
+    writeUTFBytes(out, str, (int) utflen);
+  }
+
+  /**
+   * Similar to {@link DataInputDeserializer#readUTF()}. Except this supports 
larger payloads which
+   * is up to max integer value.
+   *
+   * @param in the input stream to read the string from.
+   * @return the string value read from the input stream.
+   * @throws IOException if an I/O error occurs when reading from the input 
stream.
+   * @deprecated This method is deprecated because there will be a method 
within the {@link
+   *     DataInputDeserializer} already which does the same thing, so use that 
one instead once that
+   *     is released on Flink version 1.20.
+   *     <p>See * <a 
href="https://issues.apache.org/jira/browse/FLINK-34228";>FLINK-34228</a> * <a
+   *     
href="https://github.com/apache/flink/pull/24191";>https://github.com/apache/flink/pull/24191</a>
+   */
+  @Deprecated

Review Comment:
   This was an earlier discussion that this whole class will no longer be 
needed when Flink has the serializing/deserializing longUtf out of the box 
finally. The PR @pvary got merged in the Flink source. I think your comment 
about making the class package private makes sense but don't think it also 
makes sense to mark these method as deprecated not for the Iceberg users but 
for the Iceberg developers?



-- 
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: issues-unsubscr...@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to