dataset

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToParseCSVorTSVFile error = errors.New("failed to parse file content")
	ErrIncompatibleSchema        error = errors.New("schema is not compatible with csv")
	ErrDuplicatiedNameFields     error = errors.New("failed to parse, name-duplicated fields")
)
View Source
var (
	ValueTypeUnknown      = ValueType(value.TypeUnknown)
	ValueTypeBool         = ValueType(value.TypeBool)
	ValueTypeNumber       = ValueType(value.TypeNumber)
	ValueTypeString       = ValueType(value.TypeString)
	ValueTypeRef          = ValueType(value.TypeRef)
	ValueTypeURL          = ValueType(value.TypeURL)
	ValueTypeLatLng       = ValueType(value.TypeLatLng)
	ValueTypeLatLngHeight = ValueType(value.TypeLatLngHeight)
	ValueTypeCoordinates  = ValueType(value.TypeCoordinates)
	ValueTypeRect         = ValueType(value.TypeRect)
	TypePolygon           = ValueType(value.TypePolygon)
)
View Source
var ErrInvalidID = id.ErrInvalidID
View Source
var FieldIDFrom = id.DatasetFieldIDFrom
View Source
var FieldIDFromRef = id.DatasetFieldIDFromRef
View Source
var IDFromRef = id.DatasetIDFromRef
View Source
var MustFieldID = id.MustDatasetFieldID
View Source
var MustSceneID = id.MustSceneID
View Source
var MustSchemaID = id.MustDatasetSchemaID
View Source
var NewFieldID = id.NewDatasetFieldID
View Source
var NewFieldIDset = id.NewDatasetFieldIDSet
View Source
var NewIDSet = id.NewDatasetIDSet
View Source
var NewSceneID = id.NewSceneID
View Source
var NewSceneIDset = id.NewSceneIDSet
View Source
var NewSchemaID = id.NewDatasetSchemaID
View Source
var NewSchemaIDset = id.NewDatasetSchemaIDSet
View Source
var SceneIDFrom = id.SceneIDFrom
View Source
var SceneIDFromRef = id.SceneIDFromRef
View Source
var SchemaIDFrom = id.DatasetSchemaIDFrom
View Source
var SchemaIDFromRef = id.DatasetSchemaIDFromRef

Functions

This section is empty.

Types

type Builder

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

func New

func New() *Builder

func (*Builder) Build

func (b *Builder) Build() (*Dataset, error)

func (*Builder) Fields

func (b *Builder) Fields(fields []*Field) *Builder

func (*Builder) ID

func (b *Builder) ID(id ID) *Builder

func (*Builder) MustBuild

func (b *Builder) MustBuild() *Dataset

func (*Builder) NewID

func (b *Builder) NewID() *Builder

func (*Builder) Scene

func (b *Builder) Scene(scene SceneID) *Builder

func (*Builder) Schema

func (b *Builder) Schema(schema SchemaID) *Builder

func (*Builder) Source

func (b *Builder) Source(source string) *Builder

type Coordinates added in v0.3.0

type Coordinates = value.Coordinates

type Dataset

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

func (*Dataset) Field

func (d *Dataset) Field(id FieldID) *Field

func (*Dataset) FieldBySource

func (d *Dataset) FieldBySource(source string) *Field

func (*Dataset) FieldByType

func (d *Dataset) FieldByType(t ValueType) *Field

func (*Dataset) FieldRef

func (d *Dataset) FieldRef(id *FieldID) *Field

func (*Dataset) Fields

func (d *Dataset) Fields() []*Field

func (*Dataset) ID

func (d *Dataset) ID() (i ID)

func (*Dataset) Interface added in v0.3.0

func (d *Dataset) Interface(s *Schema) map[string]interface{}

Interface returns a simple and human-readable representation of the dataset

func (*Dataset) InterfaceWithFieldIDs added in v0.3.0

func (d *Dataset) InterfaceWithFieldIDs() map[string]interface{}

Interface is almost same as Interface, but keys of the map are IDs of fields.

func (*Dataset) NameField

func (d *Dataset) NameField(ds *Schema) *Field

func (*Dataset) Scene

func (d *Dataset) Scene() (i SceneID)

func (*Dataset) Schema

func (d *Dataset) Schema() (i SchemaID)

func (*Dataset) Source

func (d *Dataset) Source() string

type DatasetCSVParser

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

func NewCSVParser

func NewCSVParser(r io.Reader, n string, seperator rune) *DatasetCSVParser

func (*DatasetCSVParser) CheckCompatible

func (p *DatasetCSVParser) CheckCompatible(s *Schema) error

func (*DatasetCSVParser) GuessSchema

func (p *DatasetCSVParser) GuessSchema(sid SceneID) error

func (*DatasetCSVParser) Init

func (p *DatasetCSVParser) Init() error

func (*DatasetCSVParser) ReadAll

func (p *DatasetCSVParser) ReadAll() (*Schema, []*Dataset, error)

type Diff

type Diff struct {
	Added   List
	Removed List
	Others  map[ID]*Dataset
}

type Field

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

func NewField

func NewField(field FieldID, value *Value, source string) *Field

func (*Field) Field

func (d *Field) Field() (i FieldID)

func (*Field) FieldRef

func (d *Field) FieldRef() *FieldID

func (*Field) IsEmpty added in v0.3.0

func (d *Field) IsEmpty() bool

func (*Field) Source

func (d *Field) Source() string

func (*Field) Type

func (d *Field) Type() ValueType

func (*Field) Value

func (d *Field) Value() *Value

type FieldID added in v0.4.0

type FieldID = id.DatasetFieldID

type FieldIDSet added in v0.4.0

type FieldIDSet = id.DatasetFieldIDSet

type GraphIterator

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

GraphIterator is a iterator for graphically exploring a dataset.

func GraphIteratorFrom

func GraphIteratorFrom(root ID, depth int) *GraphIterator

func (*GraphIterator) Next

func (di *GraphIterator) Next(d *Dataset) (ID, bool)

func (*GraphIterator) Result

func (di *GraphIterator) Result() Map

type GraphLoader

type GraphLoader func(context.Context, ID, ...FieldID) (List, *Field, error)

func GraphLoaderFromMap

func GraphLoaderFromMap(m Map) GraphLoader

func GraphLoaderFromMapAndGraph

func GraphLoaderFromMapAndGraph(m Map, g GraphLoader) GraphLoader

type ID added in v0.4.0

type ID = id.DatasetID

type IDSet added in v0.4.0

type IDSet = id.DatasetIDSet

type LatLng

type LatLng = value.LatLng

type LatLngHeight

type LatLngHeight = value.LatLngHeight

type List

type List []*Dataset

func (List) DiffBySource

func (l List) DiffBySource(l2 List) Diff

func (List) FilterByDatasetSchema

func (l List) FilterByDatasetSchema(s SchemaID) List

func (List) FindDataset

func (l List) FindDataset(id ID) *Dataset

func (List) FindDatasetBySource

func (l List) FindDatasetBySource(s string) *Dataset

func (List) First

func (l List) First() *Dataset

func (List) GraphLoader

func (l List) GraphLoader() GraphLoader

func (List) Last

func (l List) Last() *Dataset

func (List) Loader

func (l List) Loader() Loader

func (List) Map

func (l List) Map() Map

func (List) ToDatasetIds

func (l List) ToDatasetIds() []ID

type Loader

type Loader func(context.Context, ...ID) (List, error)

func LoaderFrom

func LoaderFrom(data []*Dataset) Loader

func LoaderFromMap

func LoaderFromMap(data map[ID]*Dataset) Loader

type Map

type Map map[ID]*Dataset

func (Map) Add

func (dm Map) Add(dss ...*Dataset)

func (Map) GraphLoader

func (dm Map) GraphLoader() GraphLoader

func (Map) GraphSearchByFields

func (dm Map) GraphSearchByFields(root ID, fields ...FieldID) (List, *Field)

func (Map) Loader

func (dm Map) Loader() Loader

func (Map) Slice

func (dm Map) Slice() List

type OptionalValue added in v0.3.0

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

func NewOptionalValue added in v0.3.0

func NewOptionalValue(t ValueType, v *Value) *OptionalValue

func OptionalValueFrom added in v0.3.0

func OptionalValueFrom(v *Value) *OptionalValue

func (*OptionalValue) Cast added in v0.3.0

func (ov *OptionalValue) Cast(t ValueType) *OptionalValue

func (*OptionalValue) Clone added in v0.3.0

func (ov *OptionalValue) Clone() *OptionalValue

func (*OptionalValue) SetValue added in v0.3.0

func (ov *OptionalValue) SetValue(v *Value)

func (*OptionalValue) Type added in v0.3.0

func (ov *OptionalValue) Type() ValueType

func (*OptionalValue) TypeAndValue added in v0.3.0

func (ov *OptionalValue) TypeAndValue() (ValueType, *Value)

func (*OptionalValue) Value added in v0.3.0

func (ov *OptionalValue) Value() *Value

type Polygon added in v0.3.0

type Polygon = value.Polygon

type Rect added in v0.3.0

type Rect = value.Rect

type SceneID added in v0.4.0

type SceneID = id.SceneID

type SceneIDSet added in v0.4.0

type SceneIDSet = id.SceneIDSet

type Schema

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

func (*Schema) Dynamic

func (d *Schema) Dynamic() bool

func (*Schema) Field

func (d *Schema) Field(id FieldID) *SchemaField

func (*Schema) FieldBySource

func (d *Schema) FieldBySource(source string) *SchemaField

func (*Schema) FieldByType

func (d *Schema) FieldByType(t ValueType) *SchemaField

func (*Schema) FieldDiffBySource

func (d *Schema) FieldDiffBySource(d2 *Schema) SchemaFieldDiff

func (*Schema) FieldRef

func (d *Schema) FieldRef(id *FieldID) *SchemaField

func (*Schema) Fields

func (d *Schema) Fields() []*SchemaField

func (*Schema) ID

func (d *Schema) ID() (i SchemaID)

func (*Schema) IDRef

func (d *Schema) IDRef() *SchemaID

func (*Schema) Name

func (d *Schema) Name() string

func (*Schema) Rename

func (u *Schema) Rename(name string)

func (*Schema) RepresentativeField

func (d *Schema) RepresentativeField() *SchemaField

func (*Schema) RepresentativeFieldID

func (d *Schema) RepresentativeFieldID() *FieldID

func (*Schema) Scene

func (d *Schema) Scene() (i SceneID)

func (*Schema) Source

func (d *Schema) Source() (s string)

type SchemaBuilder

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

func NewSchema

func NewSchema() *SchemaBuilder

func (*SchemaBuilder) Build

func (b *SchemaBuilder) Build() (*Schema, error)

func (*SchemaBuilder) Dynamic

func (b *SchemaBuilder) Dynamic(dynamic bool) *SchemaBuilder

func (*SchemaBuilder) Fields

func (b *SchemaBuilder) Fields(fields []*SchemaField) *SchemaBuilder

func (*SchemaBuilder) ID

func (*SchemaBuilder) MustBuild

func (b *SchemaBuilder) MustBuild() *Schema

func (*SchemaBuilder) Name

func (b *SchemaBuilder) Name(name string) *SchemaBuilder

func (*SchemaBuilder) NewID

func (b *SchemaBuilder) NewID() *SchemaBuilder

func (*SchemaBuilder) RepresentativeField

func (b *SchemaBuilder) RepresentativeField(representativeField FieldID) *SchemaBuilder

func (*SchemaBuilder) Scene

func (b *SchemaBuilder) Scene(scene SceneID) *SchemaBuilder

func (*SchemaBuilder) Source

func (b *SchemaBuilder) Source(source string) *SchemaBuilder

type SchemaField

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

func (*SchemaField) Clone added in v0.4.0

func (d *SchemaField) Clone() *SchemaField

func (*SchemaField) ID

func (d *SchemaField) ID() (i FieldID)

func (*SchemaField) IDRef

func (d *SchemaField) IDRef() *FieldID

func (*SchemaField) Name

func (d *SchemaField) Name() (n string)

func (*SchemaField) Ref

func (d *SchemaField) Ref() *SchemaID

func (*SchemaField) Source

func (d *SchemaField) Source() (s string)

func (*SchemaField) Type

func (d *SchemaField) Type() (v ValueType)

type SchemaFieldBuilder

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

func NewSchemaField

func NewSchemaField() *SchemaFieldBuilder

func (*SchemaFieldBuilder) Build

func (b *SchemaFieldBuilder) Build() (*SchemaField, error)

func (*SchemaFieldBuilder) ID

func (*SchemaFieldBuilder) MustBuild

func (b *SchemaFieldBuilder) MustBuild() *SchemaField

func (*SchemaFieldBuilder) Name

func (*SchemaFieldBuilder) NewID

func (*SchemaFieldBuilder) Ref

func (*SchemaFieldBuilder) Source

func (b *SchemaFieldBuilder) Source(source string) *SchemaFieldBuilder

func (*SchemaFieldBuilder) Type

func (b *SchemaFieldBuilder) Type(dataType ValueType) *SchemaFieldBuilder

type SchemaFieldDiff

type SchemaFieldDiff struct {
	Added    []*SchemaField
	Removed  []*SchemaField
	Replaced map[FieldID]*SchemaField
}

type SchemaGraphIterator

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

SchemaGraphIterator は、データセットをグラフ探索するためのイテレータです。

func SchemaGraphIteratorFrom

func SchemaGraphIteratorFrom(root SchemaID, depth int) *SchemaGraphIterator

func (*SchemaGraphIterator) Next

func (di *SchemaGraphIterator) Next(d *Schema) (SchemaID, bool)

func (*SchemaGraphIterator) Result

func (di *SchemaGraphIterator) Result() SchemaMap

type SchemaID added in v0.4.0

type SchemaID = id.DatasetSchemaID

type SchemaIDSet added in v0.4.0

type SchemaIDSet = id.DatasetSchemaIDSet

type SchemaList

type SchemaList []*Schema

func (SchemaList) Map

func (dsl SchemaList) Map() SchemaMap

type SchemaMap

type SchemaMap map[SchemaID]*Schema

func (SchemaMap) GraphSearchByFields

func (dsm SchemaMap) GraphSearchByFields(root SchemaID, fields ...FieldID) (SchemaList, *SchemaField)

func (SchemaMap) Slice

func (dsm SchemaMap) Slice() SchemaList

type Value

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

func ValueFromStringOrNumber added in v0.3.0

func ValueFromStringOrNumber(s string) *Value

func (*Value) Cast added in v0.3.0

func (v *Value) Cast(vt ValueType) *Value

func (*Value) Clone

func (v *Value) Clone() *Value

func (*Value) Interface

func (v *Value) Interface() interface{}

func (*Value) IsEmpty added in v0.4.0

func (v *Value) IsEmpty() bool

func (*Value) Some added in v0.4.0

func (v *Value) Some() *OptionalValue

func (*Value) Type

func (v *Value) Type() ValueType

func (*Value) Value

func (v *Value) Value() interface{}

func (*Value) ValueBool

func (v *Value) ValueBool() *bool

func (*Value) ValueCoordinates added in v0.3.0

func (v *Value) ValueCoordinates() *Coordinates

func (*Value) ValueLatLng

func (v *Value) ValueLatLng() *LatLng

func (*Value) ValueLatLngHeight

func (v *Value) ValueLatLngHeight() *LatLngHeight

func (*Value) ValueNumber

func (v *Value) ValueNumber() *float64

func (*Value) ValuePolygon added in v0.3.0

func (v *Value) ValuePolygon() *Polygon

func (*Value) ValueRect added in v0.3.0

func (v *Value) ValueRect() *Rect

func (*Value) ValueRef

func (v *Value) ValueRef() *string

func (*Value) ValueString

func (v *Value) ValueString() *string

func (*Value) ValueURL

func (v *Value) ValueURL() *url.URL

type ValueType

type ValueType value.Type

func (ValueType) Default added in v0.3.0

func (t ValueType) Default() bool

func (ValueType) MustBeValue added in v0.3.0

func (vt ValueType) MustBeValue(i interface{}) *Value

func (ValueType) None added in v0.4.0

func (vt ValueType) None() *OptionalValue

func (ValueType) Valid added in v0.4.0

func (vt ValueType) Valid() bool

func (ValueType) ValueFrom

func (t ValueType) ValueFrom(i interface{}) *Value

Jump to

Keyboard shortcuts

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