nodesproto

package
v2.14.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package nodesproto is a generated protocol buffer package.

It is generated from these files:

nodes.proto

It has these top-level messages:

GraphHeader
Node

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthNodes = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowNodes   = fmt.Errorf("proto: integer overflow")
)
View Source
var (
	MapSize   int
	ArrSize   int
	ValSize   int
	DelimSize int

	KeysCnt     int
	KeysFromCnt int
	DupsCnt     int
)

Functions

func ReadTree

func ReadTree(r io.Reader) (nodes.Node, error)

ReadTree reads a binary graph from r and tries to decode it as a tree. If the graph is cyclic, an error is returned.

func WriteTo

func WriteTo(w io.Writer, n nodes.Node) error

Types

type GraphHeader

type GraphHeader struct {
	// LastID is a last node ID used by ID allocator for this graph. Implementation may reserve some
	// IDs space by setting LastID > max(nodes.ID). If not set, max(nodes.ID) is assumed.
	// Tools that manipulate the graph, but want to preserve IDs of the nodes should allocate IDs
	// starting from LastID+1.
	LastId uint64 `protobuf:"varint,1,opt,name=last_id,json=lastId,proto3" json:"last_id,omitempty"`
	// Root is an optional ID of a global root for this graph. This field is used to preserve
	// compatibility with tools that expect a tree-shaped data.
	// Implementation may also store multiple roots by referencing an Array node, or may store
	// multiple named roots by referencing an Object node.
	// If not set explicitly, implementations that expect a tree should search the graph for
	// unused nodes of type Object or Array and treat them as an array of roots.
	Root uint64 `protobuf:"varint,2,opt,name=root,proto3" json:"root,omitempty"`
	// Metadata is an optional ID for a metadata node for this file. Should reference an Object.
	// If set, implementations that expect a tree should exclude it from the list of roots.
	Metadata uint64 `protobuf:"varint,3,opt,name=metadata,proto3" json:"metadata,omitempty"`
}

GraphHeader is the first message written over the wire before transfering graph nodes.

It should be preceded by the magic number "\x00bgr" (4 bytes) and the version number 0x1 written as a little-endian 4 byte integer. Next, the length of the header message should be written in varint encoding, directly followed by the message itself.

func (*GraphHeader) Descriptor

func (*GraphHeader) Descriptor() ([]byte, []int)

func (*GraphHeader) GetLastId

func (m *GraphHeader) GetLastId() uint64

func (*GraphHeader) GetMetadata

func (m *GraphHeader) GetMetadata() uint64

func (*GraphHeader) GetRoot

func (m *GraphHeader) GetRoot() uint64

func (*GraphHeader) Marshal

func (m *GraphHeader) Marshal() (dAtA []byte, err error)

func (*GraphHeader) MarshalTo

func (m *GraphHeader) MarshalTo(dAtA []byte) (int, error)

func (*GraphHeader) ProtoMessage

func (*GraphHeader) ProtoMessage()

func (*GraphHeader) ProtoSize

func (m *GraphHeader) ProtoSize() (n int)

func (*GraphHeader) Reset

func (m *GraphHeader) Reset()

func (*GraphHeader) String

func (m *GraphHeader) String() string

func (*GraphHeader) Unmarshal

func (m *GraphHeader) Unmarshal(dAtA []byte) error

type Node

type Node struct {
	// ID is a unique file-local ID of the node.
	// To implement global IDs, application should write additional data to the graph
	// or keep a mapping from file-local IDs to global ones.
	Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// Value is a union for primitive value types.
	// These values are always leaf nodes, they should never store any references to other nodes,
	// or other graph-specific information.
	// It is assumed that encoded Value can be copied to a different Graph without any changes.
	//
	// Types that are valid to be assigned to Value:
	//	*Node_String_
	//	*Node_Int
	//	*Node_Uint
	//	*Node_Float
	//	*Node_Bool
	Value isNode_Value `protobuf_oneof:"value"`
	// Keys is an ordered set of Object keys. Coresponding values are stored in Values field.
	Keys []uint64 `protobuf:"varint,7,rep,packed,name=keys" json:"keys,omitempty"`
	// KeysFrom can refer to a node ID previously seen on wire. In this case, Keys from that node
	// are copied to Keys field of current node. Thus, full list of Keys can be omited.
	KeysFrom uint64 `protobuf:"varint,10,opt,name=keys_from,json=keysFrom,proto3" json:"keys_from,omitempty"`
	// Values stores an ordered list of node IDs. Zero ID represents a null node.
	// For Array node this field represent an array itself, and for Object nodes
	// this field is a set of values that coresponds to keys defined by Keys or KeysFrom.
	Values []uint64 `protobuf:"varint,8,rep,packed,name=values" json:"values,omitempty"`
	// IsObject is a helper field to distinguish between empty arrays and empty objects.
	IsObject bool `protobuf:"varint,9,opt,name=is_object,json=isObject,proto3" json:"is_object,omitempty"`
	// ValuesOffs is an offset added to all value IDs. Used for compression.
	ValuesOffs uint64 `protobuf:"varint,11,opt,name=values_offs,json=valuesOffs,proto3" json:"values_offs,omitempty"`
}

Node represents any node that can be stored in the graph.

A list of Node messages follows directly after GraphHeader and each such message should be preceded by its length written in varint encoding. Nodes in the list should always be sorted by ID (ascending). ID of a node can be zero, in this case ID will be assigned automatically as prevNode.ID+1 (starting from 1).

In general there is 3 kinds of nodes: Values, Arrays, Objects. If Value oneof field is set, all other fields are ignored, and node is decoded as a value node (leaf). If any of Keys or KeysFrom fields are set, the node is an Object (set of key-value pairs). Only Keys/KeysFrom and Values fields are considered in this case. In other cases a node is an Array, and only Values field is considered.

func (*Node) Descriptor

func (*Node) Descriptor() ([]byte, []int)

func (*Node) GetBool

func (m *Node) GetBool() bool

func (*Node) GetFloat

func (m *Node) GetFloat() float64

func (*Node) GetId

func (m *Node) GetId() uint64

func (*Node) GetInt

func (m *Node) GetInt() int64

func (*Node) GetIsObject

func (m *Node) GetIsObject() bool

func (*Node) GetKeys

func (m *Node) GetKeys() []uint64

func (*Node) GetKeysFrom

func (m *Node) GetKeysFrom() uint64

func (*Node) GetString_

func (m *Node) GetString_() string

func (*Node) GetUint

func (m *Node) GetUint() uint64

func (*Node) GetValue

func (m *Node) GetValue() isNode_Value

func (*Node) GetValues

func (m *Node) GetValues() []uint64

func (*Node) GetValuesOffs

func (m *Node) GetValuesOffs() uint64

func (*Node) Kind

func (m *Node) Kind() nodes.Kind

func (*Node) Marshal

func (m *Node) Marshal() (dAtA []byte, err error)

func (*Node) MarshalTo

func (m *Node) MarshalTo(dAtA []byte) (int, error)

func (*Node) ProtoMessage

func (*Node) ProtoMessage()

func (*Node) ProtoSize

func (m *Node) ProtoSize() (n int)

func (*Node) Reset

func (m *Node) Reset()

func (*Node) String

func (m *Node) String() string

func (*Node) Unmarshal

func (m *Node) Unmarshal(dAtA []byte) error

func (*Node) XXX_OneofFuncs

func (*Node) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type Node_Bool

type Node_Bool struct {
	Bool bool `protobuf:"varint,6,opt,name=bool,proto3,oneof"`
}

func (*Node_Bool) MarshalTo

func (m *Node_Bool) MarshalTo(dAtA []byte) (int, error)

func (*Node_Bool) ProtoSize

func (m *Node_Bool) ProtoSize() (n int)

type Node_Float

type Node_Float struct {
	Float float64 `protobuf:"fixed64,5,opt,name=float,proto3,oneof"`
}

func (*Node_Float) MarshalTo

func (m *Node_Float) MarshalTo(dAtA []byte) (int, error)

func (*Node_Float) ProtoSize

func (m *Node_Float) ProtoSize() (n int)

type Node_Int

type Node_Int struct {
	Int int64 `protobuf:"varint,3,opt,name=int,proto3,oneof"`
}

func (*Node_Int) MarshalTo

func (m *Node_Int) MarshalTo(dAtA []byte) (int, error)

func (*Node_Int) ProtoSize

func (m *Node_Int) ProtoSize() (n int)

type Node_String_

type Node_String_ struct {
	String_ string `protobuf:"bytes,2,opt,name=string,proto3,oneof"`
}

func (*Node_String_) MarshalTo

func (m *Node_String_) MarshalTo(dAtA []byte) (int, error)

func (*Node_String_) ProtoSize

func (m *Node_String_) ProtoSize() (n int)

type Node_Uint

type Node_Uint struct {
	Uint uint64 `protobuf:"varint,4,opt,name=uint,proto3,oneof"`
}

func (*Node_Uint) MarshalTo

func (m *Node_Uint) MarshalTo(dAtA []byte) (int, error)

func (*Node_Uint) ProtoSize

func (m *Node_Uint) ProtoSize() (n int)

type RawGraph

type RawGraph struct {
	Root  uint64             `json:"root,omitempty"`
	Meta  uint64             `json:"meta,omitempty"`
	Last  uint64             `json:"last,omitempty"`
	Nodes map[uint64]RawNode `json:"nodes"`
}

func ReadRaw

func ReadRaw(r io.Reader) (*RawGraph, error)

ReadRaw reads a graph from a binary stream, returning a flat list of all nodes.

type RawNode

type RawNode struct {
	ID     uint64      `json:"id"`
	Kind   nodes.Kind  `json:"kind"`
	Value  nodes.Value `json:"val,omitempty"`
	Keys   []uint64    `json:"keys,omitempty"`
	Values []uint64    `json:"values,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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