本文整理汇总了PHP中EasyRdf_Graph::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyRdf_Graph::isEmpty方法的具体用法?PHP EasyRdf_Graph::isEmpty怎么用?PHP EasyRdf_Graph::isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EasyRdf_Graph
的用法示例。
在下文中一共展示了EasyRdf_Graph::isEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Perform the load.
*
* @param EasyRdf_Graph $chunk
* @return void
*/
public function execute(&$chunk)
{
if (!$chunk->isEmpty()) {
// Don't use EasyRdf's ntriple serializer, as something might be wrong with its unicode byte characters
// After serializing with semsol/arc and easyrdf, the output looks the same (with unicode characters), but after a
// binary utf-8 conversion (see $this->serialize()) the outcome is very different, leaving easyrdf's encoding completely different
// from the original utf-8 characters, and the semsol/arc encoding correct as the original.
$ttl = $chunk->serialise('turtle');
$arc_parser = \ARC2::getTurtleParser();
$ser = \ARC2::getNTriplesSerializer();
$arc_parser->parse('', $ttl);
$triples = $ser->getSerializedTriples($arc_parser->getTriples());
preg_match_all("/(<.*\\.)/", $triples, $matches);
if ($matches[0]) {
$this->buffer = array_merge($this->buffer, $matches[0]);
}
$triple_count = count($matches[0]);
$this->log("Added {$triple_count} triples to the load buffer.");
while (count($this->buffer) >= $this->loader->buffer_size) {
// Log the time it takes to load the triples into the store
$start = microtime(true);
$buffer_size = $this->loader->buffer_size;
$triples_to_send = array_slice($this->buffer, 0, $buffer_size);
$this->addTriples($triples_to_send);
$this->buffer = array_slice($this->buffer, $buffer_size);
$duration = round((microtime(true) - $start) * 1000, 2);
$this->log("Took {$buffer_size} triples from the load buffer, loading them took {$duration} ms.");
}
}
}
示例2: testIsEmptyAfterDelete
public function testIsEmptyAfterDelete()
{
$graph = new EasyRdf_Graph();
$graph->add('http://example.com/', 'rdfs:label', 'Example');
$graph->delete('http://example.com/', 'rdfs:label');
$this->assertTrue($graph->isEmpty());
}