hub

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 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)

GetHub returns a hub singleton if there is an existing hub singleton instance return it, otherwise create it if a hub exists, but a different pluginDir is specified, reinitialise the hub with the new dir

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)

AddScanMetadata adds the scan metadata from the given iterator to the hubs array we append to this every time a scan completes (either due to end of data, or Postgres terminating) the full array is returned whenever a pop_scan_metadata command is received and the array is cleared

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) GetAggregateConnectionChild added in v0.1.0

func (h *Hub) GetAggregateConnectionChild(connectionName string) string

GetAggregateConnectionChild returns the name of first child connection of the aggregate connection with the given name

func (*Hub) GetCommandSchema added in v0.2.0

func (h *Hub) GetCommandSchema() 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) HandleCacheCommand added in v0.2.0

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

func (*Hub) IsAggregatorConnection added in v0.1.0

func (h *Hub) IsAggregatorConnection(connectionName string) bool

IsAggregatorConnection returns whether the connection with the given name is of type "aggregate"

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) Scan

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

Scan starts a table scan and returns an iterator

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(bool)
	Status() queryStatus
	Error() error
	CanIterate() bool
	GetScanMetadata() []ScanMetadata
	GetTraceContext() *telemetry.TraceCtx
}

Iterator is an interface for table scanner implementations.

func NewGroupIterator added in v0.0.42

func NewGroupIterator(name string, table string, qualMap map[string]*proto.Quals, columns []string, limit int64, connectionConfig *modconfig.Connection, h *Hub, scanTraceCtx *telemetry.TraceCtx) (Iterator, error)

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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