/** * 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."); } } }
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()); }