Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7154#discussion_r35087927
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala ---
    @@ -342,15 +342,35 @@ private[sql] class ParquetRelation2(
         // Schema of the whole table, including partition columns.
         var schema: StructType = _
     
    +    // Cached leaf statuses
    +    var localCachedLeafStatuses: Set[FileStatus] = _
    +
    +    var lastRefreshTime: Long = 0
    +
    +    // Cached leaves
    +    var cachedLeaves: Array[FileStatus] = Array()
    +
         /**
          * Refreshes `FileStatus`es, footers, partition spec, and table schema.
          */
         def refresh(): Unit = {
    +      // Check if cachedLeafStatuses is changed or not
    +      val leafStatusesChanged = localCachedLeafStatuses != 
cachedLeafStatuses()
    +
           // Lists `FileStatus`es of all leaf nodes (files) under all base 
directories.
    -      val leaves = cachedLeafStatuses().filter { f =>
    -        isSummaryFile(f.getPath) ||
    -          !(f.getPath.getName.startsWith("_") || 
f.getPath.getName.startsWith("."))
    -      }.toArray
    +      val leaves = if (leafStatusesChanged) {
    +        localCachedLeafStatuses = cachedLeafStatuses()
    +        val updatedLeaves = cachedLeafStatuses().filter { f =>
    +          (isSummaryFile(f.getPath) ||
    +            !(f.getPath.getName.startsWith("_") || 
f.getPath.getName.startsWith("."))) &&
    +            (f.getModificationTime > lastRefreshTime)
    +        }.toArray
    +        lastRefreshTime = System.currentTimeMillis
    --- End diff --
    
    We care about two kinds of files here:
    
    - New files: files don't exist in the old cache.
    - Files got updated: files exist in the old cache but have different 
modification time from their old copy.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to