xdb

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderInfoLength      = 256
	VectorIndexRows       = 256
	VectorIndexCols       = 256
	VectorIndexSize       = 8
	SegmentIndexBlockSize = 14
)

Variables

This section is empty.

Functions

func CheckIP

func CheckIP(ip string) (uint32, error)

func LoadContent

func LoadContent(handle *os.File) ([]byte, error)

LoadContent load the whole xdb content from the specified file handle

func LoadContentFromFile

func LoadContentFromFile(dbFile string) ([]byte, error)

LoadContentFromFile load the whole xdb content from the specified db file path

func LoadVectorIndex

func LoadVectorIndex(handle *os.File) ([]byte, error)

LoadVectorIndex util function to load the vector index from the specified file handle

func LoadVectorIndexFromFile

func LoadVectorIndexFromFile(dbFile string) ([]byte, error)

LoadVectorIndexFromFile load vector index from a specified file path

func Long2IP

func Long2IP(ip uint32) string

func MidIP

func MidIP(sip uint32, eip uint32) uint32

Types

type Header struct {
	// data []byte
	Version       uint16
	IndexPolicy   IndexPolicy
	CreatedAt     uint32
	StartIndexPtr uint32
	EndIndexPtr   uint32
}

func LoadHeader

func LoadHeader(handle *os.File) (*Header, error)

LoadHeader load the header info from the specified handle

func LoadHeaderFromBuff

func LoadHeaderFromBuff(cBuff []byte) (*Header, error)

LoadHeaderFromBuff wrap the header info from the content buffer

func LoadHeaderFromFile

func LoadHeaderFromFile(dbFile string) (*Header, error)

LoadHeaderFromFile load header info from the specified db file path

func NewHeader

func NewHeader(input []byte) (*Header, error)

type IndexPolicy

type IndexPolicy int
const (
	VectorIndexPolicy IndexPolicy = 1
	BTreeIndexPolicy  IndexPolicy = 2
)

func (IndexPolicy) String

func (i IndexPolicy) String() string

type IpInfo

type IpInfo struct {
	Country  string //国家
	Region   string //区域
	Province string
	City     string //城市
	ISP      string //运营商
	IP       string //IP
}

type Searcher

type Searcher struct {
	// contains filtered or unexported fields
}

func NewWithBuffer

func NewWithBuffer(cBuff []byte) (*Searcher, error)

func NewWithFileOnly

func NewWithFileOnly(dbFile string) (*Searcher, error)

func NewWithVectorIndex

func NewWithVectorIndex(dbFile string, vIndex []byte) (*Searcher, error)

func (*Searcher) Close

func (s *Searcher) Close()

func (*Searcher) GetIOCount

func (s *Searcher) GetIOCount() int

GetIOCount return the global io count for the last search

func (*Searcher) Search

func (s *Searcher) Search(ip uint32) (string, error)

Search find the region for the specified long ip

func (*Searcher) SearchByCustomInfo

func (s *Searcher) SearchByCustomInfo(str string) (IpInfo, error)

func (*Searcher) SearchByStr

func (s *Searcher) SearchByStr(str string) (string, error)

SearchByStr find the region for the specified ip string

Jump to

Keyboard shortcuts

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