1.2 KiB
1.2 KiB
Basic Graph - Random Number Generator
This example demonstrates a databuild_job that generates a random number seeded based on the partition ref.
Configure
$ bazel run //:generate_number_job.cfg test_output
{"outputs":["test_output"],"inputs":[],"args":["test_output"],"env":{}}
Execute
Generates a random number based on the hash of the partition ref and writes it to the output file.
$ bazel run //:generate_number_job.cfg test_output | bazel run //:generate_number_job
This will generate a random number for the partition "test_output" and write it to a file named "test_output".
You can verify that the random number is stable for the same partition ref by running the command multiple times:
$ bazel run //:generate_number_job.cfg test_output1 | bazel run //:generate_number_job
$ bazel run //:generate_number_job.cfg test_output1 | bazel run //:generate_number_job
And you can verify that different partition refs produce different random numbers:
$ bazel run //:generate_number_job.cfg test_output1 | bazel run //:generate_number_job
$ bazel run //:generate_number_job.cfg test_output2 | bazel run //:generate_number_job