You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/06/16 22:40:36 UTC

[GitHub] [pinot] jackjlli commented on a diff in pull request #8894: use single string dict and eliminate the integer key field

jackjlli commented on code in PR #8894:
URL: https://github.com/apache/pinot/pull/8894#discussion_r899572702


##########
pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableFactory.java:
##########
@@ -20,22 +20,58 @@
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import org.apache.pinot.common.utils.DataSchema;
 import org.apache.pinot.common.utils.DataTable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class DataTableFactory {
+  private static final Logger LOGGER = LoggerFactory.getLogger(DataTableFactory.class);
+  public static final int VERSION_2 = 2;
+  public static final int VERSION_3 = 3;
+  public static final int VERSION_4 = 4;
+  public static final int DEFAULT_VERSION = VERSION_3;
+
+  private static int _version = DataTableFactory.DEFAULT_VERSION;
+
   private DataTableFactory() {
   }
 
+  public static int getCurrentDataTableVersion() {
+    return _version;
+  }
+
+  public static void setCurrentDataTableVersion(int version) {
+    LOGGER.warn("Setting current DataTable version to: " + version);

Review Comment:
   Why warn level here?



##########
pinot-core/src/main/java/org/apache/pinot/core/common/DataTableFactory.java:
##########
@@ -0,0 +1,103 @@
+/**
+ * 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.core.common;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.common.utils.DataTable;
+import org.apache.pinot.core.common.datatable.DataTableBuilderV2V3;
+import org.apache.pinot.core.common.datatable.DataTableBuilderV4;
+import org.apache.pinot.core.common.datatable.DataTableImplV2;
+import org.apache.pinot.core.common.datatable.DataTableImplV3;
+import org.apache.pinot.core.common.datatable.DataTableImplV4;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DataTableFactory {
+  private static final Logger LOGGER = LoggerFactory.getLogger(DataTableFactory.class);
+  public static final int VERSION_2 = 2;
+  public static final int VERSION_3 = 3;
+  public static final int VERSION_4 = 4;
+  public static final int DEFAULT_VERSION = VERSION_3;
+
+  private static int _version = DataTableFactory.DEFAULT_VERSION;

Review Comment:
   put `private static` all together. Also make the constant name upper cases?



##########
pinot-core/src/main/java/org/apache/pinot/core/common/datablock/BaseDataBlock.java:
##########
@@ -84,7 +84,7 @@ public abstract class BaseDataBlock implements DataTable {
   protected int _numRows;
   protected int _numColumns;
   protected DataSchema _dataSchema;
-  protected Map<String, Map<Integer, String>> _dictionaryMap;
+  protected String[] _stringDictionary;

Review Comment:
   `_stringDictionaries`?



##########
pinot-core/src/main/java/org/apache/pinot/core/common/datablock/BaseDataBlock.java:
##########
@@ -387,24 +375,14 @@ protected byte[] serializeDictionaryMap()
   /**
    * Helper method to deserialize dictionary map.
    */
-  protected Map<String, Map<Integer, String>> deserializeDictionaryMap(ByteBuffer buffer)
+  protected String[] deserializeStringDictionary(ByteBuffer buffer)
       throws IOException {
-    int numDictionaries = buffer.getInt();
-    Map<String, Map<Integer, String>> dictionaryMap = new HashMap<>(numDictionaries);
-
-    for (int i = 0; i < numDictionaries; i++) {
-      String column = DataTableUtils.decodeString(buffer);
-      int dictionarySize = buffer.getInt();
-      Map<Integer, String> dictionary = new HashMap<>(dictionarySize);
-      for (int j = 0; j < dictionarySize; j++) {
-        int key = buffer.getInt();
-        String value = DataTableUtils.decodeString(buffer);
-        dictionary.put(key, value);
-      }
-      dictionaryMap.put(column, dictionary);
+    int dictionarySize = buffer.getInt();
+    String[] stringDictionary = new String[dictionarySize];
+    for (int i = 0; i < dictionarySize; i++) {
+      stringDictionary[i] = (DataTableUtils.decodeString(buffer));

Review Comment:
   Remove outer `()`?



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