storage

package
v0.0.0-...-75a2702 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const Prefix = "TT"

Variables

View Source
var (
	// MaxGeoTime helper to query into the future
	MaxGeoTime = time.Unix(0, math.MaxInt64)

	// MinGeoTime helper to query into the past
	MinGeoTime = time.Unix(0, 0)
)

Functions

func DataKey

func DataKey(k string, t time.Time, lat, lng float64) []byte

func ListKey

func ListKey(k string) []byte

ListingKey returns the key used to list all keys

func PointKey

func PointKey(lat, lng float64, t time.Time, k string) []byte

PointKey returns the key generated for a position + id

func ReadDataKey

func ReadDataKey(dk []byte) (string, time.Time, float64, float64, error)

ReadDataKey returns the key, time, lat, lng note that lat lng will have a small delta compared to the original values induced by the s2 cell

func ReadPointKey

func ReadPointKey(pk []byte) (s2.CellID, time.Time, string, error)

ReadPointKey returns cell, time, key

func S2RadialAreaMeters

func S2RadialAreaMeters(radius float64) float64

func Uint64tob

func Uint64tob(v uint64) []byte

Types

type DataPoint

type DataPoint struct {
	Lat, Lng float64
	Key      string
	Value    []byte
	Time     time.Time
}

type Indexer

type Indexer interface {
	Store(k string, v []byte, lat, lng float64, t time.Time) error
	StoreTx(tx Tx, k string, v []byte, lat, lng float64, t time.Time) error
	Get(k string) (*DataPoint, error)
	Keys() ([]string, error)
	GetAll(k string, count int) ([]DataPoint, error)
	RadiusSearch(lat, lng, radius float64) ([]DataPoint, error)
	RectSearch(urlat, urlng, bllat, bllng float64) ([]DataPoint, error)
	Begin() Tx
}

type Tx

type Tx interface {
	Discard()
	Commit() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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