Browse files

Worker ID and segment ID starts from 1 instead of 0.

  • Loading branch information...
1 parent e437ba6 commit c4d9dbb35870b1cee7f1983a0a03cf6eeb6446ff @cliffano committed Jun 22, 2012
Showing with 8 additions and 7 deletions.
  1. +1 −0 CHANGELOG.md
  2. +4 −4 README.md
  3. +1 −1 lib/datagen.js
  4. +2 −2 test/datagen.js
View
1 CHANGELOG.md
@@ -1,5 +1,6 @@
### 0.0.3 (SNAPSHOT)
* Worker write no longer streams non-stop, better handling of fs backpressure
+* Worker ID and segment ID starts from 1 instead of 0
### 0.0.2
* Rename run command to gen
View
8 README.md
@@ -27,18 +27,18 @@ Templates
DataGen uses three template files: header, segment, and footer. These templates are simple text files which are used to construct a data file in this format:
header
- segment 0
segment 1
+ segment 2
...
- segment N (number of segments - 1)
+ segment N (number of segments)
footer
Templates can contain the following parameters:
<table>
<tr><td>{gen_id}</td><td>Unique to each datagen execution. Default value is master process PID, can be overridden via -i flag.</td></tr>
-<tr><td>{worker_id}</td><td>Unique to each worker. Value from 0 to number of workers - 1.</td></tr>
-<tr><td>{segment_id}</td><td>Unique to each segment within the generated data file, repeated in each file. Value from 0 to number of segments - 1. Not available in header and footer templates.</td></tr>
+<tr><td>{worker_id}</td><td>Unique to each worker. Value from 1 to number of workers.</td></tr>
+<tr><td>{segment_id}</td><td>Unique to each segment within the generated data file, repeated in each file. Value from 1 to number of segments. Not available in header and footer templates.</td></tr>
<tr><td>{integer()}</td><td>Random integer.</td></tr>
<tr><td>{integer(100, 200)}</td><td>Random integer between 100 and 200.</td></tr>
<tr><td>{float()}</td><td>random float.</td></tr>
View
2 lib/datagen.js
@@ -45,7 +45,7 @@ DataGen.prototype.generate = function (genId, numSegments, numWorkers, outFile)
for (var i = 0; i < numWorkers; i += 1) {
var worker = childProcess.fork(p.join(__dirname, 'worker.js'));
worker.send({
- workerId: i,
+ workerId: i + 1,
templates: templates,
genId: genId,
numSegments: numSegments,
View
4 test/datagen.js
@@ -68,7 +68,7 @@ describe('datagen', function () {
// only 1 worker by default
checks.child_process_fork_sends.length.should.equal(1);
- checks.child_process_fork_sends[0].workerId.should.equal(0);
+ checks.child_process_fork_sends[0].workerId.should.equal(1);
checks.child_process_fork_sends[0].genId.should.equal('56789');
checks.child_process_fork_sends[0].numSegments.should.equal(1);
checks.child_process_fork_sends[0].outFile.should.equal('data');
@@ -81,7 +81,7 @@ describe('datagen', function () {
// one message for each worker
checks.child_process_fork_sends.length.should.equal(8);
- checks.child_process_fork_sends[0].workerId.should.equal(0);
+ checks.child_process_fork_sends[0].workerId.should.equal(1);
checks.child_process_fork_sends[0].genId.should.equal('12345');
checks.child_process_fork_sends[0].numSegments.should.equal(10000);
checks.child_process_fork_sends[0].outFile.should.equal('somedatafile');

0 comments on commit c4d9dbb

Please sign in to comment.