diff --git a/binding/php/XdbSearcher.class.php b/binding/php/XdbSearcher.class.php index ade4a87..d5292d7 100644 --- a/binding/php/XdbSearcher.class.php +++ b/binding/php/XdbSearcher.class.php @@ -133,7 +133,7 @@ class XdbSearcher // read the segment index $buff = $this->read($p, self::SegmentIndexSize); if ($buff == null) { - throw new Exception("failed to read segment index at ${$p}"); + throw new Exception("failed to read segment index at ${p}"); } $sip = self::getLong($buff, 0); @@ -296,16 +296,6 @@ class XdbSearcher return self::loadVectorIndex($handle); } - // load vector index from the specified buffer - public static function loadVectorIndexFromBuff($cBuff) { - $len = self::VectorIndexRows * self::VectorIndexCols * self::SegmentIndexSize; - if (strlen($cBuff) < (self::HeaderInfoLength + $len)) { - return null; - } - - return substr($cBuff, self::HeaderInfoLength, $len); - } - // load the xdb content from a file handle public static function loadContent($handle) { if (fseek($handle, 0, SEEK_END) == -1) { diff --git a/binding/php/bench_test.php b/binding/php/bench_test.php index b37d1e3..c651572 100644 --- a/binding/php/bench_test.php +++ b/binding/php/bench_test.php @@ -171,4 +171,4 @@ fclose($handle); $searcher->close(); $cost = XdbSearcher::now() - $sTime; printf("Bench finished, {cachePolicy: %s, total: %d, took: %ds, cost: %.3f ms/op}\n", - $cachePolicy, $count, $cost/1000, $cost/$count); \ No newline at end of file + $cachePolicy, $count, $cost/1000, $cost/$count); diff --git a/binding/php/util_test.php b/binding/php/util_test.php index a90271e..072753e 100644 --- a/binding/php/util_test.php +++ b/binding/php/util_test.php @@ -29,22 +29,6 @@ function testLoadVectorIndex() { printf("vector index loaded: length=%d\n", strlen($vIndex)); } -function testLoadVectorIndexFromBuff() { - $cBuff = XdbSearcher::loadContentFromFile('../../data/ip2region.xdb'); - if ($cBuff == null) { - printf("failed to load content from file\n"); - return; - } - - $vIndex = XdbSearcher::loadVectorIndexFromBuff($cBuff); - if ($vIndex == null) { - printf("failed to load content from file\n"); - return; - } - - printf("vector index loaded, length=%d\n", strlen($vIndex)); -} - function testLoadContent() { $cBuff = XdbSearcher::loadContentFromFile('../../data/ip2region.xdb'); if ($cBuff == null) { @@ -67,12 +51,6 @@ testLoadVectorIndex(); printf("done, cost: %0.5f ms\n\n", XdbSearcher::now() - $now); -printf("testing loadVectorIndexFromBuff ... \n"); -$now = XdbSearcher::now(); -testLoadVectorIndexFromBuff(); -printf("done, cost: %0.5f ms\n\n", XdbSearcher::now() - $now); - - printf("testing loadContent ... \n"); $now = XdbSearcher::now(); testLoadContent();