
Answer-first summary for fast verification
Answer: storesDF.persist(StorageLevel.MEMORY_ONLY).count()
The question asks which code blocks attempt to cache the partitions of DataFrame storesDF only in Spark's memory (MEMORY_ONLY). Option A uses cache() with a parameter, which is incorrect syntax as cache() does not accept parameters. Option B and C use persist() and cache() without specifying the storage level, defaulting to MEMORY_AND_DISK, which is not what the question asks for. Option D correctly uses persist() with the MEMORY_ONLY storage level. Option E incorrectly passes a string to persist(), which is not the correct way to specify the storage level.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
Which of the following code blocks attempts to cache only the partitions of DataFrame storesDF in Spark's memory?
A
storesDF.cache(StorageLevel.MEMORY_ONLY).count()
B
storesDF.persist().count()
C
storesDF.cache().count()
D
storesDF.persist(StorageLevel.MEMORY_ONLY).count()
E
storesDF.persist("MEMORY_ONLY").count()
No comments yet.