You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by GitBox <gi...@apache.org> on 2020/03/18 13:16:50 UTC

[GitHub] [carbondata] akashrn5 commented on a change in pull request #3584: [CARBONDATA-3718] Support SegmentLevel MinMax for better Pruning and less driver memory usage for cache

akashrn5 commented on a change in pull request #3584: [CARBONDATA-3718] Support SegmentLevel MinMax for better Pruning and less driver memory usage for cache
URL: https://github.com/apache/carbondata/pull/3584#discussion_r394327598
 
 

 ##########
 File path: core/src/main/java/org/apache/carbondata/core/segmentmeta/SegmentMetaDataInfoStats.java
 ##########
 @@ -0,0 +1,170 @@
+/*
+ * 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.carbondata.core.segmentmeta;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
+import org.apache.carbondata.core.util.ByteUtil;
+
+/**
+ * Holds segment level meta data information such as min,max, sortColumn info for the
+ * corresponding table
+ */
+public class SegmentMetaDataInfoStats {
+
+  private SegmentMetaDataInfoStats() {
+    tableSegmentMetaDataInfoMap = new LinkedHashMap<>();
+  }
+
+  public static synchronized SegmentMetaDataInfoStats getInstance() {
+    if (null == segmentMetaDataInfoStats) {
+      segmentMetaDataInfoStats = new SegmentMetaDataInfoStats();
+      return segmentMetaDataInfoStats;
+    } else {
+      return segmentMetaDataInfoStats;
+    }
+  }
+
+  private Map<String, Map<String, BlockColumnMetaDataInfo>> tableSegmentMetaDataInfoMap;
+
+  private static SegmentMetaDataInfoStats segmentMetaDataInfoStats;
+
+  /**
+   * Prepare of map with key as column-id and value as SegmentColumnMetaDataInfo using the
+   * tableSegmentMetaDataInfoMap
+   *
+   * @param tableName get corresponding tableName from map
+   * @param segmentId get corresponding segment Id from map
+   * @return segmentMetaDataInfo for the corresponding segment
+   */
+  public synchronized SegmentMetaDataInfo getTableSegmentMetaDataInfo(String tableName,
+      String segmentId) {
+    Map<String, SegmentColumnMetaDataInfo> segmentColumnMetaDataInfoMap = new LinkedHashMap<>();
+    Map<String, BlockColumnMetaDataInfo> segmentMetaDataInfoMap =
+        this.tableSegmentMetaDataInfoMap.get(tableName);
+    if (null != segmentMetaDataInfoMap && !segmentMetaDataInfoMap.isEmpty()
+        && null != segmentMetaDataInfoMap.get(segmentId)) {
+      BlockColumnMetaDataInfo blockColumnMetaDataInfo = segmentMetaDataInfoMap.get(segmentId);
+      System.out.println("Column Schemas Size: " + blockColumnMetaDataInfo.getColumnSchemas().size()
+          + " Min size: " + blockColumnMetaDataInfo.getMin().length);
+      for (int i = 0; i < blockColumnMetaDataInfo.getColumnSchemas().size(); i++) {
+        org.apache.carbondata.format.ColumnSchema columnSchema =
+            blockColumnMetaDataInfo.getColumnSchemas().get(i);
+        boolean isSortColumn = false;
+        boolean isColumnDrift = false;
+        if (null != columnSchema.columnProperties && !columnSchema.columnProperties.isEmpty()) {
+          if (null != columnSchema.columnProperties.get(CarbonCommonConstants.SORT_COLUMNS)) {
+            isSortColumn = true;
+          }
+          if (null != columnSchema.columnProperties.get(CarbonCommonConstants.COLUMN_DRIFT)) {
+            isColumnDrift = true;
+          }
+        }
+        segmentColumnMetaDataInfoMap.put(columnSchema.column_id,
+            new SegmentColumnMetaDataInfo(isSortColumn, blockColumnMetaDataInfo.getMin()[i],
+                blockColumnMetaDataInfo.getMax()[i], isColumnDrift));
+      }
+    }
+    return new SegmentMetaDataInfo(segmentColumnMetaDataInfoMap);
+  }
+
+  public synchronized void setBlockMetaDataInfo(String tableName, String segmentId,
+      BlockColumnMetaDataInfo currentBlockColumnMetaInfo) {
+    // check if tableName is present in tableSegmentMetaDataInfoMap
+    if (!this.tableSegmentMetaDataInfoMap.isEmpty() && null != this.tableSegmentMetaDataInfoMap
+        .get(tableName) && !this.tableSegmentMetaDataInfoMap.get(tableName).isEmpty()
 
 Review comment:
   i thin `!this.tableSegmentMetaDataInfoMap.get(tableName).isEmpty()` this check is not needed, please check again and remove if not required

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


With regards,
Apache Git Services