query

package
v0.24.8 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: BSD-3-Clause Imports: 16 Imported by: 1

Documentation

Overview

Package decode unpacks stored programs and values from byte slices

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache added in v0.24.7

type Cache struct {
	CacheMap
	// contains filtered or unexported fields
}

func MakeCache added in v0.24.7

func MakeCache(cacheErrors bool) Cache

func (*Cache) Ensure added in v0.24.7

func (c *Cache) Ensure(key Key, build func() (any, error)) (ret any, err error)

func (*Cache) Get added in v0.24.7

func (c *Cache) Get(k Key) (ret any, okay bool)

func (*Cache) Reset added in v0.24.7

func (c *Cache) Reset()

func (*Cache) Store added in v0.24.7

func (c *Cache) Store(k Key, d any)

type CacheMap added in v0.24.7

type CacheMap map[Key]any

things that implement TextMarshaler will save.

type Key added in v0.24.7

type Key struct {
	Domain, Target, Field string
}

func MakeKey added in v0.24.7

func MakeKey(domain, target, field string) Key

func (Key) String added in v0.24.7

func (k Key) String() string

for logs and errors

type NotImplemented

type NotImplemented string

NotImplemented - generic error used returned by QueryNone

func (NotImplemented) Error

func (e NotImplemented) Error() string

type NounInfo

type NounInfo struct {
	Domain, Noun, Kind string // noun is unique identifier within the domain.
}

func (*NounInfo) IsValid

func (n *NounInfo) IsValid() bool

func (*NounInfo) String

func (n *NounInfo) String() (ret string)

type Query

type Query interface {
	IsDomainActive(name string) (bool, error)
	ActivateDomains(name string) (prev, next []string, err error)
	//
	GetKindByName(rawName string) (*rt.Kind, error)
	// given a plural or singular kind
	// return all ancestors starting with the kind itself.
	KindOfAncestors(kindOrKinds string) ([]string, error)
	// search using a short name
	NounInfo(shortname string) (NounInfo, error)
	// return the friendly name of the exact named noun
	NounName(fullname string) (string, error)
	// find the parser aliases for this noun
	// warning: the  parser expects these to be in alphabetical order.
	NounNames(fullname string) ([]string, error)
	// a single field can contain a set of recursive spare values;
	// so this returns "pairs" of paths and values.
	NounValue(fullname, field string) (rt.Assignment, error)
	// all nouns of the indicated kind
	NounsWithAncestor(kind string) ([]string, error)
	// the empty string if not found
	PluralToSingular(plural string) (string, error)
	// the empty string if not found
	PluralFromSingular(singular string) (string, error)
	// includes the parameters, followed by the result
	// the result can be a blank string for execute statements
	PatternLabels(pat string) ([]string, error)
	RulesFor(pat string) (RuleSet, error)
	ReciprocalsOf(rel, id string) ([]string, error)
	RelativesOf(rel, id string) ([]string, error)
	// relations can be cleared by passing a blank string on the opposite side
	// but -- fix -- there is no way to clear many-many relations.
	// errors if nothing changed.
	// doesnt check to see if the relation is valid;
	// the caller should do that.
	Relate(rel, noun, otherNoun string) error
	//
	LoadGame(path string) (CacheMap, error)
	SaveGame(path string, dynamicValues CacheMap) error
	Random(inclusiveMin, exclusiveMax int) int
	// release all resource
	Close()
}

type QueryDecoder added in v0.24.7

type QueryDecoder decode.Decoder

wraps the base decoder with some additional method

func NewDecoder added in v0.24.7

func NewDecoder(signatures decode.SignatureTable) *QueryDecoder

func (*QueryDecoder) DecodeAssignment added in v0.24.7

func (d *QueryDecoder) DecodeAssignment(a affine.Affinity, b []byte) (ret rt.Assignment, err error)

matches with mdl.marshalAssignment the expected eval depends on the affinity (a) of the destination field. fix? merge somehow with express.newAssignment? with compact decoding.

func (*QueryDecoder) DecodeField added in v0.24.7

func (d *QueryDecoder) DecodeField(a affine.Affinity, b []byte, fieldType string) (ret literal.LiteralValue, err error)

func (*QueryDecoder) DecodeProg added in v0.24.7

func (d *QueryDecoder) DecodeProg(b []byte) (ret []rt.Execute, err error)

func (*QueryDecoder) DecodeValue added in v0.24.7

func (d *QueryDecoder) DecodeValue(out typeinfo.Instance, b []byte) (err error)

type QueryNone

type QueryNone string

QueryNone - implements Query by returning empty results for all reads, and the NotImplemented error for mutating methods.

func (QueryNone) ActivateDomains

func (q QueryNone) ActivateDomains(name string) (_, _ []string, err error)

func (QueryNone) Close added in v0.24.7

func (q QueryNone) Close()

func (QueryNone) GetKindByName added in v0.24.7

func (q QueryNone) GetKindByName(rawName string) (_ *rt.Kind, err error)

func (QueryNone) IsDomainActive

func (q QueryNone) IsDomainActive(name string) (_ bool, _ error)

func (QueryNone) KindOfAncestors

func (q QueryNone) KindOfAncestors(kind string) (_ []string, _ error)

func (QueryNone) LoadGame added in v0.24.7

func (q QueryNone) LoadGame(path string) (ret CacheMap, err error)

LoadGame implements Query.

func (QueryNone) NounInfo

func (q QueryNone) NounInfo(name string) (_ NounInfo, _ error)

func (QueryNone) NounName

func (q QueryNone) NounName(id string) (_ string, _ error)

func (QueryNone) NounNames

func (q QueryNone) NounNames(id string) (_ []string, _ error)

func (QueryNone) NounValue added in v0.24.7

func (q QueryNone) NounValue(id, field string) (_ rt.Assignment, _ error)

func (QueryNone) NounsWithAncestor added in v0.24.8

func (q QueryNone) NounsWithAncestor(kind string) (_ []string, _ error)

func (QueryNone) PatternLabels

func (q QueryNone) PatternLabels(pat string) (_ []string, _ error)

func (QueryNone) PluralFromSingular

func (q QueryNone) PluralFromSingular(singular string) (_ string, _ error)

func (QueryNone) PluralToSingular

func (q QueryNone) PluralToSingular(plural string) (_ string, _ error)

func (QueryNone) Random added in v0.24.7

func (q QueryNone) Random(inclusiveMin int, exclusiveMax int) int

Random implements Query.

func (QueryNone) ReciprocalsOf

func (q QueryNone) ReciprocalsOf(rel, id string) (_ []string, _ error)

func (QueryNone) Relate

func (q QueryNone) Relate(rel, noun, otherNoun string) error

func (QueryNone) RelativesOf

func (q QueryNone) RelativesOf(rel, id string) (_ []string, _ error)

func (QueryNone) RulesFor

func (q QueryNone) RulesFor(pat string) (_ RuleSet, _ error)

func (QueryNone) SaveGame added in v0.24.7

func (q QueryNone) SaveGame(path string, dynamicValues CacheMap) error

SaveGame implements Query.

type RandomPersist added in v0.24.7

type RandomPersist struct {
	Seed       []byte
	LastRandom int64
}

type Randomizer added in v0.24.7

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

func RandomizedTime added in v0.24.7

func RandomizedTime() Randomizer

func SeedRandomizer added in v0.24.7

func SeedRandomizer(seed1, seed2 uint64) Randomizer

func (*Randomizer) Load added in v0.24.7

func (r *Randomizer) Load(from RandomPersist) (err error)

func (*Randomizer) Random added in v0.24.7

func (r *Randomizer) Random(inclusiveMin, exclusiveMax int) int

func (*Randomizer) Save added in v0.24.7

func (r *Randomizer) Save() (ret RandomPersist, err error)

fix look into implementing BinaryMarshaler directly

type RuleSet added in v0.24.7

type RuleSet struct {
	Rules     []rt.Rule
	UpdateAll bool // true if any of the rules have update ste
}

Jump to

Keyboard shortcuts

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