mirror of
https://github.com/gotoeasy/glogcenter.git
synced 2025-09-15 12:58:34 +08:00
重构优化
This commit is contained in:
parent
7f377038b4
commit
68317d8a0b
@ -16,7 +16,8 @@ import (
|
||||
)
|
||||
|
||||
type SearchResult struct {
|
||||
Total string `json:"total,omitempty"` // 总件数(用10进制字符串形式以避免出现科学计数法)
|
||||
Total string `json:"total,omitempty"` // 日志总量件数(用10进制字符串形式以避免出现科学计数法)
|
||||
Count string `json:"count,omitempty"` // 当前条件最多匹配件数(用10进制字符串形式以避免出现科学计数法)
|
||||
Data []*logdata.LogDataModel `json:"data,omitempty"` // 检索结果数据(日志文档数组)
|
||||
}
|
||||
|
||||
@ -113,6 +114,7 @@ func SearchWordIndex(storeName string, word string, pageSize int, currentDocId u
|
||||
idxwordStorage := indexword.NewWordIndexStorage(storeName, word) // 关键词索引
|
||||
totalCount := idxwordStorage.GetTotalCount(word) // 总件数
|
||||
rs.Total = cmn.Uint32ToString(logDataStorage.TotalCount()) // 返回的总件数用10进制字符串形式以避免出现科学计数法
|
||||
rs.Count = cmn.Uint32ToString(totalCount) // 当前条件最多匹配件数
|
||||
|
||||
if totalCount == 0 {
|
||||
return rs
|
||||
|
||||
@ -5,6 +5,7 @@ package search
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"glc/cmn"
|
||||
"glc/ldb/storage"
|
||||
"glc/ldb/storage/logdata"
|
||||
)
|
||||
@ -13,6 +14,7 @@ import (
|
||||
func findSame(pageSize int, currentDocId uint32, forward bool, storeLogData *storage.LogDataStorageHandle, widxs ...*WidxStorage) *SearchResult {
|
||||
|
||||
var rs = new(SearchResult)
|
||||
rs.Total = cmn.Uint32ToString(storeLogData.TotalCount()) // 日志总量件数
|
||||
|
||||
// 选个最短的索引
|
||||
cnt := len(widxs)
|
||||
@ -25,6 +27,7 @@ func findSame(pageSize int, currentDocId uint32, forward bool, storeLogData *sto
|
||||
minIdx = widxs[i]
|
||||
}
|
||||
}
|
||||
rs.Count = cmn.Uint32ToString(minCount) // 当前条件最多匹配件数
|
||||
|
||||
// 简单检查排除没结果的情景
|
||||
totalCount := minIdx.idxwordStorage.GetTotalCount(minIdx.word)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user