geo

package
v1.24.10 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ID                 string
	CoordinatesForID   CoordinatesForID
	DisablePersistence bool
	RootPath           string
	Logger             logrus.FieldLogger
}

Config is passed to the GeoIndex when its created

type CoordinatesForID

type CoordinatesForID func(ctx context.Context, id uint64) (*models.GeoCoordinates, error)

CoordinatesForID must provide the geo coordinates for the specified index id

func (CoordinatesForID) VectorForID

func (cfid CoordinatesForID) VectorForID(ctx context.Context, id uint64) ([]float32, error)

VectorForID transforms the geo coordinates into a "vector" of fixed length two, where element 0 represents the latitude and element 1 represents the longitude. This way it is usable by a generic vector index such as HNSW

type Index

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

Index wraps another index to provide geo searches. This allows us to reuse the hnsw vector index, without making geo searches dependent on hnsw-specific features.

In the future we could use this level of abstraction to provide a better suited geo-index if we deem it necessary

func NewIndex

func NewIndex(config Config,
	commitLogMaintenanceCallbacks, tombstoneCleanupCallbacks,
	compactionCallbacks, flushCallbacks cyclemanager.CycleCallbackGroup,
) (*Index, error)

func (*Index) Add

func (i *Index) Add(id uint64, coordinates *models.GeoCoordinates) error

Add extends the index with the specified GeoCoordinates. It is thread-safe and can be called concurrently.

func (*Index) Delete

func (i *Index) Delete(id uint64) error

func (*Index) Drop

func (i *Index) Drop(ctx context.Context) error

func (*Index) PostStartup

func (i *Index) PostStartup()

func (*Index) WithinRange

func (i *Index) WithinRange(ctx context.Context,
	geoRange filters.GeoRange,
) ([]uint64, error)

WithinGeoRange searches the index by the specified range. It is thread-safe and can be called concurrently.

Jump to

Keyboard shortcuts

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