linliu-code commented on code in PR #9819:
URL: https://github.com/apache/hudi/pull/9819#discussion_r1353658420


##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/PositionUtils.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.hudi.common.table.log;
+
+import org.apache.hudi.common.util.Base64CodecUtil;
+
+import org.roaringbitmap.longlong.Roaring64NavigableMap;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+public class PositionUtils {
+  public static byte[] serializeWithRoaring64NavigableMap(int[] positions) 
throws IOException {
+    Roaring64NavigableMap bitmap = new Roaring64NavigableMap();
+    for (int pos : positions) {
+      bitmap.add(pos);
+    }
+    bitmap.runOptimize();
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream dos = new DataOutputStream(baos);
+    bitmap.serializePortable(dos);
+    return baos.toByteArray();
+  }
+
+  public static byte[] serializeWithRoaring64NavigableMap(List<Long> 
positions) throws IOException {
+    Roaring64NavigableMap bitmap = new Roaring64NavigableMap();
+    positions.forEach(bitmap::add);
+    bitmap.runOptimize();
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream dos = new DataOutputStream(baos);
+    bitmap.serializePortable(dos);
+    return baos.toByteArray();
+  }
+
+  public static Roaring64NavigableMap 
deserializeWithRoaring64NavigableMap(byte[] content) throws IOException {
+    Roaring64NavigableMap bitmap = new Roaring64NavigableMap();
+    ByteArrayInputStream bais = new ByteArrayInputStream(content);
+    DataInputStream dis = new DataInputStream(bais);
+    bitmap.deserializePortable(dis);
+    return bitmap;
+  }
+
+  public static String 
serializeCodecStringWithRoaring64NavigableMap(List<Long> positions) throws 
IOException {
+    return 
Base64CodecUtil.encode(serializeWithRoaring64NavigableMap(positions));
+  }
+
+  public static Roaring64NavigableMap 
deserializeCodecStringWithRoaring64NavigableMap(String content) throws 
IOException {
+    return 
deserializeWithRoaring64NavigableMap(Base64CodecUtil.decode(content));
+  }
+
+  public static String serializeCodecStringWithRoaring64NavigableMap(int[] 
positions) throws IOException {

Review Comment:
   Not needed. Will remove this file.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to