hub

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryStatusReady    queryStatus = "ready"
	QueryStatusStarted  queryStatus = "started"
	QueryStatusError    queryStatus = "error"
	QueryStatusComplete queryStatus = "complete"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

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

Hub is a structure representing plugin hub

func GetHub

func GetHub() (*Hub, error)

func (*Hub) Abort added in v0.0.35

func (h *Hub) Abort()

Abort shuts down currently running queries

func (*Hub) AddScanMetadata added in v1.2.0

func (h *Hub) AddScanMetadata(iter Iterator)

func (*Hub) ApplySetting added in v1.7.0

func (h *Hub) ApplySetting(key string, value string) error

func (*Hub) ClearScanMetadata added in v1.2.0

func (h *Hub) ClearScanMetadata()

ClearScanMetadata deletes all stored scan metadata. It is called by steampipe after retrieving timing information for the previous query

func (*Hub) Close

func (h *Hub) Close()

Close shuts down all plugin clients

func (*Hub) EndScan added in v1.2.0

func (h *Hub) EndScan(iter Iterator, limit int64)

EndScan is called when Postgres terminates the scan (because it has received enough rows of data)

func (*Hub) Explain

func (h *Hub) Explain(columns []string, quals []*proto.Qual, sortKeys []string, verbose bool, opts types.Options) ([]string, error)

Explain :: hook called on explain.

Returns:
    An iterable of strings to display in the EXPLAIN output.

func (*Hub) GetIterator added in v1.4.0

func (h *Hub) GetIterator(columns []string, quals *proto.Quals, unhandledRestrictions int, limit int64, opts types.Options) (Iterator, error)

GetIterator creates and returns an iterator

func (*Hub) GetLegacySettingsSchema added in v1.7.2

func (h *Hub) GetLegacySettingsSchema() map[string]*proto.TableSchema

func (*Hub) GetPathKeys

func (h *Hub) GetPathKeys(opts types.Options) ([]types.PathKey, error)

GetPathKeys Is a method called from the planner to add additional Path to the planner.

By default, the planner generates an (unparameterized) path, which
can be reasoned about like a SequentialScan, optionally filtered.
This method allows the implementor to declare other Paths,
corresponding to faster access methods for specific attributes.
Such a parameterized path can be reasoned about like an IndexScan.
For example, with the following query::
    select * from foreign_table inner join local_table using(id);
where foreign_table is a foreign table containing 100000 rows, and
local_table is a regular table containing 100 rows.
The previous query would probably be transformed to a plan similar to
this one::
    ┌────────────────────────────────────────────────────────────────────────────────────┐
    │                                     QUERY PLAN                                     │
    ├────────────────────────────────────────────────────────────────────────────────────┤
    │ Hash Join  (cost=57.67..4021812.67 rows=615000 width=68)                           │
    │   Hash Cond: (foreign_table.id = local_table.id)                                   │
    │   ->  Foreign Scan on foreign_table (cost=20.00..4000000.00 rows=100000 width=40)  │
    │   ->  Hash  (cost=22.30..22.30 rows=1230 width=36)                                 │
    │         ->  Seq Scan on local_table (cost=0.00..22.30 rows=1230 width=36)          │
    └────────────────────────────────────────────────────────────────────────────────────┘
But with a parameterized path declared on the id key, with the knowledge that this key
is unique on the foreign side, the following plan might get chosen::
    ┌───────────────────────────────────────────────────────────────────────┐
    │                              QUERY PLAN                               │
    ├───────────────────────────────────────────────────────────────────────┤
    │ Nested Loop  (cost=20.00..49234.60 rows=615000 width=68)              │
    │   ->  Seq Scan on local_table (cost=0.00..22.30 rows=1230 width=36)   │
    │   ->  Foreign Scan on remote_table (cost=20.00..40.00 rows=1 width=40)│
    │         Filter: (id = local_table.id)                                 │
    └───────────────────────────────────────────────────────────────────────┘
Returns:
    A list of tuples of the form: (key_columns, expected_rows),
    where key_columns is a tuple containing the columns on which
    the path can be used, and expected_rows is the number of rows
    this path might return for a simple lookup.
    For example, the return value corresponding to the previous scenario would be::
        [(('id',), 1)]

func (*Hub) GetRelSize

func (h *Hub) GetRelSize(columns []string, quals []*proto.Qual, opts types.Options) (types.RelSize, error)

GetRelSize is a method called from the planner to estimate the resulting relation size for a scan.

It will help the planner in deciding between different types of plans,
according to their costs.
Args:
    columns (list): The list of columns that must be returned.
    quals (list): A list of Qual instances describing the filters
        applied to this scan.
Returns:
    A struct of the form (expected_number_of_rows, avg_row_width (in bytes))

func (*Hub) GetSchema

func (h *Hub) GetSchema(remoteSchema string, localSchema string) (*proto.Schema, error)

GetSchema returns the schema for a name. Load the plugin for the connection if needed

func (*Hub) GetSettingsSchema added in v1.7.0

func (h *Hub) GetSettingsSchema() map[string]*proto.TableSchema

func (*Hub) HandleLegacyCacheCommand added in v1.7.2

func (h *Hub) HandleLegacyCacheCommand(command string) error

func (*Hub) LoadConnectionConfig

func (h *Hub) LoadConnectionConfig() (bool, error)

LoadConnectionConfig loads the connection config and returns whether it has changed

func (*Hub) RemoveIterator added in v0.0.35

func (h *Hub) RemoveIterator(iterator Iterator)

RemoveIterator removes an iterator from list of running iterators

func (*Hub) StartScan added in v1.4.0

func (h *Hub) StartScan(i Iterator) error

StartScan starts a scan (for scanIterators only = legacy iterators will have already started)

func (*Hub) ValidateCacheCommand added in v0.2.0

func (h *Hub) ValidateCacheCommand(command string) error

type Iterator

type Iterator interface {
	// ConnectionName returns the connection name that this iterator uses.
	// for cacheIterators, this will be an empty string
	ConnectionName() string
	// Next returns next row. Nil slice means there is no more rows to scan.
	Next() (map[string]interface{}, error)
	// Close stops an iteration and frees any resources.
	Close()
	Status() queryStatus
	Error() error
	CanIterate() bool
	GetScanMetadata() ScanMetadata
	GetTraceContext() *telemetry.TraceCtx
}

Iterator is an interface for table scanner implementations.

type QueryResult added in v1.3.0

type QueryResult struct {
	Rows []map[string]interface{}
}

func (*QueryResult) Append added in v1.3.0

func (q *QueryResult) Append(row map[string]interface{})

type ScanMetadata added in v1.2.0

type ScanMetadata struct {
	Id           int
	Table        string
	CacheHit     bool
	RowsFetched  int64
	HydrateCalls int64
	Columns      []string
	Quals        map[string]*proto.Quals
	Limit        int64
	StartTime    time.Time
	Duration     time.Duration
}

func (ScanMetadata) AsResultRow added in v1.2.0

func (m ScanMetadata) AsResultRow() map[string]interface{}

AsResultRow returns the ScanMetadata as a map[string]interface which can be returned as a query result

Jump to

Keyboard shortcuts

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