sql

package
v0.0.0-...-2887efe Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const TraceValuesShards = 8

TraceValuesShards is the number of shards we use in the TraceValues Table.

Variables

This section is empty.

Functions

func AsMD5Hash

func AsMD5Hash(b []byte) schema.MD5Hash

AsMD5Hash returns the given byte slice as an MD5Hash (for easier use with maps)

func ComputeTraceValueShard

func ComputeTraceValueShard(traceID schema.TraceID) byte

ComputeTraceValueShard computes a shard in the range [0,TraceValuesShards) based off the given trace hash bytes. This shard range was chosen to be a small number (relative to the thousands of ranges that the TraceValues database occupies) that is larger than the number of nodes in the cockroachdb cluster. See the overall design doc (go/skia-gold-sql) for more explanation about data locality and sharding.

func DigestToBytes

func DigestToBytes(d types.Digest) (schema.DigestBytes, error)

DigestToBytes returns the given digest as bytes. It returns an error if a missing digest is passed in or if the bytes are otherwise invalid.

func FromMD5Hash

func FromMD5Hash(m schema.MD5Hash) []byte

FromMD5Hash returns the given byte array a slice of bytes. The copy is required when dealing with a loop variable, as a naive slice won't work.

func GetConnectionURL

func GetConnectionURL(userHostPort, dbName string) string

GetConnectionURL returns a full connection URL with the correct protocol and connection options given the username, host, port, and database name.

func Qualify

func Qualify(system, id string) string

Qualify prefixes the given CL, PS or TJ id with the given system. In the SQL database, we use these qualified IDs to make the queries easier, that is, we don't have to do a join over id and system, we can just use the combined ID.

func Sanitize

func Sanitize(s string) string

Sanitize removes unsafe characters from strings to avoid SQL injections. Namely quotes.

func SerializeMap

func SerializeMap(m map[string]string) (string, []byte)

SerializeMap returns the given map in JSON and the MD5 of that json string. nil maps will be treated as empty maps. Keys will be sorted lexicographically.

func Unqualify

func Unqualify(id string) string

Unqualify removes the system prefix that was added with Qualify. If the id was not qualified, the input string is returned unchanged.

Types

This section is empty.

Directories

Path Synopsis
Package databuilder provides a tool for generating test data in a way that is easy for a human to update and understand.
Package databuilder provides a tool for generating test data in a way that is easy for a human to update and understand.
exporter
tosql
This executable generates a go file that contains the SQL schema for Gold defined as a string.
This executable generates a go file that contains the SQL schema for Gold defined as a string.

Jump to

Keyboard shortcuts

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