dsref

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: GPL-3.0 Imports: 7 Imported by: 2

Documentation

Overview

Package dsref defines structure and syntax for referring to a dataset

Index

Constants

View Source
const AllGenerations = -1

AllGenerations represents all the generations of a dataset's history

Variables

View Source
var (

	// ErrEmptyRef is an error for when a reference is empty
	ErrEmptyRef = fmt.Errorf("empty reference")
	// ErrParseError is an error returned when parsing fails
	ErrParseError = fmt.Errorf("could not parse ref")
	// ErrNotHumanFriendly is an error returned when a reference is not human-friendly
	ErrNotHumanFriendly = fmt.Errorf("ref can only have username/name")
	// ErrBadCaseName is the error when a bad case is used in the dataset name
	ErrBadCaseName = fmt.Errorf("dataset name may not contain any upper-case letters")
	// ErrBadCaseShouldRename is the error when a dataset should be renamed to not use upper case letters
	ErrBadCaseShouldRename = fmt.Errorf("dataset name should not contain any upper-case letters, rename it to only use lower-case letters, numbers, and underscores")
	// ErrDescribeValidName is an error describing a valid dataset name
	ErrDescribeValidName = fmt.Errorf("dataset name must start with a letter, and only contain letters, numbers, and underscore. Maximum length is 144 characters")
)

Functions

func IsRefString added in v0.9.5

func IsRefString(text string) bool

IsRefString returns whether the string parses as a valid reference

func IsValidName added in v0.9.5

func IsValidName(text string) bool

IsValidName returns whether the dataset name is valid

Types

type Ref

type Ref struct {
	// Username of dataset owner
	Username string `json:"username,omitempty"`
	// ProfileID of dataset owner
	ProfileID string `json:"profileID,omitempty"`
	// Unique name reference for this dataset
	Name string `json:"name,omitempty"`
	// Content-addressed path for this dataset
	Path string `json:"path,omitempty"`
}

Ref is a reference to a dataset

func MustParse added in v0.9.7

func MustParse(text string) Ref

MustParse parses a dsref from a string, or panics if it fails

func Parse added in v0.9.5

func Parse(text string) (Ref, error)

Parse a reference from a string

func ParseHumanFriendly added in v0.9.5

func ParseHumanFriendly(text string) (Ref, error)

ParseHumanFriendly parses a reference that only has a username and a dataset name

func (Ref) Alias

func (r Ref) Alias() (s string)

Alias returns the alias components of a Ref as a string

func (Ref) Equals added in v0.9.5

func (r Ref) Equals(t Ref) bool

Equals returns whether the reference equals another

func (Ref) IsEmpty added in v0.9.5

func (r Ref) IsEmpty() bool

IsEmpty returns whether the reference is empty

func (Ref) String

func (r Ref) String() (s string)

String implements the Stringer interface for Ref

type Rev

type Rev struct {
	// field scopt, currently can only be a component name, or the entire dataset
	Field string
	// the nth-generational ancestor of a history
	Gen int
}

Rev names a field of a dataset at a snapshot relative to the latest version in a history Much of this is inspired by git revisions: https://git-scm.com/docs/gitrevisions

Unlike git, Qri is aware of the underlying data model it's selecting against, so revisions can have conventional names for specifying fields of a dataset

func NewAllRevisions

func NewAllRevisions() Rev

NewAllRevisions returns a Rev struct that represents all revisions.

func ParseRev

func ParseRev(rev string) (*Rev, error)

ParseRev turns a string into a revision

func ParseRevs

func ParseRevs(str string) (revs []*Rev, err error)

ParseRevs turns a comma-separated list of revisions into a slice of revisions

type VersionInfo added in v0.9.5

type VersionInfo struct {
	//
	// Key as a stable identifier
	//
	// InitID is derived from the logbook for the dataset
	InitID string `json:"initID,omitempty"`
	//
	// Fields from dsref.Ref
	//
	// Username of dataset owner
	Username string `json:"username,omitempty"`
	// ProfileID of dataset owner
	ProfileID string `json:"profileID,omitempty"`
	// Unique name reference for this dataset
	Name string `json:"name,omitempty"`
	// Content-addressed path for this dataset
	Path string `json:"path,omitempty"`
	//
	// State about the dataset that can change
	//
	// If true, this dataset has published versions
	Published bool `json:"published,omitempty"`
	// If true, this reference doesn't exist locally. Only makes sense if path is set, as this
	// flag refers to specific versions, not to entire dataset histories.
	Foreign bool `json:"foreign,omitempty"`
	//
	// Meta fields
	//
	// Title from the meta structure
	MetaTitle string `json:"metaTitle,omitempty"`
	// List of themes from the meta structure, comma-separated list
	ThemeList string `json:"themeList,omitempty"`
	//
	// Structure fields
	//
	// Size of the body in bytes
	BodySize int `json:"bodySize,omitempty"`
	// Num of rows in the body
	BodyRows int `json:"bodyRows,omitempty"`
	// Format of the body, such as "csv" or "json"
	BodyFormat string `json:"bodyFromat,omitempty"`
	// Number of errors from the structure
	NumErrors int `json:"numErrors,omitempty"`
	//
	// Commit fields
	//
	// Timestamp field from the commit
	CommitTime time.Time `json:"commitTime,omitempty"`
	//
	// About the dataset's history and location
	//
	// Number of versions that the dataset has
	NumVersions int `json:"numVersions,omitempty"`
	// FSIPath is this dataset's link to the local filesystem if one exists
	FSIPath string `json:"fsiPath,omitempty"`
}

VersionInfo describes a dataset reference and detailed information about it

func ConvertDatasetToVersionInfo deprecated added in v0.9.5

func ConvertDatasetToVersionInfo(ds *dataset.Dataset) VersionInfo

ConvertDatasetToVersionInfo assigns values form a dataset to a VersionInfo This function is a shim while we work on building up dscache as a store of VersionInfo.

Deprecated: Don't use this function for new code. Instead reference a VersionInfo that is stored somewhere, or write a function that builds a VersionInfo without needing a dataset

func (*VersionInfo) Alias added in v0.9.5

func (v *VersionInfo) Alias() string

Alias returns the alias components of a Ref as a string

func (*VersionInfo) SimpleRef added in v0.9.5

func (v *VersionInfo) SimpleRef() Ref

SimpleRef returns a simple dsref.Ref

Jump to

Keyboard shortcuts

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