qri: github.com/qri-io/qri/startf/ds Index | Files

package ds

import "github.com/qri-io/qri/startf/ds"

Package ds exposes the qri dataset document model into starlark

Package ds defines the qri dataset object within starlark

outline: ds
  ds defines the qri dataset object within starlark. it's loaded by default
  in the qri runtime

      a qri dataset. Datasets can be either read-only or read-write. By default datasets are read-write
        set_meta(meta dict)
          set dataset meta component
        get_meta() dict|None
          get dataset meta component
        get_structure() dict|None
          get dataset structure component if one is defined
        set_structure(structure) structure
          set dataset structure component
        get_body() dict|list|None
          get dataset body component if one is defined
        set_body(data dict|list, parse_as? string) body
          set dataset body component. set_body has only one optional argument: 'parse_as', which defaults to the
          empty string. By default qri assumes the data value provided to set_body is an iterable starlark data
          structure (tuple, set, list, dict). When parse_as is set, set_body assumes the provided body value will
          be a string of serialized structured data in the given format. valid parse_as values are "json", "csv",
          "cbor", "xlsx".


Package Files

dataset.go doc.go entry_reader.go entry_writer.go


const ModuleName = "dataset.star"

ModuleName defines the expected name for this Module when used in starlark's load() function, eg: load('dataset.star', 'dataset')

func LoadModule Uses

func LoadModule() (starlark.StringDict, error)

LoadModule loads the base64 module. It is concurrency-safe and idempotent.

func New Uses

func New(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

New creates a new dataset from starlark land

type Dataset Uses

type Dataset struct {
    // contains filtered or unexported fields

Dataset is a qri dataset starlark type

func NewDataset Uses

func NewDataset(ds *dataset.Dataset, check MutateFieldCheck) *Dataset

NewDataset creates a dataset object, intended to be called from go-land to prepare datasets for handing to other functions

func (*Dataset) GetBody Uses

func (d *Dataset) GetBody(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

GetBody returns the body of the dataset we're transforming. The read version is returned until the dataset is modified by set_body, then the write version is returned instead.

func (*Dataset) GetMeta Uses

func (d *Dataset) GetMeta(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

GetMeta gets a dataset meta component

func (*Dataset) GetStructure Uses

func (d *Dataset) GetStructure(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

GetStructure gets a dataset structure component

func (*Dataset) IsBodyModified Uses

func (d *Dataset) IsBodyModified() bool

IsBodyModified returns whether the body has been modified by set_body

func (*Dataset) Methods Uses

func (d *Dataset) Methods() *starlarkstruct.Struct

Methods exposes dataset methods as starlark values

func (*Dataset) SetBody Uses

func (d *Dataset) SetBody(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

SetBody assigns the dataset body. Future calls to GetBody will return this newly mutated body, even if assigned value is the same as what was already there.

func (*Dataset) SetMeta Uses

func (d *Dataset) SetMeta(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

SetMeta sets a dataset meta field

func (*Dataset) SetMutable Uses

func (d *Dataset) SetMutable(ds *dataset.Dataset)

SetMutable assigns an underlying dataset that can be mutated

func (*Dataset) SetStructure Uses

func (d *Dataset) SetStructure(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

SetStructure sets the dataset structure component

type EntryReader Uses

type EntryReader struct {
    // contains filtered or unexported fields

EntryReader implements the dsio.EntryReader interface for starlark.Iterable's

func NewEntryReader Uses

func NewEntryReader(st *dataset.Structure, iter starlark.Iterable) *EntryReader

NewEntryReader creates a new Entry Reader

func (*EntryReader) Close Uses

func (r *EntryReader) Close() error

Close finalizes the reader

func (*EntryReader) ReadEntry Uses

func (r *EntryReader) ReadEntry() (e dsio.Entry, err error)

ReadEntry reads one entry from the reader

func (*EntryReader) Structure Uses

func (r *EntryReader) Structure() *dataset.Structure

Structure gives this reader's structure

type MutateFieldCheck Uses

type MutateFieldCheck func(path ...string) error

MutateFieldCheck is a function to check if a dataset field can be mutated before mutating a field, dataset will call MutateFieldCheck with as specific a path as possible and bail if an error is returned

type StarlarkEntryWriter Uses

type StarlarkEntryWriter struct {
    IsDict bool
    Struct *dataset.Structure
    Object starlark.Value

StarlarkEntryWriter creates a starlark.Value as an EntryWriter

func NewStarlarkEntryWriter Uses

func NewStarlarkEntryWriter(st *dataset.Structure) (*StarlarkEntryWriter, error)

NewStarlarkEntryWriter returns a new StarlarkEntryWriter

func (*StarlarkEntryWriter) Close Uses

func (w *StarlarkEntryWriter) Close() error

Close is a no-op

func (*StarlarkEntryWriter) Structure Uses

func (w *StarlarkEntryWriter) Structure() *dataset.Structure

Structure returns the EntryWriter's dataset structure

func (*StarlarkEntryWriter) Value Uses

func (w *StarlarkEntryWriter) Value() starlark.Value

Value returns the underlying starlark.Value

func (*StarlarkEntryWriter) WriteEntry Uses

func (w *StarlarkEntryWriter) WriteEntry(ent dsio.Entry) error

WriteEntry adds an entry to the underlying starlark.Value

Package ds imports 11 packages (graph) and is imported by 1 packages. Updated 2019-08-31. Refresh now. Tools for package owners.