You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2020/12/05 16:50:08 UTC

[GitHub] [hive] maheshk114 commented on a change in pull request #1730: HIVE-24475: Generalize fixacidkeyindex utility

maheshk114 commented on a change in pull request #1730:
URL: https://github.com/apache/hive/pull/1730#discussion_r536821113



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/io/orc/FixAcidKeyIndex.java
##########
@@ -163,11 +144,52 @@ static void checkFile(Configuration conf, Path inputPath) throws IOException {
       return;
     }
 
-    boolean validIndex = isAcidKeyIndexValid(reader);
+    AcidKeyIndexValidationResult validationResult = validate(conf, inputPath);
+    boolean validIndex = validationResult.isValid;
     System.out.println("Checking " + inputPath + " - acid key index is " +
         (validIndex ? "valid" : "invalid"));
   }
 
+  public static AcidKeyIndexValidationResult validate(Configuration conf, Path inputPath) throws IOException {
+    AcidKeyIndexValidationResult result = new AcidKeyIndexValidationResult();
+    FileSystem fs = inputPath.getFileSystem(conf);
+    Reader reader = OrcFile.createReader(fs, inputPath);
+    List<StripeInformation> stripes = reader.getStripes();
+    RecordIdentifier[] keyIndex = OrcRecordUpdater.parseKeyIndex(reader);
+    StructObjectInspector soi = (StructObjectInspector) reader.getObjectInspector();
+    // struct<operation:int,originalTransaction:bigint,bucket:int,rowId:bigint,currentTransaction:bigint
+
+    long rowsProcessed = 0;
+    try (RecordReader rr = reader.rows()) {
+      for(int i=0; i<stripes.size(); i++) {
+        rowsProcessed += stripes.get(i).getNumberOfRows();
+        rr.seekToRow(rowsProcessed-1);
+        OrcStruct row = (OrcStruct) rr.next(null);
+
+        List<? extends StructField> structFields = soi.getAllStructFieldRefs();
+
+        StructField transactionField = structFields.get(1);
+        StructField bucketField = structFields.get(2);

Review comment:
       Can this be moved out of the loop ?




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



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