Documentation ¶
Overview ¶
Package ypath defined type for working with YPath.
YPath has two forms, simple and rich.
For more information about ypath see https://docs.yandex-team.ru/yt/description/common/ypath
Index ¶
- func SplitTokens(path string) (tokens []string, err error)
- type CompressionCodec
- type ErasureCodec
- type Path
- func (p Path) Attr(name string) Path
- func (p Path) Attrs() Path
- func (p Path) Child(name string) Path
- func (p Path) Children() Path
- func (p Path) JoinChild(names ...string) Path
- func (p Path) ListAfter(n int) Path
- func (p Path) ListBefore(n int) Path
- func (p Path) ListBegin() Path
- func (p Path) ListEnd() Path
- func (p Path) ListIndex(n int) Path
- func (p Path) ListLast() Path
- func (p Path) MarshalText() (text []byte, err error)
- func (p Path) MarshalYSON(w *yson.Writer) error
- func (p Path) Rich() *Rich
- func (p Path) String() string
- func (p Path) SuppressSymlink() Path
- func (p *Path) UnmarshalText(text []byte) error
- func (p Path) YPath() Path
- type Range
- type ReadLimit
- type Rich
- func (r *Rich) AddRange(rr Range) *Rich
- func (r *Rich) Child(name string) *Rich
- func (r *Rich) Copy() *Rich
- func (r Rich) MarshalYSON(w *yson.Writer) error
- func (r *Rich) SetAppend() *Rich
- func (r *Rich) SetColumns(columns []string) *Rich
- func (r *Rich) SetCompression(compression CompressionCodec) *Rich
- func (r *Rich) SetCreate() *Rich
- func (r *Rich) SetErasure(erasure ErasureCodec) *Rich
- func (r *Rich) SetSchema(schema schema.Schema) *Rich
- func (r *Rich) SetSortedBy(keysColumns []string) *Rich
- func (r Rich) YPath() Path
- type YPath
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SplitTokens ¶
Types ¶
type CompressionCodec ¶
type CompressionCodec string
CompressionCodec is compression codec used for storing data.
const ( CompressionNode CompressionCodec = "none" CompressionSnappy CompressionCodec = "snappy" CompressionLZ4 CompressionCodec = "lz4" CompressionLZ4HighCompression CompressionCodec = "lz4_high_compression" CompressionQuickLZ CompressionCodec = "quick_lz" )
func CompressionBZIP2 ¶
func CompressionBZIP2(n int) CompressionCodec
CompressionBZIP2 returns bzip2 compression codec with quality n.
Supports quality between 1 and 9.
func CompressionBrotli ¶
func CompressionBrotli(n int) CompressionCodec
CompressionBrotli returns brotli compression codec with quality n.
Supports quality between 1 and 11.
func CompressionLZMA ¶
func CompressionLZMA(n int) CompressionCodec
CompressionLZMA returns lzma compression codec with quality n.
Supports quality between 0 and 9.
func CompressionZLIB ¶
func CompressionZLIB(n int) CompressionCodec
CompressionZLIB returns zlib compression codec with quality n.
Supports quality between 1 and 9.
func CompressionZSTD ¶
func CompressionZSTD(n int) CompressionCodec
CompressionZSTD returns zstd compression codec with quality n.
Supports quality between 1 and 21.
func (CompressionCodec) MarshalText ¶
func (c CompressionCodec) MarshalText() (text []byte, err error)
MarshalText is implementation of encoding.TextMarshaler.
func (*CompressionCodec) UnmarshalText ¶
func (c *CompressionCodec) UnmarshalText(text []byte) error
UnmarshalText is implementation of encoding.TextUnmarshaler.
type ErasureCodec ¶
type ErasureCodec string
ErasureCodec is erasure codec used for storing data.
const ( ErasureNone ErasureCodec = "none" ErasureReedSolomon ErasureCodec = "reed_solomon_6_3" ErasureLRC ErasureCodec = "lrc_12_2_2" ErasureISALRC ErasureCodec = "isa_lrc_12_2_2" )
func (ErasureCodec) MarshalText ¶
func (c ErasureCodec) MarshalText() (text []byte, err error)
MarshalText is implementation of encoding.TextMarshaler.
func (*ErasureCodec) UnmarshalText ¶
func (c *ErasureCodec) UnmarshalText(text []byte) error
UnmarshalText is implementation of encoding.TextUnmarshaler.
type Path ¶
type Path string
Path is ypath in simple text form.
Create Path by casting from string.
path := ypath.Path("//home/prime")
Edit Path using helper methods.
myHome = ypath.Root.Child("home").Child("prime") myHome = ypath.Root.JoinChild("home", "prime")
For complex manipulations, use Rich.
const Root Path = "/"
Root is path to cypress root.
func PathsUpToRoot ¶
PathsUpToRoot returns list of paths referring to the nodes on the path to the root.
Starting node and root are included.
func Split ¶
Split splits path into parent and a child component.
//home/prime/table -> //home/prime /table #a-b-c-d/@attr -> #a-b-c-d /@attr
If path refers to cypress root or object id, Split sets parent to path and child to an empty string.
Path attributes, column selectors and range selectors are stripped from provided path.
func (Path) Children ¶
Children returns path referencing all children of p.
The only place such path is ever useful is RemoveNode command.
func (Path) JoinChild ¶
JoinChild returns path referencing grandchild of p.
root := ypath.Root myHome := root.JoinChild("home", "prime")
func (Path) ListBefore ¶
ListBefore returns path used for inserting elements into the list.
func (Path) ListBegin ¶
ListBegin returns path used for inserting elements into beginning of the list.
func (Path) ListIndex ¶
ListIndex returns path referencing n-th element of p, given that p references a list.
func (Path) ListLast ¶
ListLast returns path referencing last element of p, given that p references a list.
func (Path) MarshalText ¶
UnmarshalText is implementation of encoding.TextMarshaler interface.
func (Path) MarshalYSON ¶
MarshalYSON is implementation of yson.StreamMarshaler interface.
func (Path) Rich ¶
Rich creates Rich from p.
This function doesn't validate and doesn't normalize p.
func (Path) SuppressSymlink ¶
SuppressSymlink returns path referencing symlink node.
By default, name of symlink references it target.
Typical usage would be:
var linkName ypath.Path linkTarget := linkName.SuppressSymlink().Attr("target_path")
func (*Path) UnmarshalText ¶
UnmarshalText is implementation of encoding.TextUnmarshaler interface.
type Range ¶
type Range struct { Lower *ReadLimit `yson:"lower_limit,omitempty"` Upper *ReadLimit `yson:"upper_limit,omitempty"` Exact *ReadLimit `yson:"exact,omitempty"` }
Range is subset of table rows defined by lower and upper bound.
func StartingFrom ¶
StartingFrom is Range of all rows starting from lower read limit and up to table end.
type ReadLimit ¶
type ReadLimit struct { Key []any `yson:"key,omitempty"` RowIndex *int64 `yson:"row_index,omitempty"` }
ReadLimit is either table key or row index.
type Rich ¶
type Rich struct { Path Path `yson:",value"` Append *bool `yson:"append,attr,omitempty"` SortedBy []string `yson:"sorted_by,attr,omitempty"` Ranges []Range `yson:"ranges,attr,omitempty"` Columns []string `yson:"columns,attr,omitempty"` Schema *schema.Schema `yson:"schema,attr,omitempty"` FileName string `yson:"file_name,attr,omitempty"` Create bool `yson:"create,attr,omitempty"` Teleport bool `yson:"teleport,attr,omitempty"` Foreign bool `yson:"foreign,attr,omitempty"` Compression CompressionCodec `yson:"compression_codec,attr,omitempty"` Erasure ErasureCodec `yson:"erasure_codec,attr,omitempty"` TransactionID any `yson:"transaction_id,attr,omitempty"` RenameColumns map[string]string `yson:"rename_columns,attr,omitempty"` }
Rich is YPath representation suitable for manipulation by code.
Note that unlike Path, all methods of Rich mutate receiver.
p := ypath.NewRich("//home/foo/bar"). AddRange(ypath.Interval(ypath.RowIndex(0), ypath.RowIndex(1000))). SetColumns([]string{"time", "message"})
func NewRich ¶
NewRich creates new Rich.
This function does not normalize Path and does no validation, use Parse if you need to parse attributes from Path.
func (Rich) MarshalYSON ¶
MarshalYSON is implementation yson.StreamMarshaler interface.
func (*Rich) SetColumns ¶
SetColumns updates columns attribute of p.
func (*Rich) SetCompression ¶
func (r *Rich) SetCompression(compression CompressionCodec) *Rich
SetCompression updates compression_codec attribute of p.
func (*Rich) SetErasure ¶
func (r *Rich) SetErasure(erasure ErasureCodec) *Rich
SetErasure updates erasure_codec attribute of p.
func (*Rich) SetSortedBy ¶
SetSortedBy updates sorted_by attribute of p.
type YPath ¶
type YPath interface { // YPath returns path with all attributes stripped. // // If path is malformed, returns original path unmodified. Use Parse() if you need to check path for correctness. YPath() Path yson.StreamMarshaler }
YPath is interface type that is able to hold both Path and Rich.
It is used by api methods that accept both kind of paths.