caching_BPT/caching_SBPT did NOT really cache a heck, sinche $cache was the local variable!

also, fixed broken pass-by-ref which broke loose search for SBPT
This commit is contained in:
real_nowhereman 2009-11-17 15:25:45 +00:00
parent 33abf7dcf1
commit 1f7fcf6f38

View File

@ -1759,8 +1759,8 @@ class BPlusTree {
* @param $key target key
* @returns bool false if key does not exists, true otherwise
*/
function has_key($key) {
if (@$this->getitem($key)!==false) {
function has_key(&$key, $loose=false) {
if (@$this->getitem($key, $loose)!==false) {
return true;
} else {
return false;
@ -2510,9 +2510,12 @@ class caching_BPT extends BPlusTree {
var $cache = array();
function getitem(&$key, $loose=false) {
if (isset($cache[$key]))
return $cache[$key];
else return ($cache[$key] = parent::getitem($key, $loose));
if (isset($this->cache[$key]))
return $this->cache[$key];
else {
$this->cache[$key] = parent::getitem($key, $loose);
return $this->cache[$key];
}
}
function resetcache() {
@ -2577,7 +2580,7 @@ class SBPlusTree extends BPlusTree {
* @param $key target key
* @returns int seek point if key exists, 0 otherwise
*/
function has_key($key, $loose=false) {
function has_key(&$key, $loose=false) {
return @parent::getitem($key, $loose);
}
@ -2628,9 +2631,13 @@ class caching_SBPT extends SBPlusTree {
}
function getitem(&$key, $loose=false) {
if (isset($cache[$key]))
return $cache[$key];
else return ($cache[$key] = parent::getitem($key, $loose));
if (isset($this->cache[$key]))
return $this->cache[$key];
else {
$item = parent::getitem($key, $loose);
$this->cache[$key] = $item;
return $item;
}
}
function resetcache() {