indexes

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: Unlicense Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventPrefix        = I("evt")
	IdPrefix           = I("eid")
	FullIdPubkeyPrefix = I("fpc") // full id, pubkey, created at

	CreatedAtPrefix  = I("c--") // created at
	KindPrefix       = I("kc-") // kind, created at
	PubkeyPrefix     = I("pc-") // pubkey, created at
	KindPubkeyPrefix = I("kpc") // kind, pubkey, created at

	TagPrefix           = I("tc-") // tag, created at
	TagKindPrefix       = I("tkc") // tag, kind, created at
	TagPubkeyPrefix     = I("tpc") // tag, pubkey, created at
	TagKindPubkeyPrefix = I("tkp") // tag, kind, pubkey, created at
)

Variables

View Source
var CreatedAt = next()

CreatedAt is an index that allows search for the timestamp on the event.

3 prefix|8 timestamp|5 serial
View Source
var Event = next()

Event is the whole event stored in binary format

prefix|5 serial - event in binary format
View Source
var FullIdPubkey = next()

FullIdPubkey is an index designed to enable sorting and filtering of results found via other indexes, without having to decode the event.

3 prefix|5 serial|32 ID|8 pubkey hash|8 timestamp
View Source
var Id = next()

Id contains a truncated 8-byte hash of an event index. This is the secondary key of an event, the primary key is the serial found in the Event.

3 prefix|8 ID hash|5 serial
View Source
var Kind = next()

Kind

3 prefix|2 kind|8 timestamp|5 serial
View Source
var KindPubkey = next()

KindPubkey

3 prefix|2 kind|8 pubkey hash|8 timestamp|5 serial
View Source
var Pubkey = next()

Pubkey is a composite index that allows search by pubkey filtered by timestamp.

3 prefix|8 pubkey hash|8 timestamp|5 serial
View Source
var Tag = next()

Tag allows searching for a tag and filter by timestamp.

3 prefix|1 key letter|8 value hash|8 timestamp|5 serial
View Source
var TagKind = next()

TagKind

3 prefix|1 key letter|8 value hash|2 kind|8 timestamp|5 serial
View Source
var TagKindPubkey = next()

TagKindPubkey

3 prefix|1 key letter|8 value hash|2 kind|8 pubkey hash|8 bytes timestamp|5 byte serial
View Source
var TagPubkey = next()

TagPubkey allows searching for a pubkey, tag and timestamp.

3 prefix|1 key letter|8 value hash|8 pubkey hash|8 timestamp|5 serial

Functions

func CreatedAtVars

func CreatedAtVars() (ca *types.Uint64, ser *types.Uint40)

func EventVars

func EventVars() (ser *types.Uint40)

func FullIdPubkeyVars

func FullIdPubkeyVars() (
	ser *types.Uint40, fid *types.Id, p *types.PubHash, ca *types.Uint64,
)

func IdVars

func IdVars() (id *types.IdHash, ser *types.Uint40)

func Identify

func Identify(r io.Reader) (i int, err error)

func KindPubkeyVars

func KindPubkeyVars() (
	ki *types.Uint16, p *types.PubHash, ca *types.Uint64, ser *types.Uint40,
)

func KindVars

func KindVars() (ki *types.Uint16, ca *types.Uint64, ser *types.Uint40)

func PubkeyVars

func PubkeyVars() (p *types.PubHash, ca *types.Uint64, ser *types.Uint40)

func TagKindPubkeyVars

func TagKindPubkeyVars() (
	k *types.Letter, v *types.Ident, ki *types.Uint16, p *types.PubHash,
	ca *types.Uint64,
	ser *types.Uint40,
)

func TagKindVars

func TagKindVars() (
	k *types.Letter, v *types.Ident, ki *types.Uint16, ca *types.Uint64,
	ser *types.Uint40,
)

func TagPubkeyVars

func TagPubkeyVars() (
	k *types.Letter, v *types.Ident, p *types.PubHash, ca *types.Uint64,
	ser *types.Uint40,
)

func TagVars

func TagVars() (
	k *types.Letter, v *types.Ident, ca *types.Uint64, ser *types.Uint40,
)

Types

type Encs

type Encs []codec.I

type I

type I string

func Prefix

func Prefix(prf int) (i I)

Prefix returns the three byte human-readable prefixes that go in front of database indexes.

func (I) Write

func (i I) Write(w io.Writer) (n int, err error)

type P

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

func NewPrefix

func NewPrefix(prf ...int) (p *P)

func (*P) Bytes

func (p *P) Bytes() (b []byte)

func (*P) MarshalWrite

func (p *P) MarshalWrite(w io.Writer) (err error)

func (*P) UnmarshalRead

func (p *P) UnmarshalRead(r io.Reader) (err error)

type T

type T struct{ Encs }

T is a wrapper around an array of codec.I. The caller provides the Encs so they can then call the accessor methods of the codec.I implementation.

func CreatedAtDec

func CreatedAtDec(ca *types.Uint64, ser *types.Uint40) (enc *T)

func CreatedAtEnc

func CreatedAtEnc(ca *types.Uint64, ser *types.Uint40) (enc *T)

func EventDec

func EventDec(ser *types.Uint40) (enc *T)

func EventEnc

func EventEnc(ser *types.Uint40) (enc *T)

func FullIdPubkeyDec

func FullIdPubkeyDec(
	ser *types.Uint40, fid *types.Id, p *types.PubHash, ca *types.Uint64,
) (enc *T)

func FullIdPubkeyEnc

func FullIdPubkeyEnc(
	ser *types.Uint40, fid *types.Id, p *types.PubHash, ca *types.Uint64,
) (enc *T)

func IdDec

func IdDec(id *types.IdHash, ser *types.Uint40) (enc *T)

func IdEnc

func IdEnc(id *types.IdHash, ser *types.Uint40) (enc *T)

func KindDec

func KindDec(ki *types.Uint16, ca *types.Uint64, ser *types.Uint40) (enc *T)

func KindEnc

func KindEnc(ki *types.Uint16, ca *types.Uint64, ser *types.Uint40) (enc *T)

func KindPubkeyDec

func KindPubkeyDec(
	ki *types.Uint16, p *types.PubHash, ca *types.Uint64, ser *types.Uint40,
) (enc *T)

func KindPubkeyEnc

func KindPubkeyEnc(
	ki *types.Uint16, p *types.PubHash, ca *types.Uint64, ser *types.Uint40,
) (enc *T)

func New

func New(encoders ...codec.I) (i *T)

New creates a new indexes.T. The helper functions below have an encode and decode variant, the decode variant does not add the prefix encoder because it has been read by Identify or just is being read, and found because it was written for the prefix in the iteration.

func PubkeyDec

func PubkeyDec(p *types.PubHash, ca *types.Uint64, ser *types.Uint40) (enc *T)

func PubkeyEnc

func PubkeyEnc(p *types.PubHash, ca *types.Uint64, ser *types.Uint40) (enc *T)

func TagDec

func TagDec(
	k *types.Letter, v *types.Ident, ca *types.Uint64, ser *types.Uint40,
) (enc *T)

func TagEnc

func TagEnc(
	k *types.Letter, v *types.Ident, ca *types.Uint64, ser *types.Uint40,
) (enc *T)

func TagKindDec

func TagKindDec(
	k *types.Letter, v *types.Ident, ki *types.Uint16, ca *types.Uint64,
	ser *types.Uint40,
) (enc *T)

func TagKindEnc

func TagKindEnc(
	k *types.Letter, v *types.Ident, ki *types.Uint16, ca *types.Uint64,
	ser *types.Uint40,
) (enc *T)

func TagKindPubkeyDec

func TagKindPubkeyDec(
	k *types.Letter, v *types.Ident, ki *types.Uint16, p *types.PubHash,
	ca *types.Uint64,
	ser *types.Uint40,
) (enc *T)

func TagKindPubkeyEnc

func TagKindPubkeyEnc(
	k *types.Letter, v *types.Ident, ki *types.Uint16, p *types.PubHash,
	ca *types.Uint64,
	ser *types.Uint40,
) (enc *T)

func TagPubkeyDec

func TagPubkeyDec(
	k *types.Letter, v *types.Ident, p *types.PubHash, ca *types.Uint64,
	ser *types.Uint40,
) (enc *T)

func TagPubkeyEnc

func TagPubkeyEnc(
	k *types.Letter, v *types.Ident, p *types.PubHash, ca *types.Uint64,
	ser *types.Uint40,
) (enc *T)

func (*T) MarshalWrite

func (t *T) MarshalWrite(w io.Writer) (err error)

func (*T) UnmarshalRead

func (t *T) UnmarshalRead(r io.Reader) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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