bvaradar commented on a change in pull request #674: Upgrade to Hive 2.x, MOR 
read query fixes and performance improvement
URL: https://github.com/apache/incubator-hudi/pull/674#discussion_r292600285
 
 

 ##########
 File path: 
hoodie-hadoop-mr/src/main/java/com/uber/hoodie/hadoop/realtime/RealtimeCompactedRecordReader.java
 ##########
 @@ -96,26 +77,36 @@ public boolean next(Void aVoid, ArrayWritable 
arrayWritable) throws IOException
       // return from delta records map if we have some match.
       String key = 
arrayWritable.get()[HoodieRealtimeInputFormat.HOODIE_RECORD_KEY_COL_POS]
           .toString();
-      if (LOG.isDebugEnabled()) {
-        LOG.debug(String.format("key %s, base values: %s, log values: %s", key,
-            arrayWritableToString(arrayWritable), 
arrayWritableToString(deltaRecordMap.get(key))));
-      }
       if (deltaRecordMap.containsKey(key)) {
         // TODO(NA): Invoke preCombine here by converting arrayWritable to 
Avro. This is required since the
         // deltaRecord may not be a full record and needs values of columns 
from the parquet
-        Writable[] replaceValue = deltaRecordMap.get(key).get();
-        if (replaceValue.length < 1) {
-          // This record has been deleted, move to the next record
+        Optional<GenericRecord> rec = 
deltaRecordMap.get(key).getData().getInsertValue(getReaderSchema());
+        if (!rec.isPresent()) {
+          // If the record is not present, this is a delete record using an 
empty payload so skip this base record
+          // and move to the next record
           return next(aVoid, arrayWritable);
         }
+        GenericRecord recordToReturn = rec.get();
+        if (usesCustomPayload) {
+          // If using a custom payload, return only the projection fields
+          recordToReturn = HoodieAvroUtils.rewriteRecord(rec.get(), 
getReaderSchema());
+        }
+        // we assume, a later safe record in the log, is newer than what we 
have in the map &
+        // replace it.
+        ArrayWritable aWritable = (ArrayWritable) 
avroToArrayWritable(recordToReturn, getWriterSchema());
 
 Review comment:
   Thanks

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


With regards,
Apache Git Services

Reply via email to