spanner

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryWithStatsElapsedTimeKey                = "elapsed_time"
	QueryWithStatsCPUTimeKey                    = "cpu_time"
	QueryWithStatsQueryPlanCreationTimeKey      = "query_plan_creation_time"
	QueryWithStatsRuntimeCreationTimeKey        = "runtime_creation_time"
	QueryWithStatsStatisticsLoadTimeKey         = "statistics_load_time"
	QueryWithStatsFilesystemDelaySecondsKey     = "filesystem_delay_seconds"
	QueryWithStatsDeletedRowsScannedKey         = "deleted_rows_scanned"
	QueryWithStatsRemoteServerCallsKey          = "remote_server_calls"
	QueryWithStatsRowsReturnedKey               = "rows_returned"
	QueryWithStatsRowsScannedKey                = "rows_scanned"
	QueryWithStatsDataBytesReadKey              = "data_bytes_read"
	QueryWithStatsBytesReturnedKey              = "bytes_returned"
	QueryWithStatsOptimizerStatisticsPackageKey = "optimizer_statistics_package"
	QueryWithStatsQueryTextKey                  = "query_text"
	QueryWithStatsOptimizerVersionKey           = "optimizer_version"
)

Variables

View Source
var ErrInvalidArgument = &Error{
	Code:    "InvalidArgument",
	Message: "invalid argument",
	KV:      map[string]interface{}{},
}

ErrInvalidArgument is 引数に問題がある時に返す

View Source
var ErrNotFound = &Error{
	Code:    "NotFound",
	Message: "not found",
	KV:      map[string]interface{}{},
}

ErrNotFound is 見つからなかった時に返す

View Source
var (
	//
	// deprecated
	ErrRequiredSpannerClient = errors.New("required spanner client")
)
View Source
var QueryStatsBigQueryTableSchema = bigquery.Schema{
	{Name: "interval_end", Required: true, Type: bigquery.TimestampFieldType},
	{Name: "text", Required: true, Type: bigquery.StringFieldType},
	{Name: "text_truncated", Required: true, Type: bigquery.BooleanFieldType},
	{Name: "text_fingerprint", Required: true, Type: bigquery.IntegerFieldType},
	{Name: "execution_count", Required: true, Type: bigquery.IntegerFieldType},
	{Name: "avg_latency_seconds", Required: true, Type: bigquery.FloatFieldType},
	{Name: "avg_rows", Required: true, Type: bigquery.FloatFieldType},
	{Name: "avg_bytes", Required: true, Type: bigquery.FloatFieldType},
	{Name: "avg_rows_scanned", Required: true, Type: bigquery.FloatFieldType},
	{Name: "avg_cpu_seconds", Required: true, Type: bigquery.FloatFieldType},
}

QueryStatsBigQueryTableSchema is BigQuery Table Schema

deprecated

Functions

func NewErrInvalidArgument

func NewErrInvalidArgument(message string, kv map[string]interface{}, err error) error

NewErrInvalidArgument is return InvalidArgument

func NewErrNotFound

func NewErrNotFound(key string, err error) error

NewErrNotFound is return ErrNotFound

func ValidateDatabaseIDFormat

func ValidateDatabaseIDFormat(projectID string) bool

ValidateDatabaseIDFormat is InstanceIDのFormatを検証する

The database ID must conform to the regular expression [a-z][a-z0-9_\-]*[a-z0-9] and be between 2 and 30 characters in length. https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases/create

func ValidateInstanceIDFormat

func ValidateInstanceIDFormat(projectID string) bool

ValidateInstanceIDFormat is InstanceIDのFormatを検証する

Valid identifiers are of the form [a-z][-a-z0-9]*[a-z0-9] and must be between 2 and 64 characters in length. https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances/create

Types

type Database

type Database struct {
	ProjectID string
	Instance  string
	Database  string
}

Database is Spanner Databaseを表す

func SplitDatabaseName

func SplitDatabaseName(database string) (*Database, error)

SplitDatabaseName is projects/{PROJECT_ID}/instances/{INSTANCE}/databases/{DB} 形式の文字列をstructにして返す

func (*Database) ToSpannerDatabaseName

func (d *Database) ToSpannerDatabaseName() string

ToSpannerDatabaseName is Spanner Database Name として指定できる形式の文字列を返す

type Error

type Error struct {
	Code    string
	Message string
	KV      map[string]interface{}
	// contains filtered or unexported fields
}

Error is Error情報を保持する struct

func (*Error) Error

func (e *Error) Error() string

Error is error interface func

func (*Error) Is

func (e *Error) Is(target error) bool

Is is err equal check

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap is return unwrap error

type QueryStat

type QueryStat struct {
	IntervalEnd       time.Time `spanner:"interval_end"` // End of the time interval that the included query executions occurred in.
	Text              string    // SQL query text, truncated to approximately 64KB.
	TextTruncated     bool      `spanner:"text_truncated"`      // Whether or not the query text was truncated.
	TextFingerprint   int64     `spanner:"text_fingerprint"`    // Hash of the query text.
	ExecuteCount      int64     `spanner:"execution_count"`     // Number of times Cloud Spanner saw the query during the interval.
	AvgLatencySeconds float64   `spanner:"avg_latency_seconds"` // Average length of time, in seconds, for each query execution within the database. This average excludes the encoding and transmission time for the result set as well as overhead.
	AvgRows           float64   `spanner:"avg_rows"`            // Average number of rows that the query returned.
	AvgBytes          float64   `spanner:"avg_bytes"`           // Average number of data bytes that the query returned, excluding transmission encoding overhead.
	AvgRowsScanned    float64   `spanner:"avg_rows_scanned"`    // Average number of rows that the query scanned, excluding deleted values.
	AvgCPUSeconds     float64   `spanner:"avg_cpu_seconds"`     // Average number of seconds of CPU time Cloud Spanner spent on all operations to execute the query.
}

QueryStat

deprecated

func (*QueryStat) InsertID

func (s *QueryStat) InsertID() (string, error)

InsertID is 同じデータをBigQueryになるべく入れないようにデータからInsertIDを作成する

func (*QueryStat) Save

func (s *QueryStat) Save() (map[string]bigquery.Value, string, error)

Save is bigquery.ValueSaver interface

type QueryStatsCopyService

type QueryStatsCopyService struct {
	Spanner *spanner.Client
	BQ      *bigquery.Client
	// contains filtered or unexported fields
}

QueryStatsCopyService is QueryStatsをCopyする機能

deprecated

func NewQueryStatsCopyService

func NewQueryStatsCopyService(ctx context.Context, bq *bigquery.Client) (*QueryStatsCopyService, error)

NewQueryStatsCopyService is QueryStatsCopyServiceを生成する

deprecated

func NewQueryStatsCopyServiceWithSpannerClient

func NewQueryStatsCopyServiceWithSpannerClient(ctx context.Context, bq *bigquery.Client, spannerClient *spanner.Client) (*QueryStatsCopyService, error)

NewQueryStatsCopyServiceWithSpannerClient is Statsを取得したいSpanner DBが1つしかないのであれば、Spanner Clientを設定して、QueryStatsCopyServiceを作成する

deprecated

func (*QueryStatsCopyService) Close

func (s *QueryStatsCopyService) Close() error

func (*QueryStatsCopyService) Copy

func (s *QueryStatsCopyService) Copy(ctx context.Context, dataset *bigquery.Dataset, bigQueryTable string, queryStatsTable QueryStatsTopTable, intervalEnd time.Time) (int, error)

Copy is SpannerからQuery Statsを引っ張ってきて、BigQueryにCopyしていく

deprecated

func (*QueryStatsCopyService) CopyWithSpannerClient

func (s *QueryStatsCopyService) CopyWithSpannerClient(ctx context.Context, dataset *bigquery.Dataset, bigQueryTable string, queryStatsTable QueryStatsTopTable, spannerClient *spanner.Client, intervalEnd time.Time) (int, error)

CopyWithSpannerClient is SpannerからQuery Statsを引っ張ってきて、BigQueryにCopyしていく

deprecated

func (*QueryStatsCopyService) CreateTable

func (s *QueryStatsCopyService) CreateTable(ctx context.Context, dataset *bigquery.Dataset, table string) error

ToBigQuery is QueryStatsをBigQueryにStreamingInsertでInsertする

deprecated

func (*QueryStatsCopyService) GetQueryStats

func (s *QueryStatsCopyService) GetQueryStats(ctx context.Context, table QueryStatsTopTable, intervalEnd time.Time) ([]*QueryStat, error)

GetQueryStats is SpannerからQueryStatsを取得する

deprecated

func (*QueryStatsCopyService) GetQueryStatsWithSpannerClient

func (s *QueryStatsCopyService) GetQueryStatsWithSpannerClient(ctx context.Context, table QueryStatsTopTable, spannerClient *spanner.Client, intervalEnd time.Time) ([]*QueryStat, error)

GetQueryStatsWithSpannerClient is 指定したSpannerClientを利用して、SpannerからQueryStatsを取得する

deprecated

type QueryStatsParam

type QueryStatsParam struct {
	Table string
}

deprecated

type QueryStatsTopTable

type QueryStatsTopTable string

deprecated

const (
	//
	// deprecated
	QueryStatsTopMinuteTable QueryStatsTopTable = "spanner_sys.query_stats_top_minute"

	//
	// deprecated
	QueryStatsTop10MinuteTable QueryStatsTopTable = "spanner_sys.query_stats_top_10minute"

	//
	// deprecated
	QueryStatsTopHourTable QueryStatsTopTable = "spanner_sys.query_stats_top_hour"
)

type QueryWithStats

type QueryWithStats struct {
	ElapsedTime                string `json:"elapsedTime"`
	CPUTime                    string `json:"cpuTime"`
	QueryPlanCreationTime      string `json:"queryPlanCreationTime"`
	RuntimeCreationTime        string `json:"runtimeCreationTime"`
	StatisticsLoadTime         string `json:"statisticsLoadTime"`
	FilesystemDelaySeconds     string `json:"filesystemDelaySeconds"`
	DeletedRowsScanned         int64  `json:"deletedRowsScanned"`
	RemoteServerCalls          string `json:"remoteServerCalls"`
	RowsReturned               int64  `json:"rowsReturned"`
	RowsScanned                int64  `json:"rowsScanned"`
	DataBytesRead              int64  `json:"dataBytesRead"`
	BytesReturned              int64  `json:"bytesReturned"`
	OptimizerStatisticsPackage string `json:"optimizerStatisticsPackage"`
	QueryText                  string `json:"queryText"`
	OptimizerVersion           string `json:"optimizerVersion"`
}

QueryWithStats is Query 実行時に返ってくるStatsの情報を持つstruct

func ConvertQueryWithStats

func ConvertQueryWithStats(stats map[string]interface{}) (*QueryWithStats, error)

ConvertQueryWithStats is Query 実行時に返ってくる stats の map を struct に割り当てる

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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