MCPcopy Create free account
hub / github.com/apache/arrow / RandomSequenceSpans

Method RandomSequenceSpans

cpp/src/arrow/util/future_test.cc:1411–1423  ·  view source on GitHub ↗

Generate a sequence of randomly-sized ordered spans covering exactly [0, size). Returns a vector of (start, stop) pairs.

Source from the content-addressed store, hash-verified

1409 // Generate a sequence of randomly-sized ordered spans covering exactly [0, size).
1410 // Returns a vector of (start, stop) pairs.
1411 std::vector<std::pair<int, int>> RandomSequenceSpans(int size) {
1412 std::default_random_engine gen(seed_++);
1413 // The distribution of span sizes
1414 std::poisson_distribution<int> dist(5);
1415 std::vector<std::pair<int, int>> spans;
1416 int start = 0;
1417 while (start < size) {
1418 int stop = std::min(start + dist(gen), size);
1419 spans.emplace_back(start, stop);
1420 start = stop;
1421 }
1422 return spans;
1423 }
1424
1425 void AssertAllNotFinished(const std::vector<int>& future_indices) {
1426 const auto& futures = executor_->futures();

Callers

nothing calls this directly

Calls 1

emplace_backMethod · 0.80

Tested by

no test coverage detected