types

package
v0.0.0-...-918a76a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STANDARD //传统计算方法
	MEITUAN  //美团开放计算方法
	IMPROVED //优化的计算方法
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EngineOptions

type EngineOptions struct {
	NumShards           int //channel分片
	AddBuffer           int //add channel长度
	RemoveBuffer        int //remove channel长度
	SearchBuffer        int //channel长度
	SearchWorkerThreads int //每个搜索channel worker数量

	DefaultSearchOption *SearchOptions  //默认搜索配置
	IndexerOption       *IndexerOptions //索引器配置项
}

func (*EngineOptions) Init

func (o *EngineOptions) Init()

type IndexedDocument

type IndexedDocument struct {
	DocId     uint64      `msg:"id"`
	Latitude  float64     `msg:"lat"`
	Longitude float64     `msg:"long"`
	Fields    interface{} `msg:"f"`
}

固态存储中存储的struct

func (*IndexedDocument) DecodeMsg

func (z *IndexedDocument) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*IndexedDocument) EncodeMsg

func (z *IndexedDocument) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*IndexedDocument) MarshalBinary

func (z *IndexedDocument) MarshalBinary() (data []byte, err error)

marshal

func (*IndexedDocument) MarshalMsg

func (z *IndexedDocument) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*IndexedDocument) Msgsize

func (z *IndexedDocument) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*IndexedDocument) UnmarshalBinary

func (z *IndexedDocument) UnmarshalBinary(data []byte) error

unmarshal

func (*IndexedDocument) UnmarshalMsg

func (z *IndexedDocument) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type IndexerOptions

type IndexerOptions struct {
	RedisHost       string
	RedisPassword   string
	RedisDb         int
	HashSize        uint64  //hash分片大小
	GeoShard        uint64  //GEOHASH分片大小
	GeoPrecious     uint    //GEOHASH位数
	CenterLatitude  float64 //城市中心纬度
	CenterLongitude float64 //城市中心经度
	Location        string  //城市
}

type ScoredDocument

type ScoredDocument struct {
	Distance float64
	DocId    uint64
	Model    interface{} //为外围组装数据提供
}

排序的struct

type ScoredDocuments

type ScoredDocuments []*ScoredDocument

排序

func (ScoredDocuments) Len

func (docs ScoredDocuments) Len() int

func (ScoredDocuments) Less

func (docs ScoredDocuments) Less(i, j int) bool

func (ScoredDocuments) Swap

func (docs ScoredDocuments) Swap(i, j int)

type SearchOptions

type SearchOptions struct {
	Refresh   bool
	OrderDesc bool
	Timeout   time.Duration
	Accuracy  int             //计算进度
	Circles   int             //圈数,默认1,不扩散
	Excepts   map[uint64]bool //排除指定ID
	Filter    func(doc IndexedDocument) bool
}

可不设置的搜索参数

func (*SearchOptions) Init

func (o *SearchOptions) Init()

type SearchRequest

type SearchRequest struct {
	Latitude     float64
	Longitude    float64
	CountOnly    bool
	Offset       int
	Limit        int
	SearchOption *SearchOptions //可留空,使用引擎默认参数
}

搜索请求

type SearchResponse

type SearchResponse struct {
	Docs    ScoredDocuments //排序好的结果
	Timeout bool            //是否超时
	Count   int             //数量
}

搜索结果返回

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL