index

package
v0.0.0-...-56ab034 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HashSeed uint32 = 666

Functions

func ExtractActor

func ExtractActor(li vocab.LinkOrIRI) []uint64

ExtractActor returns the vocab.IRI tokens corresponding to the "actor" property of the received vocab.IntransitiveActivity

func ExtractAttributedTo

func ExtractAttributedTo(li vocab.LinkOrIRI) []uint64

ExtractAttributedTo returns the vocab.IRI tokens corresponding to the "attributedTo" property of the received vocab.Item

func ExtractCollectionItems

func ExtractCollectionItems(li vocab.LinkOrIRI) []uint64

ExtractCollectionItems returns the vocab.IRI tokens corresponding to the items in the collection of the received vocab.Item

func ExtractContent

func ExtractContent(li vocab.LinkOrIRI) []string

ExtractContent returns the tokens in the "content" property of the vocab.Item

func ExtractID

func ExtractID(li vocab.LinkOrIRI) []uint64

ExtractID returns the vocab.IRI token corresponding to the "ID" property of the received vocab.Item

func ExtractInReplyTo

func ExtractInReplyTo(li vocab.LinkOrIRI) []uint64

ExtractInReplyTo returns the vocab.IRI tokens corresponding to the "inReplyTo" property of the received vocab.Item

func ExtractName

func ExtractName(li vocab.LinkOrIRI) []string

ExtractName returns a single token composed of the "name" property of the vocab.LinkOrIRI. This works on both vocab.Link and vocab.Item objects.

func ExtractNatLangVal

func ExtractNatLangVal(nlv vocab.NaturalLanguageValues) []string

ExtractNatLangVal extracts a single token from the value of the vocab.NaturalLanguageValues value. This is meant for the properties that contain single words like "preferredUsername" or "name".

func ExtractObject

func ExtractObject(li vocab.LinkOrIRI) []uint64

ExtractObject returns the vocab.IRI tokens corresponding to the "object" property of the received vocab.Activity

func ExtractPreferredUsername

func ExtractPreferredUsername(li vocab.LinkOrIRI) []string

ExtractPreferredUsername returns a single token composed of the "preferredUsername" property of the vocab.Actor

func ExtractPublished

func ExtractPublished(li vocab.LinkOrIRI) []uint64

ExtractPublished returns the vocab.IRI tokens corresponding to the Published property the received vocab.Object

func ExtractRecipients

func ExtractRecipients(li vocab.LinkOrIRI) []uint64

ExtractRecipients returns the vocab.IRI tokens corresponding to the various addressing properties of the received vocab.Item. NOTE(marius): Currently it includes *all* the addressing fields, not removing the "blind" ones (Bto and BCC)

func ExtractSummary

func ExtractSummary(li vocab.LinkOrIRI) []string

ExtractSummary returns the tokens in the "summary" property of the vocab.Item

func ExtractType

func ExtractType(li vocab.LinkOrIRI) []string

ExtractType returns the "type" of the vocab.LinkOrIRI. This works on both vocab.Link and vocab.Item objects.

func ExtractUpdated

func ExtractUpdated(li vocab.LinkOrIRI) []uint64

ExtractUpdated returns the vocab.IRI tokens corresponding to the Updated property the received vocab.Object

func GetBitmaps

func GetBitmaps[T Tokenizable](in Indexable, tokens ...T) []*roaring64.Bitmap

GetBitmaps returns the ORing of the underlying search bitmaps corresponding to the received tokens, or to the reverse of the returned tokens if the neg parameter is set.

Types

type ExtractFnType

type ExtractFnType[T Tokenizable] func(vocab.LinkOrIRI) []T

type HashFnType

type HashFnType func(vocab.LinkOrIRI) uint64
var HashFn HashFnType = murmurHash

type Index

type Index struct {
	Ref     map[uint64]vocab.IRI
	Indexes map[Type]Indexable
	// contains filtered or unexported fields
}

Index represents a full index It contains the fast tokenized bitmaps, together with a cross-reference map that provides the corresponding vocab.IRI list that results after resolving the bitmap searches.

func Full

func Full() *Index

Full returns a full index data type. The complete list of types can be found in the "ByXX" constants.

func Partial

func Partial(types ...Type) *Index

Partial returns a partial index. It will create tokenized bitmaps only for the types it receives as parameters. The types can be found in the "ByXX" constants.

func (*Index) Add

func (i *Index) Add(items ...vocab.LinkOrIRI)

Add adds a vocab.LinkOrIRI object to the index.

func (*Index) MarshalBinary

func (i *Index) MarshalBinary() ([]byte, error)

func (*Index) UnmarshalBinary

func (i *Index) UnmarshalBinary(data []byte) error

type Indexable

type Indexable interface {
	Add(vocab.LinkOrIRI) uint64
}

func All

func All() Indexable

func NewIndex

func NewIndex[T Tokenizable](refsExtractFn ExtractFnType[uint64], tokExtractFn ExtractFnType[T]) Indexable

NewTokenIndex intializes a new tokenMap index where the function to extract the references that get indexed is passed directly.

func NewTokenIndex

func NewTokenIndex[T Tokenizable](extractFn ExtractFnType[T]) Indexable

NewTokenIndex intializes a new tokenMap index where the reference extraction function returns the indexed reference based on the ActivityPub Object ID.

type Tokenizable

type Tokenizable interface{ ~string | uint32 | uint64 }

type Type

type Type int8
const (
	ByID Type = iota
	ByType
	ByName
	ByPreferredUsername
	BySummary
	ByContent
	ByActor
	ByObject
	ByRecipients
	ByAttributedTo
	ByInReplyTo
	ByPublished
	ByUpdated
)

Jump to

Keyboard shortcuts

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