observation

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Published   = true
	Unpublished = false
)

Boolean indicators for publish flag

View Source
var ErrNoDataReturned = errors.New("no data returned in this row")

ErrNoDataReturned is returned if a Neo4j row has no data.

View Source
var ErrNoInstanceFound = errors.New("no instance found in datastore")

ErrNoInstanceFound is returned if no instance exists in neo4j

View Source
var ErrNoResultsFound = errors.New("the filter options created no results")

ErrNoResultsFound is returned if the selected filter options produce no results

View Source
var ErrUnrecognisedType = errors.New("the value returned was not a string")

ErrUnrecognisedType is returned if a Neo4j row does not have the expected string value.

Functions

This section is empty.

Types

type BoltRowReader

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

BoltRowReader translates Neo4j rows to CSV rows.

func NewBoltRowReader

func NewBoltRowReader(rows BoltRows, connection DBConnection) *BoltRowReader

NewBoltRowReader returns a new reader instace for the given bolt rows.

func (*BoltRowReader) Close

func (reader *BoltRowReader) Close() error

Close the reader and the connection (For pooled connections this will release it back into the pool)

func (*BoltRowReader) Read

func (reader *BoltRowReader) Read() (string, error)

Read the next row, or return io.EOF

type BoltRows

type BoltRows bolt.Rows

BoltRows provides an interface to each row of results returned from the database.

type CSVRowReader

type CSVRowReader interface {
	Read() (string, error)
	Close() error
}

CSVRowReader provides a reader of individual rows (lines) of a CSV file.

type DBConnection

type DBConnection interface {
	Close() error
}

DBConnection provides a method to close the connection once all the rows have been read

type DBPool

type DBPool interface {
	OpenPool() (bolt.Conn, error)
}

DBPool provides a pool of database connections

type DimensionFilter

type DimensionFilter struct {
	Name    string   `json:"name,omitempty"`
	Options []string `json:"options,omitempty"`
}

DimensionFilter represents an object containing a list of dimension values and the dimension name

type DownloadItem

type DownloadItem struct {
	HRef    string `json:"href,omitempty"`
	Private string `json:"private,omitempty"`
	Public  string `json:"public,omitempty"`
	Size    string `json:"size,omitempty"`
}

DownloadItem represents an object containing download details

type Downloads

type Downloads struct {
	CSV *DownloadItem `json:"csv,omitempty"`
	XLS *DownloadItem `json:"xls,omitempty"`
}

Downloads represent a list of download types

type Filter

type Filter struct {
	FilterID         string             `json:"filter_id,omitempty"`
	InstanceID       string             `json:"instance_id"`
	DimensionFilters []*DimensionFilter `json:"dimensions,omitempty"`
	Published        *bool              `json:"published,omitempty"`
	Downloads        *Downloads         `json:"downloads,omitempty"`
}

Filter represents a structure for a filter job

func (Filter) IsEmpty

func (f Filter) IsEmpty() bool

IsEmpty return true if DimensionFilters is nil, empty or contains only empty values

type Reader

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

Reader is an io.Reader implementation that wraps a csvRowReader

func NewReader

func NewReader(csvRowReader CSVRowReader) *Reader

NewReader returns a new io.Reader for the given csvRowReader.

func (*Reader) Close

func (reader *Reader) Close() (err error)

Close the reader.

func (*Reader) ObservationsCount

func (reader *Reader) ObservationsCount() int32

ObservationsCount returns the total number of bytes read by this reader.

func (*Reader) Read

func (reader *Reader) Read(p []byte) (n int, err error)

Read bytes from the underlying csvRowReader

func (*Reader) TotalBytesRead

func (reader *Reader) TotalBytesRead() int64

TotalBytesRead returns the total number of bytes read by this reader.

type Store

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

Store represents storage for observation data.

func NewStore

func NewStore(pool DBPool) *Store

NewStore returns a new store instace using the given DB connection.

func (*Store) GetCSVRows

func (store *Store) GetCSVRows(ctx context.Context, filter *Filter, limit *int) (CSVRowReader, error)

GetCSVRows returns a reader allowing individual CSV rows to be read. Rows returned can be limited, to stop this pass in nil. If filter.DimensionFilters is nil, empty or contains only empty values then a CSVRowReader for the entire dataset will be returned.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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