/usr/share/php/arc/store/ARC2_StoreQueryHandler.php is in libarc-php 2.2.5-1ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | <?php
/**
* ARC2 RDF Store Query Handler
*
* @author Benjamin Nowack
* @license <http://arc.semsol.org/license>
* @homepage <http://arc.semsol.org/>
* @package ARC2
* @version 2010-11-16
*/
ARC2::inc('Class');
class ARC2_StoreQueryHandler extends ARC2_Class {
function __construct($a, &$caller) {
parent::__construct($a, $caller);
}
function __init() {/* db_con */
parent::__init();
$this->xsd = 'http://www.w3.org/2001/XMLSchema#';
$this->allow_extension_functions = $this->v('store_allow_extension_functions', 1, $this->a);
$this->keep_time_limit = $this->v('keep_time_limit', 0, $this->a);
$this->handler_type = '';
}
/* */
function getTermID($val, $term = '') {
return $this->store->getTermID($val, $term);
}
function hasHashColumn($tbl) {
return $this->store->hasHashColumn($tbl);
}
function getValueHash($val) {
return $this->store->getValueHash($val);
}
/* */
function getTripleTable() {
$r = $this->store->getTablePrefix() . 'triple';
return $r;
}
/* */
function createMergeTable() {
$split_ps = $this->store->getSetting('split_predicates', array());
if (!$split_ps) return 1;
$this->mrg_table_id = 'MRG_' . $this->store->getTablePrefix() . crc32(uniqid(rand()));
$con = $this->store->getDBCon();
$this->queryDB("FLUSH TABLES", $con);
$indexes = $this->v('store_indexes', array('sp (s,p)', 'os (o,s)', 'po (p,o)'), $this->a);
$index_code = $indexes ? 'KEY ' . join(', KEY ', $indexes) . ', ' : '';
$prefix = $this->store->getTablePrefix();
$sql = "
CREATE TEMPORARY TABLE IF NOT EXISTS " . $prefix . "triple_all (
t mediumint UNSIGNED NOT NULL,
s mediumint UNSIGNED NOT NULL,
p mediumint UNSIGNED NOT NULL,
o mediumint UNSIGNED NOT NULL,
o_lang_dt mediumint UNSIGNED NOT NULL,
o_comp char(35) NOT NULL, /* normalized value for ORDER BY operations */
s_type tinyint(1) NOT NULL default 0, /* uri/bnode => 0/1 */
o_type tinyint(1) NOT NULL default 0, /* uri/bnode/literal => 0/1/2 */
misc tinyint(1) NOT NULL default 0, /* temporary flags */
UNIQUE KEY (t), " . $index_code . " KEY (misc)
)
";
$v = $this->store->getDBVersion();
$sql .= (($v < '04-01-00') && ($v >= '04-00-18')) ? 'ENGINE' : (($v >= '04-01-02') ? 'ENGINE' : 'TYPE');
$sql .= "=MERGE UNION=(" . $prefix . "triple" ;
foreach ($split_ps as $pos => $p) {
$sql .= ',' . $prefix . 'triple_' . abs(crc32($p));
}
$sql .= ")";
//$sql .= ($v >= '04-00-00') ? " CHARACTER SET utf8" : "";
//$sql .= ($v >= '04-01-00') ? " COLLATE utf8_unicode_ci" : "";
//echo $sql;
return $this->queryDB($sql, $con);
}
function dropMergeTable() {
return 1;
$sql = "DROP TABLE IF EXISTS " . $this->store->getTablePrefix() . "triple_all";
//echo $sql;
return $this->queryDB($sql, $this->store->getDBCon());
}
}
|