Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/7154#discussion_r35197961
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala ---
@@ -345,14 +345,23 @@ private[sql] class ParquetRelation2(
// Schema of the whole table, including partition columns.
var schema: StructType = _
+ // Cached leaves
+ val cachedLeaves: mutable.Map[Path, FileStatus] = new
mutable.HashMap[Path, FileStatus]()
+
/**
* Refreshes `FileStatus`es, footers, partition spec, and table schema.
*/
def refresh(): Unit = {
// Lists `FileStatus`es of all leaf nodes (files) under all base
directories.
+ // We only care about new FileStatus and updated FileStatus.
val leaves = cachedLeafStatuses().filter { f =>
- isSummaryFile(f.getPath) ||
- !(f.getPath.getName.startsWith("_") ||
f.getPath.getName.startsWith("."))
+ (isSummaryFile(f.getPath) ||
+ !(f.getPath.getName.startsWith("_") ||
f.getPath.getName.startsWith("."))) &&
+ (!cachedLeaves.contains(f.getPath) ||
+ cachedLeaves(f.getPath).getModificationTime <
f.getModificationTime)
+ }.map { f =>
+ cachedLeaves += (f.getPath -> f)
+ f
--- End diff --
Unfortunately there's still a bug here :) We also need to remove those
files that only exist in the old cache (namely removed files). This happens
when an existing directory is overwritten.
I think we can first keep both the old cache and the result of
`cachedLeafStatuses()`, then filter out updated and new files, and at last
update the old `FileStatus` cache.
---
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]