Skip to content

Commit

Permalink
Merge pull request #71 from talis/in-place-updates
Browse files Browse the repository at this point in the history
90% - In place updates
  • Loading branch information
Chris Clarke committed Jul 8, 2015
2 parents 3c73c7e + a0206f5 commit bb37b5f
Show file tree
Hide file tree
Showing 24 changed files with 30,538 additions and 255 deletions.
3 changes: 2 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<property name="output.dir" location="output" />
<property name="codecoverage.dir" location="${output.dir}/codecoverage" />
<property name="unit.test.dir" location="${test.dir}/unit" />
<property name="perf.test.dir" location="${test.dir}/performance" />
<property name="test" value="**" />

<!-- targets -->
Expand Down Expand Up @@ -62,7 +63,7 @@
</target>

<target name="perftest" depends="init" description="Runs the performance test suite">
<exec dir="${test.dir}/performance" executable="${vendor.dir}/bin/phpunit" failonerror="true">
<exec dir="${perf.test.dir}" executable="${vendor.dir}/bin/phpunit" failonerror="true">
<arg line="--filter ${test} --log-junit ${output.dir}/performanceTest-report.xml" />
</exec>
</target>
Expand Down
3 changes: 2 additions & 1 deletion src/classes/ExtendedGraph.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ public function add_turtle($turtle, $base='') {
/** @var \ARC2_TurtleParser $parser */
$parser = \ARC2::getTurtleParser();
$parser->parse($base, $turtle );
$this->_add_arc2_triple_list($parser->getTriples());
$triples = $parser->getTriples();
$this->_add_arc2_triple_list($triples);
unset($parser);
}
}
Expand Down
31 changes: 30 additions & 1 deletion src/mongo/Config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,17 @@ private static function getQueueName($envVar,$type)
*/
public static function getResqueServer()
{
return self::getenv(MONGO_TRIPOD_RESQUE_SERVER,"localhost:6379");
$resqueServer = self::getenv(RESQUE_SERVER,'');
if (empty($resqueServer))
{
$resqueServer = self::getenv(MONGO_TRIPOD_RESQUE_SERVER,'');
self::getLogger()->addNotice("Use of MONGO_TRIPOD_RESQUE_SERVER is deprecated - use RESQUE_SERVER instead");
}
if (empty($resqueServer))
{
$resqueServer = "localhost:6379";
}
return $resqueServer;
}

/**
Expand All @@ -2079,4 +2089,23 @@ private static function getenv($env, $default = false)
}
throw new \Tripod\Exceptions\ConfigException("Missing value for environmental variable $env");
}

/**
* @var \Psr\Log\LoggerInterface
*/
protected static $logger;

/**
* @static
* @return \Psr\Log\LoggerInterface;
*/
public static function getLogger()
{
if (self::$logger == null)
{
$log = new \Monolog\Logger('TRIPOD');
self::$logger = $log;
}
return self::$logger;
}
}
10 changes: 9 additions & 1 deletion src/mongo/MongoTripodConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
define('OP_ASYNC', 'async');
define('OP_QUEUE', 'queue');

// operands provided by mongo
define("MONGO_OPERATION_SET",'$set');
define("MONGO_OPERATION_INC",'$inc');
define("MONGO_OPERATION_UNSET",'$unset');
define("MONGO_OPERATION_GTE",'$gte');
define("MONGO_OPERATION_LTE",'$lte');

// query types, used mainly for logging
define('MONGO_SELECT','MONGO_SELECT');
define('MONGO_DESCRIBE','MONGO_DESCRIBE');
Expand Down Expand Up @@ -80,7 +87,8 @@
define('DEFAULT_MONGO_CONNECT_TIMEOUT_MS', 20000);

// queue constants
define("MONGO_TRIPOD_RESQUE_SERVER","MONGO_TRIPOD_RESQUE_SERVER");
define("RESQUE_SERVER","RESQUE_SERVER");
define("MONGO_TRIPOD_RESQUE_SERVER","MONGO_TRIPOD_RESQUE_SERVER"); // deprecated, will be removed in future releases
define("TRIPOD_DISCOVER_QUEUE","TRIPOD_DISCOVER_QUEUE");
define("TRIPOD_APPLY_QUEUE","TRIPOD_APPLY_QUEUE");

37 changes: 20 additions & 17 deletions src/mongo/base/DriverBase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,30 +307,33 @@ protected function expandSequence(&$joins, $source)
* @param array &$target
* @throws \InvalidArgumentException
*/
protected function addIdToImpactIndex(array $id, &$target)
protected function addIdToImpactIndex(array $id, &$target, $buildImpactIndex=true)
{
if(isset($id[_ID_RESOURCE]))
if ($buildImpactIndex)
{
// Ensure that our id is curie'd
$id[_ID_RESOURCE] = $this->labeller->uri_to_alias($id[_ID_RESOURCE]);
if (!isset($target[_IMPACT_INDEX]))
if(isset($id[_ID_RESOURCE]))
{
$target[_IMPACT_INDEX] = array();
}
if(!in_array($id, $target[_IMPACT_INDEX]))
{
$target[_IMPACT_INDEX][] = $id;
// Ensure that our id is curie'd
$id[_ID_RESOURCE] = $this->labeller->uri_to_alias($id[_ID_RESOURCE]);
if (!isset($target[_IMPACT_INDEX]))
{
$target[_IMPACT_INDEX] = array();
}
if(!in_array($id, $target[_IMPACT_INDEX]))
{
$target[_IMPACT_INDEX][] = $id;
}
}
}
else // Assume this is an array of ids
{
foreach($id as $i)
else // Assume this is an array of ids
{
if(!isset($i[_ID_RESOURCE]))
foreach($id as $i)
{
throw new \InvalidArgumentException("Invalid id format");
if(!isset($i[_ID_RESOURCE]))
{
throw new \InvalidArgumentException("Invalid id format");
}
$this->addIdToImpactIndex($i, $target);
}
$this->addIdToImpactIndex($i, $target);
}
}
}
Expand Down
Loading

0 comments on commit bb37b5f

Please sign in to comment.