morningman commented on a change in pull request #3815:
URL: https://github.com/apache/incubator-doris/pull/3815#discussion_r438769259



##########
File path: fe/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java
##########
@@ -298,57 +262,28 @@ public Long getTabletIdByReplica(long replicaId) {
         }
     }
 
-    public long getPartitionId(long tabletId) {
-        readLock();
-        try {
-            if (tabletMetaMap.containsKey(tabletId)) {
-                return tabletMetaMap.get(tabletId).getPartitionId();
-            }
-            return NOT_EXIST_VALUE;
-        } finally {
-            readUnlock();
-        }
-    }
-
-    public long getIndexId(long tabletId) {
+    public TabletMeta getTabletMeta(long tabletId) {
         readLock();
         try {
-            if (tabletMetaMap.containsKey(tabletId)) {
-                return tabletMetaMap.get(tabletId).getIndexId();
-            }
-            return NOT_EXIST_VALUE;
+            return tabletMetaMap.get(tabletId);
         } finally {
             readUnlock();
         }
     }
 
-    public int getEffectiveSchemaHash(long tabletId) {
-        // always get old schema hash(as effective one)
+    public List<TabletMeta> getTabletMetaList(List<Long> tabletIdList) {

Review comment:
       It is very error-prone to result a list will null in it.
   How about using `getOrDefault()` method, and return an `NonExistTabletMeta` 
is not found?
   And `NonExistTabletMeta` can be a `final static` member with all id as 
`NON_EXIST_VALUE` in it.
   
   In this way, we don't have to check null each time we visit the returned 
list.

##########
File path: fe/src/main/java/org/apache/doris/master/ReportHandler.java
##########
@@ -388,21 +389,26 @@ private static void sync(Map<Long, TTablet> 
backendTablets, ListMultimap<Long, L
                 List<Long> tabletIds = tabletSyncMap.get(dbId);
                 LOG.info("before sync tablets in db[{}]. report num: {}. 
backend[{}]",
                          dbId, tabletIds.size(), backendId);
-
-                for (Long tabletId : tabletIds) {
-                    long tableId = invertedIndex.getTableId(tabletId);
+                List<TabletMeta> tabletMetaList = 
invertedIndex.getTabletMetaList(tabletIds);
+                for (int i = 0; i < tabletMetaList.size(); i++) {
+                    TabletMeta tabletMeta = tabletMetaList.get(i);
+                    if (tabletMeta == null) {
+                        continue;
+                    }
+                    long tabletId = tabletIds.get(i);
+                    long tableId = tabletMeta.getTableId();
                     OlapTable olapTable = (OlapTable) db.getTable(tableId);
                     if (olapTable == null) {
                         continue;
                     }
 
-                    long partitionId = invertedIndex.getPartitionId(tabletId);
+                    long partitionId = tabletMeta.getPartitionId();
                     Partition partition = olapTable.getPartition(partitionId);
                     if (partition == null) {
                         continue;
                     }
 
-                    long indexId = invertedIndex.getIndexId(tabletId);
+                    long indexId = tabletMeta.getPartitionId();

Review comment:
       ```suggestion
                       long indexId = tabletMeta.getIndexId();
   ```
   
   Please double check again for similar errors.
   




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to