Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add configuration to enable in-memory table scan accumulators.
  • Loading branch information
viirya committed Apr 12, 2015
commit 26c9bb61b70391f2408bbb0846a8e486baf3ec4d
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,24 @@ private[sql] case class InMemoryColumnarTableScan(
}
}

lazy val enableAccumulators: Boolean =
sqlContext.getConf("spark.sql.inMemoryTableScanStatistics.enable", "false").toBoolean

// Accumulators used for testing purposes
val (readPartitions, readBatches) = relation.applyScanAccumulators(sparkContext)
lazy val (readPartitions, readBatches) =
if (enableAccumulators) {
relation.applyScanAccumulators(sparkContext)
} else {
(null, null)
}

private val inMemoryPartitionPruningEnabled = sqlContext.conf.inMemoryPartitionPruning

override def execute(): RDD[Row] = {
readPartitions.setValue(0)
readBatches.setValue(0)
if (enableAccumulators) {
readPartitions.setValue(0)
readBatches.setValue(0)
}

relation.cachedColumnBuffers.mapPartitions { cachedBatchIterator =>
val partitionFilter = newPredicate(
Expand Down Expand Up @@ -339,7 +349,7 @@ private[sql] case class InMemoryColumnarTableScan(
}
}

if (rows.hasNext) {
if (rows.hasNext && enableAccumulators) {
readPartitions += 1
}

Expand All @@ -358,7 +368,9 @@ private[sql] case class InMemoryColumnarTableScan(
logInfo(s"Skipping partition based on stats $statsString")
false
} else {
readBatches += 1
if (enableAccumulators) {
readBatches += 1
}
true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class PartitionBatchPruningSuite extends FunSuite with BeforeAndAfterAll with Be

// Enable in-memory partition pruning
setConf(SQLConf.IN_MEMORY_PARTITION_PRUNING, "true")
// Enable in-memory table scan accumulators
setConf("spark.sql.inMemoryTableScanStatistics.enable", "true")
Copy link
Member

@gatorsmile gatorsmile Jan 12, 2018

Choose a reason for hiding this comment

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

Why not setting spark.sql.inMemoryTableScanStatistics.enable back false in afterAll?

}

override protected def afterAll(): Unit = {
Expand Down