JingsongLi commented on code in PR #6810:
URL: https://github.com/apache/paimon/pull/6810#discussion_r2613469993


##########
paimon-common/src/main/java/org/apache/paimon/globalindex/GlobalIndexSerDeUtils.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.paimon.globalindex;
+
+import org.apache.paimon.utils.RoaringNavigableMap64;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/** Utils to serialize and deserialize GlobalIndexResult. */
+public class GlobalIndexSerDeUtils {
+
+    private static final long MAGIC = 30458034380294134L;
+    private static final int VERSION = 1;
+
+    static void serialize(DataOutput dataOutput, GlobalIndexResult 
globalIndexResult)
+            throws IOException {
+        dataOutput.writeLong(MAGIC);
+        dataOutput.writeInt(VERSION);
+
+        int type;
+        if (globalIndexResult instanceof TopkGlobalIndexResult) {
+            type = 1;
+        } else {
+            type = 0;
+        }
+        dataOutput.writeInt(type);
+
+        RoaringNavigableMap64 roaringNavigableMap64 = 
globalIndexResult.results();
+        byte[] bytes = roaringNavigableMap64.serialize();
+
+        dataOutput.writeInt(bytes.length);
+        dataOutput.write(bytes);
+
+        if (type == 1) {
+            TopkGlobalIndexResult topkGlobalIndexResult = 
(TopkGlobalIndexResult) globalIndexResult;

Review Comment:
   You can write a size 0 or number to decide if there is score.



-- 
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