From 9ab6658e7d1f405c96dd7b2344012b2a3df4ccb8 Mon Sep 17 00:00:00 2001 From: "lei.tian" Date: Thu, 30 Jun 2022 19:43:56 +0800 Subject: [PATCH] fix search() elseif --- src/XdbSearcher.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/XdbSearcher.php b/src/XdbSearcher.php index fb1a883..1308b58 100644 --- a/src/XdbSearcher.php +++ b/src/XdbSearcher.php @@ -122,20 +122,18 @@ class XdbSearcher if ($this->vectorIndex != null) { $sPtr = self::getLong($this->vectorIndex, $idx); $ePtr = self::getLong($this->vectorIndex, $idx + 4); + } elseif ($this->contentBuff != null) { + $sPtr = self::getLong($this->contentBuff, self::HeaderInfoLength + $idx); + $ePtr = self::getLong($this->contentBuff, self::HeaderInfoLength + $idx + 4); } else { - if ($this->contentBuff != null) { - $sPtr = self::getLong($this->contentBuff, self::HeaderInfoLength + $idx); - $ePtr = self::getLong($this->contentBuff, self::HeaderInfoLength + $idx + 4); - } else { - // read the vector index block - $buff = $this->read(self::HeaderInfoLength + $idx, 8); - if ($buff === null) { - throw new \Exception("failed to read vector index at ${idx}"); - } - - $sPtr = self::getLong($buff, 0); - $ePtr = self::getLong($buff, 4); + // read the vector index block + $buff = $this->read(self::HeaderInfoLength + $idx, 8); + if ($buff === null) { + throw new \Exception("failed to read vector index at ${idx}"); } + + $sPtr = self::getLong($buff, 0); + $ePtr = self::getLong($buff, 4); } // printf("sPtr: %d, ePtr: %d\n", $sPtr, $ePtr);