perf: golang.org/x/perf/storage/db Index | Files | Directories

package db

import "golang.org/x/perf/storage/db"

Package db provides the high-level database interface for the storage app.

Index

Package Files

db.go query.go

func RegisterOpenHook Uses

func RegisterOpenHook(driverName string, hook func(*sql.DB) error)

RegisterOpenHook registers a hook to be called after opening a connection to driverName. This is used by the sqlite3 package to register a ConnectHook. It must be called from an init function.

type DB Uses

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

DB is a high-level interface to a database for the storage app. It's safe for concurrent use by multiple goroutines.

func OpenSQL Uses

func OpenSQL(driverName, dataSourceName string) (*DB, error)

OpenSQL creates a DB backed by a SQL database. The parameters are the same as the parameters for sql.Open. Only mysql and sqlite3 are explicitly supported; other database engines will receive MySQL query syntax which may or may not be compatible.

func (*DB) Close Uses

func (db *DB) Close() error

Close closes the database connections, releasing any open resources.

func (*DB) CountUploads Uses

func (db *DB) CountUploads() (int, error)

CountUploads returns the number of uploads in the database.

func (*DB) ListUploads Uses

func (db *DB) ListUploads(q string, extraLabels []string, limit int) *UploadList

ListUploads searches for uploads containing results matching the given query string. The query may be empty, in which case all uploads will be returned. For each label in extraLabels, one unspecified record's value will be obtained for each upload. If limit is non-zero, only the limit most recent uploads will be returned.

func (*DB) NewUpload Uses

func (db *DB) NewUpload(ctx context.Context) (*Upload, error)

NewUpload returns an upload for storing new files. All records written to the Upload will have the same upload ID.

func (*DB) Query Uses

func (db *DB) Query(q string) *Query

Query searches for results matching the given query string.

The query string is first parsed into quoted words (as in the shell) and then each word must be formatted as one of the following: key:value - exact match on label "key" = "value" key>value - value greater than (useful for dates) key<value - value less than (also useful for dates)

func (*DB) ReplaceUpload Uses

func (db *DB) ReplaceUpload(id string) (*Upload, error)

ReplaceUpload removes the records associated with id if any and allows insertion of new records.

type Query Uses

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

Query is the result of a query. Use Next to advance through the rows, making sure to call Close when done:

q := db.Query("key:value")
defer q.Close()
for q.Next() {
  res := q.Result()
  ...
}
err = q.Err() // get any error encountered during iteration
...

func (*Query) Close Uses

func (q *Query) Close() error

Close frees resources associated with the query.

func (*Query) Debug Uses

func (q *Query) Debug() string

Debug returns the human-readable state of the query.

func (*Query) Err Uses

func (q *Query) Err() error

Err returns the error state of the query.

func (*Query) Next Uses

func (q *Query) Next() bool

Next prepares the next result for reading with the Result method. It returns false when there are no more results, either by reaching the end of the input or an error.

func (*Query) Result Uses

func (q *Query) Result() *benchfmt.Result

Result returns the most recent result generated by a call to Next.

type Upload Uses

type Upload struct {
    // ID is the value of the "upload" key that should be
    // associated with every record in this upload.
    ID string
    // contains filtered or unexported fields
}

An Upload is a collection of files that share an upload ID.

func (*Upload) Abort Uses

func (u *Upload) Abort() error

Abort cleans up resources associated with the upload. It does not attempt to clean up partial database state.

func (*Upload) Commit Uses

func (u *Upload) Commit() error

Commit finishes processing the upload.

func (*Upload) InsertRecord Uses

func (u *Upload) InsertRecord(r *benchfmt.Result) error

InsertRecord inserts a single record in an existing upload. If InsertRecord returns a non-nil error, the Upload has failed and u.Abort() must be called.

type UploadList Uses

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

UploadList is the result of ListUploads. Use Next to advance through the rows, making sure to call Close when done:

q := db.ListUploads("key:value")
defer q.Close()
for q.Next() {
  info := q.Info()
  ...
}
err = q.Err() // get any error encountered during iteration
...

func (*UploadList) Close Uses

func (ul *UploadList) Close() error

Close frees resources associated with the query.

func (*UploadList) Debug Uses

func (ul *UploadList) Debug() string

Debug returns the human-readable state of ul.

func (*UploadList) Err Uses

func (ul *UploadList) Err() error

Err returns the error state of the query.

func (*UploadList) Info Uses

func (ul *UploadList) Info() storage.UploadInfo

Info returns the most recent UploadInfo generated by a call to Next.

func (*UploadList) Next Uses

func (ul *UploadList) Next() bool

Next prepares the next result for reading with the Result method. It returns false when there are no more results, either by reaching the end of the input or an error.

Directories

PathSynopsis
dbtest
sqlite3Package sqlite3 provides the sqlite3 driver for x/perf/storage/db.

Package db imports 15 packages (graph) and is imported by 8 packages. Updated 2017-07-07. Refresh now. Tools for package owners.