Search in sources :

Example 6 with RuntimeStats

use of org.apache.hudi.common.model.HoodieWriteStat.RuntimeStats in project hudi by apache.

the class HoodieMergeHandle method close.

@Override
public List<WriteStatus> close() {
    try {
        writeIncomingRecords();
        if (keyToNewRecords instanceof ExternalSpillableMap) {
            ((ExternalSpillableMap) keyToNewRecords).close();
        } else {
            keyToNewRecords.clear();
        }
        writtenRecordKeys.clear();
        if (fileWriter != null) {
            fileWriter.close();
            fileWriter = null;
        }
        long fileSizeInBytes = FSUtils.getFileSize(fs, newFilePath);
        HoodieWriteStat stat = writeStatus.getStat();
        stat.setTotalWriteBytes(fileSizeInBytes);
        stat.setFileSizeInBytes(fileSizeInBytes);
        stat.setNumWrites(recordsWritten);
        stat.setNumDeletes(recordsDeleted);
        stat.setNumUpdateWrites(updatedRecordsWritten);
        stat.setNumInserts(insertRecordsWritten);
        stat.setTotalWriteErrors(writeStatus.getTotalErrorRecords());
        RuntimeStats runtimeStats = new RuntimeStats();
        runtimeStats.setTotalUpsertTime(timer.endTimer());
        stat.setRuntimeStats(runtimeStats);
        performMergeDataValidationCheck(writeStatus);
        LOG.info(String.format("MergeHandle for partitionPath %s fileID %s, took %d ms.", stat.getPartitionPath(), stat.getFileId(), runtimeStats.getTotalUpsertTime()));
        return Collections.singletonList(writeStatus);
    } catch (IOException e) {
        throw new HoodieUpsertException("Failed to close UpdateHandle", e);
    }
}
Also used : HoodieWriteStat(org.apache.hudi.common.model.HoodieWriteStat) HoodieUpsertException(org.apache.hudi.exception.HoodieUpsertException) ExternalSpillableMap(org.apache.hudi.common.util.collection.ExternalSpillableMap) RuntimeStats(org.apache.hudi.common.model.HoodieWriteStat.RuntimeStats) IOException(java.io.IOException) HoodieIOException(org.apache.hudi.exception.HoodieIOException)

Aggregations

RuntimeStats (org.apache.hudi.common.model.HoodieWriteStat.RuntimeStats)6 HoodieWriteStat (org.apache.hudi.common.model.HoodieWriteStat)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Path (org.apache.hadoop.fs.Path)2 Serializable (java.io.Serializable)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1 Collectors.toList (java.util.stream.Collectors.toList)1 StreamSupport (java.util.stream.StreamSupport)1 Schema (org.apache.avro.Schema)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 HoodieAvroUtils (org.apache.hudi.avro.HoodieAvroUtils)1 HoodieCompactionOperation (org.apache.hudi.avro.model.HoodieCompactionOperation)1 HoodieCompactionPlan (org.apache.hudi.avro.model.HoodieCompactionPlan)1 WriteStatus (org.apache.hudi.client.WriteStatus)1 HoodieAccumulator (org.apache.hudi.common.data.HoodieAccumulator)1 HoodieData (org.apache.hudi.common.data.HoodieData)1