Skip to content

Commit f424dee

Browse files
committed
cap count to QSL->TotalSampleCount()
1 parent 940612d commit f424dee

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

loadgen/loadgen.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,13 @@ std::vector<LoadableSampleSet> GenerateLoadableSets(
635635
std::vector<LoadableSampleSet> result;
636636
std::mt19937 qsl_rng(settings.qsl_rng_seed);
637637

638+
// Cap sample count to QSL's actual total to avoid out-of-range indices.
639+
const size_t qsl_total_count = qsl->TotalSampleCount();
640+
const size_t effective_sample_count = std::min(total_sample_count, qsl_total_count);
641+
638642
// Generate indices for the specified sample count.
639-
std::vector<QuerySampleIndex> samples(total_sample_count);
640-
for (size_t i = 0; i < total_sample_count; i++) {
643+
std::vector<QuerySampleIndex> samples(effective_sample_count);
644+
for (size_t i = 0; i < effective_sample_count; i++) {
641645
samples[i] = static_cast<QuerySampleIndex>(i);
642646
}
643647

0 commit comments

Comments
 (0)