Documentation ¶
Overview ¶
Package mapping provides the API to convert data coming from Big Table into a data.Set.
The mapping system is based on a set of rules described inside a JSON mapping file, here's an example:
{ "raws": { "ui": "user_id" }, "mapped": { "oi": { "name": "is_opted_in", "values": { "0": "false", "1": "true" } } }, "reversed": [ { "name": "order_status", "values": { "1": "pending_payment", "2": "failed", "3": "processing", "4": "completed", "5": "on_hold", "6": "canceled", "7": "refunded" } } ] }
The mapping has 3 sections:
- raws: only the column qualifier is translated from its short version to a meaningful name.
- mapped: the column qualifier is translated from its short version to a meaningful name, and the value is translated from its short-value to the full value.
- reversed: the column qualifier contains the real data which is mapped to a value as described in the "values" property and the column name is taken from the "name" attribute.
Considering the mapping above, let's say we have a row with the following data coming from Big Table:
{ "ui": "12345", "oi": "1", "3": "1" }
The mapping system will map it to a new data.Event containing the following data:
{ "user_id": "12345", "is_opted_in": "true", "order_status": "processing" }
Index ¶
- func NewGCSBucketGetter(gcreds *GcloudCreds, bucketName string) (*gcsBucketGetter, *storage.Client, error)
- func NewGCSBucketGetterFromEnvironment(bucketName string) (*gcsBucketGetter, *storage.Client, error)
- func NewGCSBucketGetterWithClient(client *storage.Client, bucketName string) (*gcsBucketGetter, error)
- func Unwrap(err error) error
- func UnwrapAll(err error) error
- type GcloudCreds
- type Map
- type Mapper
- type Mapping
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGCSBucketGetter ¶ added in v1.1.1
func NewGCSBucketGetter(gcreds *GcloudCreds, bucketName string) (*gcsBucketGetter, *storage.Client, error)
func NewGCSBucketGetterFromEnvironment ¶ added in v1.1.1
func NewGCSBucketGetterWithClient ¶ added in v1.1.1
Types ¶
type GcloudCreds ¶ added in v1.1.1
type GcloudCreds struct { Type string `json:"type"` ProjectID string `json:"project_id"` PrivateKeyID string `json:"private_key_id"` PrivateKey string `json:"private_key"` ClientEmail string `json:"client_email"` ClientID string `json:"client_id"` AuthURI string `json:"auth_uri"` TokenURI string `json:"token_uri"` AuthProvider string `json:"auth_provider_x509_cert_url"` CertURL string `json:"client_x509_cert_url"` }
type Mapper ¶
type Mapper struct { // mapping coming from the JSON file *Mapping // contains filtered or unexported fields }
Mapper is in charge of translating data from Big Table into a human-readable format.
func (*Mapper) GetMappedEvents ¶
GetMappedEvents translates a slice of bigtable.ReadItem into a slice of data.Event. It uses the Mapping to know which columns to seek and each event is identified by the timestamp of the bigtable.ReadItem. So assuming there's a slice of 20 bigtable.ReadItem with the same timestamp, then the returned slice will have 1 data.Event containing a slice of 20 Cells.
type Mapping ¶
type Mapping struct { // columns that are taken as there are in Big Table Raws map[string]string `json:"raws"` // columns that needs to be mapped to a string value Mapped map[string]Map `json:"mapped"` // columns featuring a reversed mapping, meaning that the column qualifier is the data Reversed []Map `json:"reversed"` }
Mapping describes the mapping between data stored in Big Table and its human-readable representation.
func LoadMapping ¶
LoadMapping loads a mapping from a slice of bytes. You can use this function if you prefer to open the mapping file yourself.
func LoadMappingFromFile ¶
LoadMappingFromFile loads a mapping from a file.
func LoadMappingIO ¶ added in v1.1.1
func LoadMappingIO(reader io.ReadCloser) (*Mapping, error)
LoadMappingIO loads a mapping from a IO reader.
type Reader ¶ added in v1.1.1
type Reader struct {
// contains filtered or unexported fields
}