qdb

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: 18 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAspects added in v0.24.7

func BuildAspects(kb KindBuilder, fields []rt.Field) (ret []rt.Aspect, err error)

fix: merge with the rtAsepcts version. :/

func BuildKind added in v0.24.7

func BuildKind(kb KindBuilder, k string) (ret rt.Kind, err error)

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 MakeGrammar added in v0.24.7

func MakeGrammar(db *sql.DB) (ret []parser.Scanner, err error)

func ReadGrammar added in v0.24.7

func ReadGrammar(db *sql.DB, dec CommandDecoder) (ret []parser.Scanner, err error)

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

func ScanFields(rows *sql.Rows, dec CommandDecoder) (ret []rt.Field, err error)

given an query producing rows of field name, affinity, class, and init build an rt.Field list

func ScanGrammar added in v0.24.7

func ScanGrammar(rows *sql.Rows, dec CommandDecoder) (ret []parser.Scanner, err error)

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 KindBuilder interface {
	KindOfAncestors(string) ([]string, error)
	FieldsOf(string) ([]rt.Field, error)
}

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

func (q *Query) ActivateDomains(name string) (retEnds, retBegins []string, err error)

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) Close added in v0.24.7

func (q *Query) Close()

implements closer

func (*Query) FieldsOf

func (q *Query) FieldsOf(kind string) (ret []rt.Field, err error)

cached fields exclusive to a kind

func (*Query) GetKindByName added in v0.24.7

func (q *Query) GetKindByName(k string) (ret *rt.Kind, err error)

func (*Query) GetKindByNoun added in v0.24.7

func (q *Query) GetKindByNoun(noun string) (ret *rt.Kind, err error)

func (*Query) IsDomainActive

func (q *Query) IsDomainActive(name string) (okay bool, err error)

func (*Query) KindOfAncestors

func (q *Query) KindOfAncestors(kind string) (ret []string, err error)

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

func (q *Query) LoadGame(outPath string) (ret query.CacheMap, err error)

read noun data from the db ( rt.run_value ) and store them as bytes; run.readNounValue will unpack them

func (*Query) NounInfo

func (q *Query) NounInfo(name string) (ret query.NounInfo, err error)

given a short name, find a noun ( and some useful other context )

func (*Query) NounName

func (q *Query) NounName(id string) (ret string, err error)

return the best "short name" for a noun ( or blank if the noun isnt known or isnt in scope )

func (*Query) NounNames

func (q *Query) NounNames(id string) (ret []string, err error)

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 (q *Query) NounsWithAncestor(kind string) (ret []string, err error)

func (*Query) PatternLabels

func (q *Query) PatternLabels(pat string) (ret []string, err error)

the last value is always the result, blank for execute statements

func (*Query) PluralFromSingular

func (q *Query) PluralFromSingular(singular string) (string, error)

func (*Query) PluralToSingular

func (q *Query) PluralToSingular(plural string) (string, error)

func (*Query) Random added in v0.24.7

func (q *Query) Random(inclusiveMin, exclusiveMax int) int

func (*Query) ReciprocalsOf

func (q *Query) ReciprocalsOf(rel, id string) ([]string, error)

func (*Query) Relate

func (q *Query) Relate(rel, noun, otherNoun string) (err error)

func (*Query) RelativesOf

func (q *Query) RelativesOf(rel, id string) ([]string, error)

func (*Query) RulesFor

func (q *Query) RulesFor(pat string) (ret query.RuleSet, err error)

get the rules from the cache, or build them and add them to the cache

func (*Query) SaveGame added in v0.24.7

func (q *Query) SaveGame(outPath string, d query.CacheMap) (err error)

type SparseValue added in v0.24.7

type SparseValue struct {
	Path  string
	Bytes []byte
}

func ScanSparseValues added in v0.24.7

func ScanSparseValues(rows *sql.Rows) (ret []SparseValue, err error)

Jump to

Keyboard shortcuts

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