Documentation
¶
Index ¶
- Constants
- type Hub
- func (h *Hub) Abort()
- func (h *Hub) AddScanMetadata(iter Iterator)
- func (h *Hub) ClearScanMetadata()
- func (h *Hub) Close()
- func (h *Hub) EndScan(iter Iterator, limit int64)
- func (h *Hub) Explain(columns []string, quals []*proto.Qual, sortKeys []string, verbose bool, ...) ([]string, error)
- func (h *Hub) GetAggregateConnectionChild(connectionName string) string
- func (h *Hub) GetCommandSchema() map[string]*proto.TableSchema
- func (h *Hub) GetPathKeys(opts types.Options) ([]types.PathKey, error)
- func (h *Hub) GetRelSize(columns []string, quals []*proto.Qual, opts types.Options) (types.RelSize, error)
- func (h *Hub) GetSchema(remoteSchema string, localSchema string) (*proto.Schema, error)
- func (h *Hub) HandleCacheCommand(command string) error
- func (h *Hub) IsLegacyAggregatorConnection(connectionName string) (res bool)
- func (h *Hub) LoadConnectionConfig() (bool, error)
- func (h *Hub) RemoveIterator(iterator Iterator)
- func (h *Hub) Scan(columns []string, quals *proto.Quals, limit int64, opts types.Options) (Iterator, error)
- func (h *Hub) ValidateCacheCommand(command string) error
- type Iterator
- type QueryResult
- type ScanMetadata
Constants ¶
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 ¶
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
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) EndScan ¶ added in v1.2.0
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
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 ¶
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 ¶
GetSchema returns the schema for a name. Load the plugin for the connection if needed
func (*Hub) HandleCacheCommand ¶ added in v0.2.0
func (*Hub) IsLegacyAggregatorConnection ¶ added in v1.3.0
IsLegacyAggregatorConnection returns whether the connection with the given name is using a legacy plugin and has type "aggregator"
func (*Hub) LoadConnectionConfig ¶
LoadConnectionConfig loads the connection config and returns whether it has changed
func (*Hub) RemoveIterator ¶ added in v0.0.35
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
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