Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/7154#discussion_r35083650
--- 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()
--- End diff --
Should we do a deep copy here? Currently it's OK because
`cachedLeafStatuses()` always returns a new instance of `Set[FileStatus]`, but
it's possible that we use a mutable set object in the future. In that case, the
`!=` predicate above will always be true.
---
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]