parser

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultGeoHashOption = GeoOption{
	Precision:               6,
	CompressPrecisionMin:    3,
	CompressPrecisionCutoff: 6,
}
View Source
var ErrBadRangeValue = fmt.Errorf("NumberRangeParser need:'start:end:step'")

Functions

func ParseIntegerNumber

func ParseIntegerNumber(v interface{}, f2i bool) (n int64, err error)

func ParseIntergers added in v0.2.0

func ParseIntergers(v interface{}, f2i bool) (res []int64, err error)

Types

type CommonStrParser

type CommonStrParser struct {
	EnableFloat2Int bool
	StrIDAllocator  IDAllocator
}

func NewCommonParser added in v0.2.0

func NewCommonParser() *CommonStrParser

func (*CommonStrParser) Name added in v0.2.0

func (p *CommonStrParser) Name() string

func (*CommonStrParser) ParseAssign

func (p *CommonStrParser) ParseAssign(v interface{}) (values []uint64, e error)

func (*CommonStrParser) ParseValue

func (p *CommonStrParser) ParseValue(v interface{}) ([]uint64, error)

type FieldValueParser

type FieldValueParser interface {
	Name() string

	// ParseAssign parse query assign value into id-encoded ids
	ParseAssign(v interface{}) ([]uint64, error)

	// ParseValue parse bool expression value into id-encoded ids
	ParseValue(v interface{}) ([]uint64, error)
}

FieldValueParser turn value into a unique id

func NewNumRangeParser

func NewNumRangeParser() FieldValueParser

func NewStrHashParser

func NewStrHashParser() FieldValueParser

type GeoHashParser added in v0.2.0

type GeoHashParser struct {
	GeoOption
}

GeoHashParser turn value into a unique id parser a string fmt geohash region: "lat:lon:radius(m)" geohash长度 误差距离(km)

1	            ±2500
2	            ±630
3	            ±78
4	            ±20
5	            ±2.4
6	            ±0.61
7	            ±0.076
8	            ±0.019

func NewGeoHashParser added in v0.2.0

func NewGeoHashParser(option *GeoOption) *GeoHashParser

func (*GeoHashParser) Name added in v0.2.0

func (p *GeoHashParser) Name() string

func (*GeoHashParser) ParseAssign added in v0.2.0

func (p *GeoHashParser) ParseAssign(v interface{}) ([]uint64, error)

ParseAssign parse query assign value into id-encoded ids

func (*GeoHashParser) ParseValue added in v0.2.0

func (p *GeoHashParser) ParseValue(v interface{}) ([]uint64, error)

ParseValue parse bool expression value into id-encoded ids

type GeoOption added in v0.2.0

type GeoOption struct {
	Precision               int
	CompressPrecisionMin    int
	CompressPrecisionCutoff int
}

GeoHashParser turn value into a unique id parser a string fmt geohash region: "lat:lon:radius(m)" geohash长度 误差距离(km)

1	            ±2500
2	            ±630
3	            ±78
4	            ±20
5	            ±2.4
6	            ±0.61
7	            ±0.076
8	            ±0.019

func (*GeoOption) InitDefault added in v0.2.0

func (p *GeoOption) InitDefault()

type HashAllocator added in v0.2.0

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

func NewHashAllocator added in v0.2.0

func NewHashAllocator(fn func(string) uint64) *HashAllocator

func (*HashAllocator) AllocStringID added in v0.2.0

func (alloc *HashAllocator) AllocStringID(v string) uint64

func (*HashAllocator) FindStringID added in v0.2.0

func (alloc *HashAllocator) FindStringID(v string) (value uint64, found bool)

type IDAllocator

type IDAllocator interface {
	AllocStringID(v string) uint64
	FindStringID(v string) (value uint64, found bool)
}

func NewIDAllocatorImpl

func NewIDAllocatorImpl() IDAllocator

type IDAllocatorImpl

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

IDAllocatorImpl 用于将不同类型的值ID化,用于构造Index的PostingList,减少重复值

func (*IDAllocatorImpl) AllocStringID

func (alloc *IDAllocatorImpl) AllocStringID(v string) uint64

func (*IDAllocatorImpl) FindStringID

func (alloc *IDAllocatorImpl) FindStringID(v string) (value uint64, found bool)

func (*IDAllocatorImpl) TotalIDCount

func (alloc *IDAllocatorImpl) TotalIDCount() uint64

type NumberParser

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

func NewNumberParser

func NewNumberParser() *NumberParser

func NewNumberParser2

func NewNumberParser2(f2i bool) *NumberParser

func (*NumberParser) Name added in v0.2.0

func (p *NumberParser) Name() string

func (*NumberParser) ParseAssign

func (p *NumberParser) ParseAssign(v interface{}) (values []uint64, e error)

func (*NumberParser) ParseValue

func (p *NumberParser) ParseValue(v interface{}) ([]uint64, error)

type NumberRangeParser

type NumberRangeParser struct {
}

NumberRangeParser format: start:end:step; the `step` is optional

func (*NumberRangeParser) Name added in v0.2.0

func (p *NumberRangeParser) Name() string

func (*NumberRangeParser) ParseAssign

func (p *NumberRangeParser) ParseAssign(v interface{}) (res []uint64, err error)

ParseAssign only single number supported, float will round into integer

func (*NumberRangeParser) ParseValue

func (p *NumberRangeParser) ParseValue(v interface{}) (res []uint64, err error)

type RangeDesc

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

NumberRangeParser parse syntax like format: start:end:step step ist optional, it will generate start, start+step, start+2*stem ....

func NewRangeDesc

func NewRangeDesc(v string) *RangeDesc

func (*RangeDesc) Values added in v0.2.0

func (rgd *RangeDesc) Values() (start, end, stepLen int64)

type StrHashParser

type StrHashParser struct{}

func (*StrHashParser) Name added in v0.2.0

func (p *StrHashParser) Name() string

func (*StrHashParser) ParseAssign

func (p *StrHashParser) ParseAssign(v interface{}) ([]uint64, error)

func (*StrHashParser) ParseValue

func (p *StrHashParser) ParseValue(v interface{}) ([]uint64, error)

ParseValue parse bool expression value into id-encoded ids

Jump to

Keyboard shortcuts

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