dcapwell commented on code in PR #111:
URL:
https://github.com/apache/cassandra-easy-stress/pull/111#discussion_r4354388426
##########
src/main/kotlin/org/apache/cassandra/easystress/commands/Run.kt:
##########
@@ -611,59 +645,75 @@ class Run(
runners: List<WorkloadRunner>,
metrics: Metrics,
) {
- // The --populate flag can be overridden by the profile
+ val settings = resolvePopulateSettings(workload)
+ val generator = populateGenerator ?:
workload.instance.getPopulatePartitionKeyGenerator().orElse("sequence")
+
+ println("Prepopulating data with ${settings.rows} records per thread
($threads)")
+
+ if (settings.rows <= 0) {
+ return
+ }
+ println(
+ "Populate generator: $generator, batch: ${settings.batchSize}, " +
+ "delete ratio: ${settings.deleteRatio}, concurrency per
thread: ${settings.concurrency}",
+ )
+
+ ProgressBar("Populate Progress", settings.rows * threads,
ProgressBarStyle.ASCII).use { bar ->
+ // update the bar every second, starting 1 second from now, as a
daemon thread
+ val timer =
+ fixedRateTimer("progress-bar", true, 1000, 1000) {
+ bar.stepTo(metrics.populateRows.count +
metrics.populateErrors.count)
+ }
+
+ // each runner returns once all of its writes have completed
+ runners
+ .map { thread(start = true, isDaemon = false, name =
"populate-${it.context.thread}") { it.populate(settings, generator) } }
+ .forEach { it.join() }
+
+ timer.cancel()
+ bar.stepTo(metrics.populateRows.count +
metrics.populateErrors.count)
+ }
+ println("\nPre-populate complete: ${metrics.populateRows.count} rows
written, ${metrics.populateErrors.count} rows failed.")
+ }
+
+ /**
+ * Works out the populate settings. A workload's populate option
overrides --populate, and the
+ * --populate.* flags win over the workload's choice where both exist.
+ */
+ private fun resolvePopulateSettings(workload: Workload): PopulateSettings {
val option = workload.instance.getPopulateOption(this)
- var deletes = true
- val max =
+ val rows =
when (option) {
- is PopulateOption.Standard -> {
- populate
- }
+ is PopulateOption.Standard -> if (populate ==
PopulateRowsConverter.ALL) partitionCount * populateBatch else populate
is PopulateOption.Custom -> {
println("Using workload specific populate options of
${option.rows}")
- deletes = option.deletes
- if (!deletes) {
- println("Not doing deletes in populate phase")
- }
option.rows
}
}
- println("Prepopulating data with $max records per thread ($threads)")
+ val workloadDeleteRatio = if (option is PopulateOption.Custom &&
!option.deletes) 0.0 else null
+ val deleteRatio = populateDeleteRatio ?: workloadDeleteRatio ?: 0.0
Review Comment:
workloadDeleteRatio is either 0.0 or null, and it is immediately followed by
?: 0.0. Thus workloadDeleteRatio ?: 0.0 evaluates to 0.0 in all cases
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]