Documentation ¶
Index ¶
- Constants
- Variables
- func CurrentMaxShard(ctx context.Context) (int, error)
- func InclusionKey(including, included ID) spanner.Key
- func IncrementTestResultCount(ctx context.Context, id ID, delta int64) error
- func Read(ctx context.Context, id ID) (*pb.Invocation, error)
- func ReadBatch(ctx context.Context, ids IDSet) (map[ID]*pb.Invocation, error)
- func ReadColumns(ctx context.Context, id ID, ptrMap map[string]interface{}) error
- func ReadRealm(ctx context.Context, id ID) (string, error)
- func ReadRealms(ctx context.Context, ids IDSet) (realms map[ID]string, err error)
- func ReadState(ctx context.Context, id ID) (pb.Invocation_State, error)
- func ReadStateBatch(ctx context.Context, ids IDSet) (map[ID]pb.Invocation_State, error)
- func ReadTestResultCount(ctx context.Context, ids IDSet) (int64, error)
- func ShardStatement(st spanner.Statement, invIDsParamName string) []spanner.Statement
- func TokenToMap(token string, dest map[string]interface{}, keys ...string) error
- type ID
- type IDSet
- func MustParseNames(names []string) IDSet
- func NewIDSet(ids ...ID) IDSet
- func ParseNames(names []string) (IDSet, error)
- func Reachable(ctx context.Context, roots IDSet) (IDSet, error)
- func ReachableSkipRootCache(ctx context.Context, roots IDSet) (IDSet, error)
- func ReadIncluded(ctx context.Context, id ID) (IDSet, error)
- func (s IDSet) Add(id ID)
- func (s IDSet) Batches() []IDSet
- func (s *IDSet) FromSpanner(b *spanutil.Buffer) error
- func (s IDSet) Has(id ID) bool
- func (s IDSet) Keys(suffix ...interface{}) spanner.KeySet
- func (s IDSet) Names() []string
- func (s IDSet) Remove(id ID)
- func (s IDSet) SortByRowID() []ID
- func (s *IDSet) SpannerPtr(b *spanutil.Buffer) interface{}
- func (s IDSet) String() string
- func (s IDSet) ToSpanner() interface{}
- func (s IDSet) Union(other IDSet)
- type ReachCache
Constants ¶
const MaxNodes = 10000
MaxNodes is the maximum number of invocation nodes that ResultDB can operate on at a time.
const Shards = 100
Shards is the sharding level for the Invocations table. Column Invocations.ShardId is a value in range [0, Shards).
Variables ¶
var ErrUnknownReach = fmt.Errorf("the reachable set is unknown")
ErrUnknownReach is returned by ReachCache.Read if the cached value is absent.
var TooManyTag = errors.BoolTag{ Key: errors.NewTagKey("too many matching invocations matched the condition"), }
TooManyTag set in an error indicates that too many invocations matched a condition.
Functions ¶
func CurrentMaxShard ¶
CurrentMaxShard reads the highest shard id in the Invocations table. This may differ from the constant above when it has changed recently.
func InclusionKey ¶
InclusionKey returns a spanner key for an Inclusion row.
func IncrementTestResultCount ¶
IncrementTestResultCount increases the TestResultCount of the invocation.
func Read ¶
Read reads one invocation from Spanner. If the invocation does not exist, the returned error is annotated with NotFound GRPC code.
func ReadBatch ¶
ReadBatch reads multiple invocations from Spanner. If any of them are not found, returns an error.
func ReadColumns ¶
ReadColumns reads the specified columns from an invocation Spanner row. If the invocation does not exist, the returned error is annotated with NotFound GRPC code. For ptrMap see ReadRow comment in span/util.go.
func ReadRealms ¶
ReadRealms returns the invocations' realms. Makes a single RPC.
func ReadStateBatch ¶
ReadStateBatch reads the states of multiple invocations.
func ReadTestResultCount ¶
ReadTestResultCount returns the total number of test results of requested invocations.
func ShardStatement ¶
ShardStatement splits the statement into multiple shards by invocation parameter. For example, if a query retrieves test results from a set of invocations, then ShardQuery splits the set of invocations into subsets, and returns a statement for each of them. The returned statements are ordered by invocation row id.
Users of this function must be careful with LIMIT and ORDER BY operator, because each statement would have its own LIMIT and order.
st must have a parameter with the name invIDsParamName, and it must have a type IDSet.
TODO(crbug.com/1113071): remove this function.
func TokenToMap ¶
TokenToMap parses a page token to a map. The first component of the token is expected to be an invocation ID. Convenient to initialize Spanner statement parameters. Expects the token to be either empty or have len(keys) components. If the token is empty, sets map values to "".
Types ¶
type ID ¶
type ID string
ID can convert an invocation id to various formats.
func IDFromRowID ¶
IDFromRowID converts a Spanner-level row ID to an ID.
func MustParseName ¶
MustParseName converts an invocation name to an ID. Panics if the name is invalid. Useful for situations when name was already validated.
func (*ID) FromSpanner ¶
FromSpanner implements span.Ptr.
func (*ID) SpannerPtr ¶
SpannerPtr implements span.Ptr.
type IDSet ¶
type IDSet map[ID]struct{}
IDSet is an unordered set of invocation ids.
func MustParseNames ¶
MustParseNames converts invocation names to IDSet. Panics if a name is invalid. Useful for situations when names were already validated.
func ParseNames ¶
ParseNames converts invocation names to IDSet.
func Reachable ¶
Reachable returns all invocations reachable from roots along the inclusion edges. May return an appstatus-annotated error.
func ReachableSkipRootCache ¶
ReachableSkipRootCache is similar to Reachable, but it ignores cache for the roots.
Useful to keep cache-hit stats high in cases where the roots are known not to have cache.
func ReadIncluded ¶
ReadIncluded reads ids of included invocations.
func (IDSet) Batches ¶
Batches splits s into batches. The batches are sorted by RowID(), such that interval (minRowID, maxRowID) of each batch does not overlap with any other batch.
The size of batch is hardcoded 50, because that's the maximum parallelism we get from Cloud Spanner.
func (*IDSet) FromSpanner ¶
FromSpanner implements span.Ptr.
func (IDSet) SortByRowID ¶
SortByRowID returns IDs in the set sorted by row id.
func (*IDSet) SpannerPtr ¶
SpannerPtr implements span.Ptr.
type ReachCache ¶
type ReachCache ID
ReachCache is a cache of all invocations reachable from the given invocation, stored in Redis. The cached set is either correct or absent.
The cache must be written only after the set of reachable invocations becomes immutable, i.e. when the including invocation is finalized. This is important to be able to tolerate transient Redis failures and avoid a situation where we failed to update the currently stored set, ignored the failure and then, after Redis came back online, read the stale set.
func (ReachCache) Read ¶
func (c ReachCache) Read(ctx context.Context) (ids IDSet, err error)
Read reads the current value. Returns ErrUnknownReach if the value is absent.
If err is nil, ids includes c, even if it was not passed in Write().