frames

package module
v0.6.6-8-x-v0.9.12-8-x Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: Apache-2.0 Imports: 19 Imported by: 1

README

V3IO Frames

Build Status GoDoc License

V3IO Frames ("Frames") is a multi-model open-source data-access library, developed by Iguazio, which provides a unified high-performance DataFrame API for working with data in the data store of the Iguazio Data Science Platform ("the platform").

In This Document

Client Python API Reference

Overview

To use Frames, you first need to import the v3io_frames Python library. For example:

import v3io_frames as v3f

Then, you need to create and initialize an instance of the Client class; see Client Constructor. You can then use the client methods to perform different data operations on the supported backend types:

Client Methods

The Client class features the following methods for supporting basic data operations:

  • create — creates a new TSDB table or a stream ("backend data").
  • delete — deletes a table or stream or specific table items
  • read — reads data from a table or stream into pandas DataFrames.
  • write — writes data from pandas DataFrames to a table or stream.
  • execute — executes a backend-specific command on a table or stream. Each backend may support multiple commands.

Backend Types

All Frames client methods receive a backend parameter for setting the Frames backend type. Frames supports the following backend types:

  • kv — a platform NoSQL (key/value) table.
  • stream — a platform data stream.
  • tsdb — a time-series database (TSDB).
  • csv — a comma-separated-value (CSV) file. This backend type is used only for testing purposes.

Note: Some method parameters are common to all backend types and some are backend-specific, as detailed in this reference.

User Authentication

When creating a Frames client, you must provide valid platform credentials for accessing the backend data, which Frames will use to identify the identity of the user. This can be done by using any of the following alternative methods (documented in order of precedence):

  • Provide the authentication credentials in the Client constructor parameters by using either of the following methods:

    • Set the token constructor parameter to a valid platform access key with the required data-access permissions.
    • Set the user and password constructor parameters to the username and password of a platform user with the required data-access permissions.

    Note: You can't use both methods concurrently: setting both the token and username and password parameters in the same constructor call will produce an error.

  • Set the authentication credentials in environment variables, by using either of the following methods:

    • Set the V3IO_ACCESS_KEY environment variable to a valid platform access key with the required data-access permissions.
    • Set the V3IO_USERNAME and V3IO_PASSWORD environment variables to the username and password of a platform user with the required data-access permissions.

    Note:

    • When the client constructor is called with authentication parameters, the authentication-credentials environment variables (if defined) are ignored.
    • When V3IO_ACCESS_KEY is defined, V3IO_USERNAME and V3IO_PASSWORD are ignored.
    • The platform's Jupyter Notebook service automatically defines the V3IO_ACCESS_KEY environment variable and initializes it to a valid access key for the running user of the service.

Client Constructor

All Frames operations are executed via an object of the Client class.

Syntax
Client(address='', container='', user='', password='', token='')

Parameters and Data Members
  • address — The address of the Frames service (framesdb).
    When running locally on the platform (for example, from a Jupyter Notebook service), set this parameter to framesd:8081 to use the gRPC (recommended) or to framesd:8080 to use HTTP.
    When connecting to the platform remotely, set this parameter to the API address of Frames platform service of the parent tenant. You can copy this address from the API column of the V3IO Frames service on the Services platform dashboard page.

    • Type: str
    • Requirement: Required
  • container — The name of the platform data container that contains the backend data. For example, "bigdata" or "users".

    • Type: str
    • Requirement: Required
  • user — The username of a platform user with permissions to access the backend data.

    • Type: str
    • Requirement: Required when neither the token parameter or the authentication environment variables are set. See User Authentication.
      When the user parameter is set, the password parameter must also be set to a matching user password.
  • password — A platform password for the user configured in the user parameter.

  • token — A valid platform access key that allows access to the backend data. To get this access key, select the user profile icon on any platform dashboard page, select Access Tokens, and copy an existing access key or create a new key.

    • Type: str
    • Requirement: Required when neither the user or password parameters or the authentication environment variables are set. See User Authentication.

Return Value

Returns a new Frames Client data object.

Example

The following example, for local platform execution, creates a Frames client for accessing data in the "users" container by using the authentication credentials of the user "iguazio":

import v3io_frames as v3f
client = v3f.Client("framesd:8081", user="iguazio", password="mypass", container="users")

Common Client Method Parameters

All client methods receive the following common parameters:

  • backend — The backend data type for the operation. See the backend-types descriptions in the overview.

    • Type: str
    • Valid Values: "csv" | "kv" | "stream" | "tsdb"
    • Requirement: Required
  • table — The relative path to the backend data — A directory in the target platform data container (as configured for the client object) that represents a TSDB or NoSQL table or a data stream. For example, "mytable" or "examples/tsdb/my_metrics".

    • Type: str
    • Requirement: Required unless otherwise specified in the method-specific documentation

Additional method-specific parameters are described for each method.

create Method

Creates a new TSDB table or a stream in a platform data container, according to the specified backend type.

The create method is supported by the tsdb and stream backends, but not by the kv backend, because NoSQL tables in the platform don't need to be created prior to ingestion; when ingesting data into a table that doesn't exist, the table is automatically created.

Syntax
create(backend, table, attrs=None)

Common create Parameters

All Frames backends that support the create method support the following common parameters:

  • attrs — A dictionary of <argument name>: <value> pairs for passing additional backend-specific parameters (arguments).

    • Type: dict
    • Requirement: Optional
    • Default Value: None

tsdb Backend create Parameters

The following tsdb backend parameters are passed via the attrs parameter of the create method:

  • rate — The ingestion rate TSDB's metric-samples, as "[0-9]+/[smh]" (where s = seconds, m = minutes, and h = hours); for example, "1/s" (one sample per minute). The rate should be calculated according to the slowest expected ingestion rate.

    • Type: str
    • Requirement: Required
  • aggregates — Default aggregates to calculate in real time during the samples ingestion, as a comma-separated list of supported aggregation functions.

    • Type: str
    • Requirement: Optional
  • aggregation-granularity — Aggregation granularity; i.e., a time interval for applying the aggregation functions, if configured in the aggregates parameter.

    • Type: str
    • Requirement: Optional

For detailed information about these parameters, refer to the V3IO TSDB documentation.

Example:

client.create("tsdb", "/mytable", attrs={"rate": "1/m"})

stream Backend create Parameters

The following stream backend parameters are passed via the attrs parameter of the create method:

  • shards (Optional) (default: 1) — int — The number of stream shards to create.
  • retention_hours (Optional) (default: 24) — int — The stream's retention period, in hours.

For detailed information about these parameters, refer to the platform streams documentation.

Example:

client.create("stream", "/mystream", attrs={"shards": 6})

write Method

Writes data from a DataFrame to a table or stream in a platform data container, according to the specified backend type.

Syntax
write(backend, table, dfs, condition='', labels=None, max_in_message=0,
    index_cols=None, partition_keys=None)
  • When the value of the iterator parameter is False (default) — returns a single DataFrame.
  • When the value of the iterator parameter is True — returns a DataFrames iterator. The returned DataFrames include a "labels" DataFrame attribute with backend-specific data, if applicable; for example, for the stream backend, this attribute holds the sequence number of the last stream record that was read.

Common write Parameters

All Frames backends that support the write method support the following common parameters:

  • dfs (Required) — A single DataFrame, a list of DataFrames, or a DataFrames iterator — One or more DataFrames containing the data to write.
  • index_cols (Optional) (default: None) — []str — A list of column (attribute) names to be used as index columns for the write operation, regardless of any index-column definitions in the DataFrame. By default, the DataFrame's index columns are used.

    Note: The significance and supported number of index columns is backend specific. For example, the kv backend supports only a single index column for the primary-key item attribute, while the tsdb backend supports additional index columns for metric labels.

  • labels (Optional) (default: None) — This parameter is currently defined for all backends but is used only for the TSDB backend, therefore it's documented as part of the write method's tsdb backend parameters.
  • max_in_message (Optional) (default: 0)
  • partition_keys (Optional) (default: None) — []str — [Not supported in this version]

Example:

data = [["tom", 10], ["nick", 15], ["juli", 14]]
df = pd.DataFrame(data, columns = ["name", "age"])
df.set_index("name")
client.write(backend="kv", table="mytable", dfs=df)

tsdb Backend write Parameters
  • labels (Optional) (default: None) — dict — A dictionary of <label name>: <label value> pairs that define metric labels to add to all written metric-sample table items. Note that the values of the metric labels must be of type string.

kv Backend write Parameters
  • condition (Optional) (default: None) — A platform condition expression that defines conditions for performing the write operation. For detailed information about platform condition expressions, see the platform documentation.

Example:

data = [["tom", 10, "TLV"], ["nick", 15, "Berlin"], ["juli", 14, "NY"]]
df = pd.DataFrame(data, columns = ["name", "age", "city"])
df.set_index("name")
v3c.write(backend="kv", table="mytable", dfs=df, condition="age>14")

read Method

Reads data from a table or stream in a platform data container to a DataFrame, according to the configured backend.

Reads data from a backend.

Syntax
read(backend='', table='', query='', columns=None, filter='', group_by='',
    limit=0, data_format='', row_layout=False, max_in_message=0, marker='',
    iterator=False, **kw)

Common read Parameters

All Frames backends that support the read method support the following common parameters:

  • iterator — (Optional) (default: False) — boolTrue to return a DataFrames iterator; False to return a single DataFrame.
  • filter (Optional) — str — A query filter.
    This parameter can't be used concurrently with the query parameter.
  • columns[]str — A list of attributes (columns) to return.
    This parameter can't be used concurrently with the query parameter.
  • data_formatstr — The data format. [Not supported in this version]
  • markerstr — A query marker. [Not supported in this version]
  • limitint — The maximum number of rows to return. [Not supported in this version]
  • row_layout (Optional) (default: False) — boolTrue to use a row layout; False (default) to use a column layout. [Not supported in this version]

tsdb Backend read Parameters
  • startstr — Start (minimum) time for the read operation, as a string containing an RFC 3339 time, a Unix timestamp in milliseconds, a relative time of the format "now" or "now-[0-9]+[mhd]" (where m = minutes, h = hours, and 'd' = days), or 0 for the earliest time. For example: "2016-01-02T15:34:26Z"; "1451748866"; "now-90m"; "0".
    The default start time is <end time> - 1h.
  • endstr — End (maximum) time for the read operation, as a string containing an RFC 3339 time, a Unix timestamp in milliseconds, a relative time of the format "now" or "now-[0-9]+[mhd]" (where m = minutes, h = hours, and 'd' = days), or 0 for the earliest time. For example: "2018-09-26T14:10:20Z"; "1537971006000"; "now-3h"; "now-7d".
    The default end time is "now".
  • step (Optional) — str — For an aggregation query, this parameter specifies the aggregation interval for applying the aggregation functions; by default, the aggregation is applied to all sample data within the requested time range.
    When the query doesn't include aggregates, this parameter specifies an interval for downsampling the raw sample data.
  • aggregators (Optional) — str — Aggregation information to return, as a comma-separated list of supported aggregation functions.
  • aggregationWindow (Optional) — str — Aggregation interval for applying the aggregation functions, if set in the aggregators or query parameters.
  • query (Optional) — str — A query string in SQL format.

    Note: When the query parameter is set, you can either specify the target table within the query string (FROM <table>) or by setting the table parameter of the read method to the table path. When the query string specifies the target table, the value of the table parameter (if set) is ignored.

  • group_by (Optional) — str — A group-by query string.
    This parameter can't be used concurrently with the query parameter.
  • multi_index (Optional) — boolTrue to receive the read results as multi-index DataFrames where the labels are used as index columns in addition to the metric sample-time primary-key attribute; False (default) only the timestamp will function as the index.

For detailed information about these parameters, refer to the V3IO TSDB documentation.

Example:

df = client.read(backend="tsdb", query="select avg(cpu) as cpu, avg(diskio), avg(network)from mytable", start="now-1d", end="now", step="2h")

kv Backend read Parameters
  • reset_indexbool — Reset the index. When set to false (default), the DataFrame will have the key column of the v3io kv as the index column. When set to true, the index will be reset to a range index.
  • max_in_messageint — The maximum number of rows per message.
  • sharding_keys[]string (Experimental) — A list of specific sharding keys to query, for range-scan formatted tables only.
  • segments[]int64 [Not supported in this version]
  • total_segmentsint64 [Not supported in this version]
  • sort_key_range_startstr [Not supported in this version]
  • sort_key_range_endstr [Not supported in this version]

For detailed information about these parameters, refer to the platform's NoSQL documentation.

Example:

df = client.read(backend="kv", table="mytable", filter="col1>666")

stream Backend read Parameters
  • seekstr — Valid values: "time" | "seq"/"sequence" | "latest" | "earliest".
    If the "seq"|"sequence" seek type is set, you need to provide the desired record sequence ID via the sequence parameter.
    If the time seek type is set, you need to provide the desired start time via the start parameter.
  • shard_idstr
  • sequenceint64 (Optional)

For detailed information about these parameters, refer to the platform streams documentation.

Example:

df = client.read(backend="stream", table="mytable", seek="latest", shard_id="5")

Return Value
  • When the value of the iterator parameter is False (default) — returns a single DataFrame.
  • When the value of the iterator parameter is True — returns a DataFrames iterator.

Note: The returned DataFrames include a labels DataFrame attribute with backend-specific data, if applicable. For example, for the stream backend, this attribute holds the sequence number of the last stream record that was read.

delete Method

Deletes a table or stream or specific table items from a platform data container, according to the specified backend type.

Syntax
delete(backend, table, filter='', start='', end='')

tsdb Backend delete Parameters
  • startstr — Start (minimum) time for the delete operation, as a string containing an RFC 3339 time, a Unix timestamp in milliseconds, a relative time of the format "now" or "now-[0-9]+[mhd]" (where m = minutes, h = hours, and 'd' = days), or 0 for the earliest time. For example: "2016-01-02T15:34:26Z"; "1451748866"; "now-90m"; "0".
    The default start time is <end time> - 1h.
  • endstr — End (maximum) time for the delete operation, as a string containing an RFC 3339 time, a Unix timestamp in milliseconds, a relative time of the format "now" or "now-[0-9]+[mhd]" (where m = minutes, h = hours, and 'd' = days), or 0 for the earliest time. For example: "2018-09-26T14:10:20Z"; "1537971006000"; "now-3h"; "now-7d".
    The default end time is "now".

Note: When neither the start or end parameters are set, the entire TSDB table is deleted.

For detailed information about these parameters, refer to the V3IO TSDB documentation.

Example:

df = client.delete(backend="tsdb", table="mytable", start="now-1d", end="now-5h")

kv Backend delete Parameters
  • filterstr — A platform filter expression that identifies specific items to delete. For detailed information about platform filter expressions, see the platform documentation.

Note: When the filter parameter isn't set, the entire table is deleted.

Example:

df = client.delete(backend="kv", table="mytable", filter="age > 40")

execute Method

Extends the basic CRUD functionality of the other client methods via backend-specific commands.

Syntax
execute(backend, table, command='', args=None)

Common execute Parameters

All Frames backends that support the execute method support the following common parameters:

  • args — A dictionary of <argument name>: <value> pairs for passing command-specific parameters (arguments).

    • Type: dict
    • Requirement: Optional
    • Default Value: None

tsdb Backend execute Commands

Currently, no execute commands are available for the tsdb backend.

kv Backend execute Commands
  • infer | inferschema — Infers the data schema of a given NoSQL table and creates a schema file for the table.

    Example:

    client.execute(backend="kv", table="mytable", command="infer")
    

stream Backend execute Commands
  • put — Adds records to a stream.

    Example:

    client.execute(backend="stream", table="mystream", command="put", args={"data": "this a record", "clientinfo": "some_info", "partition": "partition_key"})
    

Contributing

To contribute to V3IO Frames, you need to be aware of the following:

Components

The following components are required for building Frames code:

  • Go server with support for both the gRPC and HTTP protocols
  • Go client
  • Python client

Development

The core is written in Go. The development is done on the development branch and then released to the master branch.

Before submitting changes, test the code:

  • To execute the Go tests, run make test.
  • To execute the Python tests, run make test-python.

Adding and Changing Dependencies
  • If you add Go dependencies, run make update-go-deps.
  • If you add Python dependencies, update clients/py/Pipfile and run make update-py-deps.

Travis CI

Integration tests are run on Travis CI. See .travis.yml for details.

The following environment variables are defined in the Travis settings:

  • Docker Container Registry (Quay.io)
    • DOCKER_PASSWORD — a password for pushing images to Quay.io.
    • DOCKER_USERNAME — a username for pushing images to Quay.io.
  • Python Package Index (PyPI)
    • V3IO_PYPI_PASSWORD — a password for pushing a new release to PyPi.
    • V3IO_PYPI_USER — a username for pushing a new release to PyPi.
  • Iguazio Data Science Platform
    • V3IO_SESSION — a JSON encoded map with session information for running tests. For example:

      '{"url":"45.39.128.5:8081","container":"mitzi","user":"daffy","password":"rabbit season"}'
      

      Note: Make sure to embed the JSON object within single quotes ('{...}').

Docker Image

Building the Image

Use the following command to build the Docker image:

make build-docker

Running the Image

Use the following command to run the Docker image:

docker run \
	-v /path/to/config.yaml:/etc/framesd.yaml \
	quay.io/v3io/frames:unstable

LICENSE

Apache 2

Documentation

Overview

Package frames provides an efficient way of moving data from various sources.

The package is composed os a HTTP web server that can serve data from various sources and from clients in Go and in Python.

Index

Constants

View Source
const (
	IgnoreError = pb.ErrorOptions_IGNORE
	FailOnError = pb.ErrorOptions_FAIL
)

Shortcut for fail/ignore

Variables

View Source
var (
	BoolType   = DType(pb.DType_BOOLEAN)
	FloatType  = DType(pb.DType_FLOAT)
	IntType    = DType(pb.DType_INTEGER)
	StringType = DType(pb.DType_STRING)
	TimeType   = DType(pb.DType_TIME)
)

Possible data types

View Source
var (
	// DefaultLogLevel is the default log verbosity
	DefaultLogLevel string
)
View Source
var ZeroTime time.Time

ZeroTime is zero value for time

Functions

func MarshalFrame

func MarshalFrame(frame Frame) ([]byte, error)

MarshalFrame serializes a frame to []byte

func NewLogger

func NewLogger(verbose string) (logger.Logger, error)

NewLogger returns a new logger

func SessionFromEnv

func SessionFromEnv() (*pb.Session, error)

SessionFromEnv return a session from V3IO_SESSION environment variable (JSON encoded)

Types

type BackendConfig

type BackendConfig struct {
	Type                    string `json:"type"` // v3io, csv, ...
	Name                    string `json:"name"`
	Workers                 int    `json:"workers"`
	V3ioGoWorkers           int    `json:"v3ioGoWorkers"`
	V3ioGoRequestChanLength int    `json:"v3ioGoRequestChanLength"`
	MaxConnections          int    `json:"maxConnections"`

	// backend specific options
	Options map[string]interface{} `json:"options"`

	// CSV backend
	RootDir string `json:"rootdir,omitempty"`
}

BackendConfig is default backend configuration

type Client

type Client interface {
	// Read reads data from server
	Read(request *pb.ReadRequest) (FrameIterator, error)
	// Write writes data to server
	Write(request *WriteRequest) (FrameAppender, error)
	// Create creates a table
	Create(request *pb.CreateRequest) error
	// Delete deletes data or table
	Delete(request *pb.DeleteRequest) error
	// Exec executes a command on the backend
	Exec(request *pb.ExecRequest) (Frame, error)
}

Client interface

type Column

type Column interface {
	Len() int                                 // Number of elements
	Name() string                             // Column name
	DType() DType                             // Data type (e.g. IntType, FloatType ...)
	Ints() ([]int64, error)                   // Data as []int64
	IntAt(i int) (int64, error)               // Int value at index i
	Floats() ([]float64, error)               // Data as []float64
	FloatAt(i int) (float64, error)           // Float value at index i
	Strings() []string                        // Data as []string
	StringAt(i int) (string, error)           // String value at index i
	Times() ([]time.Time, error)              // Data as []time.Time
	TimeAt(i int) (time.Time, error)          // time.Time value at index i
	Bools() ([]bool, error)                   // Data as []bool
	BoolAt(i int) (bool, error)               // bool value at index i
	Slice(start int, end int) (Column, error) // Slice of data
	CopyWithName(newName string) Column       // Create a copy of the current column
}

Column is a data column

func NewLabelColumn

func NewLabelColumn(name string, value interface{}, size int) (Column, error)

NewLabelColumn returns a new slabel column

func NewSliceColumn

func NewSliceColumn(name string, data interface{}) (Column, error)

NewSliceColumn returns a new slice column

type ColumnBuilder

type ColumnBuilder interface {
	Append(value interface{}) error
	At(index int) (interface{}, error)
	Set(index int, value interface{}) error
	Delete(index int) error
	Finish() Column
}

ColumnBuilder is interface for building columns

func NewLabelColumnBuilder

func NewLabelColumnBuilder(name string, dtype DType, size int) ColumnBuilder

NewLabelColumnBuilder return a builder for LabelColumn

func NewSliceColumnBuilder

func NewSliceColumnBuilder(name string, dtype DType, size int) ColumnBuilder

NewSliceColumnBuilder return a builder for SliceColumn

type Config

type Config struct {
	Log            LogConfig `json:"log"`
	DefaultLimit   int       `json:"limit,omitempty"`
	DefaultTimeout int       `json:"timeout,omitempty"`

	// default V3IO connection details
	WebAPIEndpoint string `json:"webApiEndpoint"`
	Container      string `json:"container"`
	Username       string `json:"username,omitempty"`
	Password       string `json:"password,omitempty"`
	SessionKey     string `json:"sessionKey,omitempty"`

	// Number of parallel V3IO worker routines
	Workers int `json:"workers"`

	QuerierCacheSize                 int  `json:"querierCacheSize"`
	TsdbLoadPartitionsFromSchemaAttr bool `json:"tsdbLoadPartitionsFromSchemaAttr"`

	Backends []*BackendConfig `json:"backends,omitempty"`
}

Config is server configuration

func (*Config) InitDefaults

func (c *Config) InitDefaults() error

InitDefaults initializes the defaults for configuration

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration

type CreateRequest

type CreateRequest struct {
	Proto    *pb.CreateRequest
	Password SecretString
	Token    SecretString
}

CreateRequest is a table creation request

type DType

type DType pb.DType

DType is data type

type DataBackend

type DataBackend interface {
	// TODO: Expose name, type, config ... ?
	Read(request *ReadRequest) (FrameIterator, error)
	Write(request *WriteRequest) (FrameAppender, error) // TODO: use Appender for write streaming
	Create(request *CreateRequest) error
	Delete(request *DeleteRequest) error
	Exec(request *ExecRequest) (Frame, error)
}

DataBackend is an interface for read/write on backend

type Decoder

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

Decoder is message decoder

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(msg proto.Message) error

Decode decodes message from d.r

type DeleteRequest

type DeleteRequest struct {
	Proto    *pb.DeleteRequest
	Password SecretString
	Token    SecretString
}

DeleteRequest is a deletion request

type Encoder

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

Encoder is message encoder

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns new Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(msg proto.Message) error

Encode encoders the message to e.w

type ExecRequest

type ExecRequest struct {
	Proto    *pb.ExecRequest
	Password SecretString
	Token    SecretString
}

ExecRequest is execution request

type Frame

type Frame interface {
	Labels() map[string]interface{}          // Label set
	Names() []string                         // Column names
	Indices() []Column                       // Index columns
	Len() int                                // Number of rows
	Column(name string) (Column, error)      // Column by name
	Slice(start int, end int) (Frame, error) // Slice of Frame
	IterRows(includeIndex bool) RowIterator  // Iterate over rows
}

Frame is a collection of columns

func NewFrame

func NewFrame(columns []Column, indices []Column, labels map[string]interface{}) (Frame, error)

NewFrame returns a new Frame

func NewFrameFromMap

func NewFrameFromMap(columns map[string]interface{}, indices map[string]interface{}) (Frame, error)

NewFrameFromMap returns a new MapFrame from a map

func NewFrameFromProto

func NewFrameFromProto(msg *pb.Frame) Frame

NewFrameFromProto return a new frame from protobuf message

func NewFrameFromRows

func NewFrameFromRows(rows []map[string]interface{}, indices []string, labels map[string]interface{}) (Frame, error)

NewFrameFromRows creates a new frame from rows

func UnmarshalFrame

func UnmarshalFrame(data []byte) (Frame, error)

UnmarshalFrame de-serialize a frame from []byte

type FrameAppender

type FrameAppender interface {
	Add(frame Frame) error
	WaitForComplete(timeout time.Duration) error
	Close()
}

FrameAppender appends frames

type FrameIterator

type FrameIterator interface {
	Next() bool
	Err() error
	At() Frame
}

FrameIterator iterates over frames

type JoinStruct

type JoinStruct = pb.JoinStruct

JoinStruct is a join structure

type LogConfig

type LogConfig struct {
	Level string `json:"level,omitempty"`
}

LogConfig is the logging configuration

type Query

type Query struct {
	Table   string
	Columns []string
	Filter  string
	GroupBy string
}

Query is query structure

func ParseSQL

func ParseSQL(sql string) (*Query, error)

ParseSQL parsers SQL query to a Query struct

type ReadRequest

type ReadRequest struct {
	Proto    *pb.ReadRequest
	Password SecretString
	Token    SecretString
}

ReadRequest is a read/query request

type RowIterator

type RowIterator interface {
	Next() bool                      // Advance to next row
	Row() map[string]interface{}     // Row as map of name->value
	RowNum() int                     // Current row number
	Indices() map[string]interface{} // MultiIndex as name->value
	Err() error                      // Iteration error
}

RowIterator is an iterator over frame rows

type SchemaField

type SchemaField = pb.SchemaField

SchemaField represents a schema field for Avro record.

type SchemaKey

type SchemaKey = pb.SchemaKey

SchemaKey is a schema key

type SecretString

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

Hides a string such as a password from both plain and json logs.

func InitSecretString

func InitSecretString(s string) SecretString

func (SecretString) Get

func (s SecretString) Get() string

type Server

type Server interface {
	Start() error
	State() ServerState
	Err() error
}

Server is frames server interface

type ServerBase

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

ServerBase have common functionality for server

func NewServerBase

func NewServerBase() *ServerBase

NewServerBase returns a new server base

func (*ServerBase) Err

func (s *ServerBase) Err() error

Err returns the server error

func (*ServerBase) SetError

func (s *ServerBase) SetError(err error)

SetError sets current error and will change state to ErrorState

func (*ServerBase) SetState

func (s *ServerBase) SetState(state ServerState)

SetState sets the server state

func (*ServerBase) State

func (s *ServerBase) State() ServerState

State return the server state

type ServerState

type ServerState string

ServerState is state of server

const (
	ReadyState   ServerState = "ready"
	RunningState ServerState = "running"
	ErrorState   ServerState = "error"
)

Possible server states

type Session

type Session = pb.Session

Session information

func InitSessionDefaults

func InitSessionDefaults(session *Session, framesConfig *Config) *Session

InitSessionDefaults initializes session defaults

func NewSession

func NewSession(url, container, path, user, password, token, id string) (*Session, error)

NewSession will create a new session. It will populate missing values from the V3IO_SESSION environment variable (JSON encoded)

type TableSchema

type TableSchema = pb.TableSchema

TableSchema is a table schema

type WriteRequest

type WriteRequest struct {
	Session  *Session
	Password SecretString
	Token    SecretString
	Backend  string // backend name
	Table    string // Table name (path)
	// Data message sent with the write request (in case of a stream multiple messages can follow)
	ImmidiateData Frame
	// Expression template, for update expressions generated from combining columns data with expression
	Expression string
	// Condition template, for update conditions generated from combining columns data with expression
	Condition string
	// Will we get more message chunks (in a stream), if not we can complete
	HaveMore bool
}

WriteRequest is request for writing data TODO: Unite with probouf (currenly the protobuf message combines both this and a frame message)

Directories

Path Synopsis
csv
kv
cmd

Jump to

Keyboard shortcuts

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