pvargacl commented on a change in pull request #1087:
URL: https://github.com/apache/hive/pull/1087#discussion_r450338348



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java
##########
@@ -429,6 +451,75 @@ void findUnknownPartitions(Table table, Set<Path> 
partPaths,
     LOG.debug("Number of partitions not in metastore : " + 
result.getPartitionsNotInMs().size());
   }
 
+  /**
+   * Calculate the maximum seen writeId from the acid directory structure
+   * @param partPath Path of the partition directory
+   * @param res Partition result to write the max ids
+   * @throws IOException ex
+   */
+  private void setMaxTxnAndWriteIdFromPartition(Path partPath, 
CheckResult.PartitionResult res) throws IOException {
+    FileSystem fs = partPath.getFileSystem(conf);
+    FileStatus[] deltaOrBaseFiles = fs.listStatus(partPath, 
HIDDEN_FILES_PATH_FILTER);
+
+    // Read the writeIds from every base and delta directory and find the max
+    long maxWriteId = 0L;
+    long maxVisibilityId = 0L;
+    for(FileStatus fileStatus : deltaOrBaseFiles) {
+      if (!fileStatus.isDirectory()) {
+        continue;
+      }
+      long writeId = 0L;
+      long visibilityId = 0L;
+      String folder = fileStatus.getPath().getName();
+      if (folder.startsWith(BASE_PREFIX)) {
+        visibilityId = getVisibilityTxnId(folder);
+        if (visibilityId > 0) {
+          folder = removeVisibilityTxnId(folder);
+        }
+        writeId = Long.parseLong(folder.substring(BASE_PREFIX.length()));
+      } else if (folder.startsWith(DELTA_PREFIX) || 
folder.startsWith(DELETE_DELTA_PREFIX)) {
+        // See AcidUtils.parseDelta
+        visibilityId = getVisibilityTxnId(folder);
+        if (visibilityId > 0) {
+          folder = removeVisibilityTxnId(folder);
+        }
+        boolean isDeleteDelta = folder.startsWith(DELETE_DELTA_PREFIX);
+        String rest = folder.substring((isDeleteDelta ? DELETE_DELTA_PREFIX : 
DELTA_PREFIX).length());
+        int split = rest.indexOf('_');

Review comment:
       fixed




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to