diff --git a/data.h b/data.h index 1a0b39a..fdd1d36 100644 --- a/data.h +++ b/data.h @@ -388,7 +388,7 @@ class Data : public JSON::Object, private TupleHelper JSON::Object object; // set the dirname - object.set("dirname", dirname); + object.set("directory", dirname); // set whether or not to remove object.set("remove", remove); diff --git a/init.cpp b/init.cpp index 7459d52..fddf0d2 100644 --- a/init.cpp +++ b/init.cpp @@ -238,7 +238,7 @@ Php::Value yothalotInit(Php::Parameters ¶ms) if (strcasecmp(params[0].rawValue(), "run") == 0) result = run(input); // check the type of task to run that is part of the mapreduce algorithm - if (strcasecmp(params[0].rawValue(), "kvmapper") == 0) result = kvmap(input); + if (strcasecmp(params[0].rawValue(), "kvmapper") == 0) result = kvmap(input); else if (strcasecmp(params[0].rawValue(), "mapper") == 0) result = map(input); else if (strcasecmp(params[0].rawValue(), "reducer") == 0) result = reduce(input); else if (strcasecmp(params[0].rawValue(), "finalizer") == 0) result = write(input); diff --git a/tests/WordCount.php b/tests/WordCount.php index 3dc4a7e..c0f4b5b 100644 --- a/tests/WordCount.php +++ b/tests/WordCount.php @@ -127,6 +127,7 @@ public function reduce($key, Yothalot\Values $values, Yothalot\Writer $writer) */ public function write($key, $value) { + // if we've not added the file yet if (!$this->file) { // the output file is stored on the gluster diff --git a/tests/test.kvlinecount.php b/tests/test.kvlinecount.php index 52c2499..579dfee 100644 --- a/tests/test.kvlinecount.php +++ b/tests/test.kvlinecount.php @@ -12,16 +12,25 @@ require_once('KvLineCount.php'); /** - * The output file on the gluster - * @var string + * The WordCount class wrote its output to a file on the distributed file + * system. To find out what the absolute path name of this file is on this + * machine, we make use of the Yothalot\Path class to turn the relative name + * into an absolute path (GlusterFS must be mounted on this machine) + * + * @var Yothalot\Path + */ +$path = new Yothalot\Path("linecount-results-kv.txt"); + +/** + * Unlink the result upon start, to make sure that we don't display the previous result. */ -$output = "linecount-results.txt"; +unlink($path->absolute()); /** * Create an instance of the WordCount algorithm * @var WordCount */ -$wordcount = new KvLineCount($output); +$wordcount = new KvLineCount($path->relative()); /** * We want to send this WordCount instance to the Yothalot master. To do this, @@ -61,17 +70,7 @@ function assign($job, $path) /** * Wait for the result of the map reduce job */ -$job->wait(); - -/** - * The WordCount class wrote its output to a file on the distributed file - * system. To find out what the absolute path name of this file is on this - * machine, we make use of the Yothalot\Path class to turn the relative name - * into an absolute path (GlusterFS must be mounted on this machine) - * - * @var Yothalot\Path - */ -$path = new Yothalot\Path($output); +$result = $job->wait(); /** * Show the found words diff --git a/tests/test.linecount.php b/tests/test.linecount.php index a3268ca..c45c653 100644 --- a/tests/test.linecount.php +++ b/tests/test.linecount.php @@ -12,16 +12,26 @@ require_once('LineCount.php'); /** - * The output file on the gluster - * @var string + * The WordCount class wrote its output to a file on the distributed file + * system. To find out what the absolute path name of this file is on this + * machine, we make use of the Yothalot\Path class to turn the relative name + * into an absolute path (GlusterFS must be mounted on this machine) + * + * @var Yothalot\Path + */ +$path = new Yothalot\Path("linecount-results.txt"); + + +/** + * Unlink the result upon start, to make sure that we don't display the previous result. */ -$output = "linecount-results.txt"; +unlink($path->absolute()); /** * Create an instance of the WordCount algorithm * @var WordCount */ -$wordcount = new LineCount($output); +$wordcount = new LineCount($path->relative()); /** * We want to send this WordCount instance to the Yothalot master. To do this, @@ -75,16 +85,6 @@ function assign($job, $path) */ $job->wait(); -/** - * The WordCount class wrote its output to a file on the distributed file - * system. To find out what the absolute path name of this file is on this - * machine, we make use of the Yothalot\Path class to turn the relative name - * into an absolute path (GlusterFS must be mounted on this machine) - * - * @var Yothalot\Path - */ -$path = new Yothalot\Path($output); - /** * Show the found words */ diff --git a/tests/test.wordcount.php b/tests/test.wordcount.php index 365dd77..9332223 100644 --- a/tests/test.wordcount.php +++ b/tests/test.wordcount.php @@ -14,6 +14,11 @@ */ $path = new Yothalot\Path("wordcount-results.txt"); +/** + * Unlink the result upon start, to make sure that we don't display the previous result. + */ +unlink($path->absolute()); + /** * Create an instance of the WordCount algorithm * @var WordCount