Documentation ¶
Overview ¶
Package qdb asks specific questions of the play.db for the package qna runtime. It relies on the model.sql and run.sql sqlite tables that are written to by package asm.
Index ¶
- func BuildAspects(kb KindBuilder, fields []rt.Field) (ret []rt.Aspect, err error)
- func BuildKind(kb KindBuilder, k string) (ret rt.Kind, err error)
- func BuildStates(kb KindBuilder, k string) (ret []string, err error)
- func DecodeSparseRecord(kd KindDecoder, kind string, vs []SparseValue) (ret *rt.Record, err error)
- func MakeGrammar(db *sql.DB) (ret []parser.Scanner, err error)
- func ReadGrammar(db *sql.DB, dec CommandDecoder) (ret []parser.Scanner, err error)
- func ScanFields(rows *sql.Rows, dec CommandDecoder) (ret []rt.Field, err error)
- func ScanGrammar(rows *sql.Rows, dec CommandDecoder) (ret []parser.Scanner, err error)
- type CommandDecoder
- type DecodeNone
- func (d DecodeNone) DecodeAssignment(affine.Affinity, []byte) (_ rt.Assignment, err error)
- func (d DecodeNone) DecodeField(affine.Affinity, []byte, string) (_ literal.LiteralValue, err error)
- func (d DecodeNone) DecodeProg([]byte) (_ []rt.Execute, err error)
- func (d DecodeNone) DecodeValue(typeinfo.Instance, []byte) error
- type KindBuilder
- type KindDecoder
- type Query
- func (q *Query) ActivateDomains(name string) (retEnds, retBegins []string, err error)
- func (q *Query) Close()
- func (q *Query) FieldsOf(kind string) (ret []rt.Field, err error)
- func (q *Query) GetKindByName(k string) (ret *rt.Kind, err error)
- func (q *Query) GetKindByNoun(noun string) (ret *rt.Kind, err error)
- func (q *Query) IsDomainActive(name string) (okay bool, err error)
- func (q *Query) KindOfAncestors(kind string) (ret []string, err error)
- func (q *Query) LoadGame(outPath string) (ret query.CacheMap, err error)
- func (q *Query) NounInfo(name string) (ret query.NounInfo, err error)
- func (q *Query) NounName(id string) (ret string, err error)
- func (q *Query) NounNames(id string) (ret []string, err error)
- func (q *Query) NounValue(noun, field string) (ret rt.Assignment, err error)
- func (q *Query) NounsWithAncestor(kind string) (ret []string, err error)
- func (q *Query) PatternLabels(pat string) (ret []string, err error)
- func (q *Query) PluralFromSingular(singular string) (string, error)
- func (q *Query) PluralToSingular(plural string) (string, error)
- func (q *Query) Random(inclusiveMin, exclusiveMax int) int
- func (q *Query) ReciprocalsOf(rel, id string) ([]string, error)
- func (q *Query) Relate(rel, noun, otherNoun string) (err error)
- func (q *Query) RelativesOf(rel, id string) ([]string, error)
- func (q *Query) RulesFor(pat string) (ret query.RuleSet, err error)
- func (q *Query) SaveGame(outPath string, d query.CacheMap) (err error)
- type SparseValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAspects ¶ added in v0.24.7
fix: merge with the rtAsepcts version. :/
func BuildStates ¶ added in v0.24.7
func BuildStates(kb KindBuilder, k string) (ret []string, err error)
return a list of state names if the passed kind represents a state set. an empty list if it doesnt and error if there was some problem determining what is what.
func DecodeSparseRecord ¶ added in v0.24.7
func DecodeSparseRecord(kd KindDecoder, kind string, vs []SparseValue) (ret *rt.Record, err error)
func ReadGrammar ¶ added in v0.24.7
fix: domains: rebuild on domain changes, or: add a special "AllOf" that does a db query / cache implicitly? add scanners which check the database domain?
func ScanFields ¶ added in v0.24.7
given an query producing rows of field name, affinity, class, and init build an rt.Field list
func ScanGrammar ¶ added in v0.24.7
Types ¶
type CommandDecoder ¶ added in v0.24.7
type CommandDecoder interface { DecodeField(a affine.Affinity, b []byte, fieldType string) (literal.LiteralValue, error) DecodeAssignment(affine.Affinity, []byte) (rt.Assignment, error) DecodeProg([]byte) ([]rt.Execute, error) DecodeValue(typeinfo.Instance, []byte) error }
CommandDecoder transforms the raw bytes pulled from a query into in-memory commands.
type DecodeNone ¶ added in v0.24.7
type DecodeNone string
DecodeNone returns error for every method of Decoder. used for testing, and for a simplified
func (DecodeNone) DecodeAssignment ¶ added in v0.24.7
func (d DecodeNone) DecodeAssignment(affine.Affinity, []byte) (_ rt.Assignment, err error)
func (DecodeNone) DecodeField ¶ added in v0.24.7
func (d DecodeNone) DecodeField(affine.Affinity, []byte, string) (_ literal.LiteralValue, err error)
func (DecodeNone) DecodeProg ¶ added in v0.24.7
func (d DecodeNone) DecodeProg([]byte) (_ []rt.Execute, err error)
func (DecodeNone) DecodeValue ¶ added in v0.24.7
func (d DecodeNone) DecodeValue(typeinfo.Instance, []byte) error
type KindBuilder ¶ added in v0.24.7
type KindDecoder ¶ added in v0.24.7
type KindDecoder interface { CommandDecoder rt.Kinds }
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Read various data from the play database.
func NewQueries ¶
func NewQueries(db *sql.DB, dec CommandDecoder) (*Query, error)
func NewQueryOptions ¶ added in v0.24.7
func NewQueryOptions(db *sql.DB, dec CommandDecoder, rand query.Randomizer, cacheErrors bool) (ret *Query, err error)
func (*Query) ActivateDomains ¶
changing domains can establish new relations ( abandoning now conflicting ones ) and cause nouns to fall out of scope returns the previous domain name
func (*Query) GetKindByName ¶ added in v0.24.7
func (*Query) GetKindByNoun ¶ added in v0.24.7
func (*Query) KindOfAncestors ¶
returns the ancestor hierarchy, starting with the kind itself. empty if the kind doesnt exist, errors on a db error. accepts both the plural and singular kind.
func (*Query) LoadGame ¶ added in v0.24.7
read noun data from the db ( rt.run_value ) and store them as bytes; run.readNounValue will unpack them
func (*Query) NounName ¶
return the best "short name" for a noun ( or blank if the noun isnt known or isnt in scope )
func (*Query) NounValue ¶ added in v0.24.7
func (q *Query) NounValue(noun, field string) (ret rt.Assignment, err error)
interpreting the value is left to the caller ( re: field affinity )
func (*Query) NounsWithAncestor ¶ added in v0.24.8
func (*Query) PatternLabels ¶
the last value is always the result, blank for execute statements
func (*Query) PluralFromSingular ¶
type SparseValue ¶ added in v0.24.7
func ScanSparseValues ¶ added in v0.24.7
func ScanSparseValues(rows *sql.Rows) (ret []SparseValue, err error)