MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / PickRandomKey

Method PickRandomKey

tensorflow/core/lib/io/table_test.cc:398–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396 }
397
398 string PickRandomKey(random::SimplePhilox* rnd,
399 const std::vector<string>& keys) {
400 if (keys.empty()) {
401 return "foo";
402 } else {
403 const int index = rnd->Uniform(keys.size());
404 string result = keys[index];
405 switch (rnd->Uniform(3)) {
406 case 0:
407 // Return an existing key
408 break;
409 case 1: {
410 // Attempt to return something smaller than an existing key
411 if (!result.empty() && result[result.size() - 1] > '\0') {
412 result[result.size() - 1]--;
413 }
414 break;
415 }
416 case 2: {
417 // Return something larger than an existing key
418 Increment(&result);
419 break;
420 }
421 }
422 return result;
423 }
424 }
425
426 private:
427 Options options_;

Callers

nothing calls this directly

Calls 4

IncrementFunction · 0.85
UniformMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected