Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class InMemoryFileIndex(
}

override def refresh(): Unit = {
refresh0()
fileStatusCache.invalidateAll()
refresh0()
}

private def refresh0(): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,34 @@ class FileIndexSuite extends SharedSQLContext {
assert(catalog2.allFiles().nonEmpty)
}
}

test("refresh for InMemoryFileIndex with FileStatusCache") {
withTempDir { dir =>
val fileStatusCache = FileStatusCache.getOrCreate(spark)
val dirPath = new Path(dir.getAbsolutePath)
val catalog = new InMemoryFileIndex(spark, Seq(dirPath), Map.empty,
None, fileStatusCache) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

val catalog =
  new XXX(...) {
    def xxx
  }

def leafFilePaths: Seq[Path] = leafFiles.keys.toSeq
def leafDirPaths: Seq[Path] = leafDirToChildrenFiles.keys.toSeq
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Indents issues for the above three lines.


assert(catalog.leafDirPaths.isEmpty)
assert(catalog.leafFilePaths.isEmpty)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move these two asserts after stringToFile


val file = new File(dir, "text.txt")
stringToFile(file, "text")

catalog.refresh()

assert(catalog.leafFilePaths.size == 1)
assert(catalog.leafFilePaths.head.toString.stripSuffix("/") ==
s"file:${file.getAbsolutePath.stripSuffix("/")}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks hacky, can you turn them into Path and compare?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let me modify~ thanks~


assert(catalog.leafDirPaths.size == 1)
assert(catalog.leafDirPaths.head.toString.stripSuffix("/") ==
s"file:${dir.getAbsolutePath.stripSuffix("/")}")
}
}
}

class FakeParentPathFileSystem extends RawLocalFileSystem {
Expand Down