myxdb

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func CheckIP

func CheckIP(ip string) (uint32, error)

func CheckSegments

func CheckSegments(segList []*Segment) error

func IterateSegments

func IterateSegments(handle *os.File, before func(l string), cb func(seg *Segment) error) error

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 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 Maker

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

func NewMaker

func NewMaker(policy IndexPolicy, srcFile string, dstFile string) (*Maker, error)

func (*Maker) End

func (m *Maker) End() error

func (*Maker) Init

func (m *Maker) Init() error

Init the db binary file

func (*Maker) Start

func (m *Maker) Start() error

Start to make the binary file

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) SearchByStr

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

SearchByStr find the region for the specified ip string

type Segment

type Segment struct {
	StartIP uint32
	EndIP   uint32
	Region  string
}

func SegmentFrom

func SegmentFrom(seg string) (*Segment, error)

func (*Segment) AfterCheck

func (s *Segment) AfterCheck(last *Segment) error

AfterCheck check the current segment is the one just after the specified one

func (*Segment) Split

func (s *Segment) Split() []*Segment

Split the segment based on the pre-two bytes

func (*Segment) String

func (s *Segment) String() string

type XDBMaker

type XDBMaker struct {
	*Maker
}

func NewXDBMakerByBtree

func NewXDBMakerByBtree(srcFile string, dstFile string) (ret *XDBMaker, err error)

func NewXDBMakerByVector

func NewXDBMakerByVector(srcFile string, dstFile string) (ret *XDBMaker, err error)

func (*XDBMaker) GenXDBFile

func (self *XDBMaker) GenXDBFile() error

type XDBSearcher

type XDBSearcher struct {
	*Searcher
}

func NewXDBSearcher

func NewXDBSearcher(filePath string) (ret *XDBSearcher, err error)

func (*XDBSearcher) Search

func (self *XDBSearcher) Search(ipaddr string) string

Jump to

Keyboard shortcuts

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