pquads

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package pquads implements Cayley-specific protobuf-based quads format.

Package pquads is a generated protocol buffer package.

It is generated from these files:
	quads.proto

It has these top-level messages:
	Quad
	WireQuad
	StrictQuad
	Value
	Header

Index

Constants

View Source
const ContentType = "application/x-protobuf"

Variables

View Source
var (
	ErrInvalidLengthQuads = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowQuads   = fmt.Errorf("proto: integer overflow")
)
View Source
var DefaultMaxSize = 1024 * 1024

Functions

func MarshalValue

func MarshalValue(v quad.Value) ([]byte, error)

MarshalValue is a helper for serialization of quad.Value.

func UnmarshalValue

func UnmarshalValue(data []byte) (quad.Value, error)

UnmarshalValue is a helper for deserialization of quad.Value.

Types

type Header struct {
	// Full is set if encoder always writes every quad directions instead of
	// skipping duplicated values on each direction (except label) for subsequent quads.
	Full bool `protobuf:"varint,1,opt,name=full,proto3" json:"full,omitempty"`
	// NotStrict is set if encoder emits WireQuad instead of StrictQuad messages.
	NotStrict bool `protobuf:"varint,2,opt,name=not_strict,json=notStrict,proto3" json:"not_strict,omitempty"`
}

func (*Header) Descriptor

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

func (*Header) Marshal

func (m *Header) Marshal() (data []byte, err error)

func (*Header) MarshalTo

func (m *Header) MarshalTo(data []byte) (int, error)

func (*Header) ProtoMessage

func (*Header) ProtoMessage()

func (*Header) ProtoSize

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

func (*Header) Reset

func (m *Header) Reset()

func (*Header) String

func (m *Header) String() string

func (*Header) Unmarshal

func (m *Header) Unmarshal(data []byte) error

type Options

type Options struct {
	// Full can be set to disable quad values compaction.
	//
	// This will increase files size, but skip will work faster by omitting unmarshal entirely.
	Full bool
	// Strict can be set to only marshal quads allowed by RDF spec.
	Strict bool
}

type Quad

type Quad struct {
	Subject        string `protobuf:"bytes,1,opt,name=subject,proto3" json:"subject,omitempty"`
	Predicate      string `protobuf:"bytes,2,opt,name=predicate,proto3" json:"predicate,omitempty"`
	Object         string `protobuf:"bytes,3,opt,name=object,proto3" json:"object,omitempty"`
	Label          string `protobuf:"bytes,4,opt,name=label,proto3" json:"label,omitempty"`
	SubjectValue   *Value `protobuf:"bytes,5,opt,name=subject_value,json=subjectValue" json:"subject_value,omitempty"`
	PredicateValue *Value `protobuf:"bytes,6,opt,name=predicate_value,json=predicateValue" json:"predicate_value,omitempty"`
	ObjectValue    *Value `protobuf:"bytes,7,opt,name=object_value,json=objectValue" json:"object_value,omitempty"`
	LabelValue     *Value `protobuf:"bytes,8,opt,name=label_value,json=labelValue" json:"label_value,omitempty"`
}

Quad is in internal representation of quad used by Cayley.

func MakeQuad

func MakeQuad(q quad.Quad) *Quad

MakeQuad converts quad.Quad to its protobuf representation.

func (*Quad) Descriptor

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

func (*Quad) GetLabelValue

func (m *Quad) GetLabelValue() *Value

func (*Quad) GetObjectValue

func (m *Quad) GetObjectValue() *Value

func (*Quad) GetPredicateValue

func (m *Quad) GetPredicateValue() *Value

func (*Quad) GetSubjectValue

func (m *Quad) GetSubjectValue() *Value

func (*Quad) Marshal

func (m *Quad) Marshal() (data []byte, err error)

func (*Quad) MarshalTo

func (m *Quad) MarshalTo(data []byte) (int, error)

func (*Quad) ProtoMessage

func (*Quad) ProtoMessage()

func (*Quad) ProtoSize

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

func (*Quad) Reset

func (m *Quad) Reset()

func (*Quad) String

func (m *Quad) String() string

func (*Quad) ToNative

func (m *Quad) ToNative() (q quad.Quad)

ToNative converts protobuf Quad to quad.Quad.

func (*Quad) Unmarshal

func (m *Quad) Unmarshal(data []byte) error

func (*Quad) Upgrade

func (m *Quad) Upgrade()

type Reader

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

func NewReader

func NewReader(r io.Reader, maxSize int) *Reader

NewReader creates protobuf quads decoder.

MaxSize argument limits maximal size of the buffer used to read quads.

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) ReadQuad

func (r *Reader) ReadQuad() (quad.Quad, error)

func (*Reader) SetCloser added in v0.7.0

func (r *Reader) SetCloser(c io.Closer)

func (*Reader) SkipQuad

func (r *Reader) SkipQuad() error

type StrictQuad

type StrictQuad struct {
	Subject   *StrictQuad_Ref `protobuf:"bytes,1,opt,name=subject" json:"subject,omitempty"`
	Predicate *StrictQuad_Ref `protobuf:"bytes,2,opt,name=predicate" json:"predicate,omitempty"`
	Object    *Value          `protobuf:"bytes,3,opt,name=object" json:"object,omitempty"`
	Label     *StrictQuad_Ref `protobuf:"bytes,4,opt,name=label" json:"label,omitempty"`
}

StrictQuad is a quad as described by RDF spec.

func (*StrictQuad) Descriptor

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

func (*StrictQuad) GetLabel

func (m *StrictQuad) GetLabel() *StrictQuad_Ref

func (*StrictQuad) GetObject

func (m *StrictQuad) GetObject() *Value

func (*StrictQuad) GetPredicate

func (m *StrictQuad) GetPredicate() *StrictQuad_Ref

func (*StrictQuad) GetSubject

func (m *StrictQuad) GetSubject() *StrictQuad_Ref

func (*StrictQuad) Marshal

func (m *StrictQuad) Marshal() (data []byte, err error)

func (*StrictQuad) MarshalTo

func (m *StrictQuad) MarshalTo(data []byte) (int, error)

func (*StrictQuad) ProtoMessage

func (*StrictQuad) ProtoMessage()

func (*StrictQuad) ProtoSize

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

func (*StrictQuad) Reset

func (m *StrictQuad) Reset()

func (*StrictQuad) String

func (m *StrictQuad) String() string

func (*StrictQuad) ToNative

func (m *StrictQuad) ToNative() (q quad.Quad)

ToNative converts protobuf StrictQuad to quad.Quad.

func (*StrictQuad) Unmarshal

func (m *StrictQuad) Unmarshal(data []byte) error

type StrictQuad_Ref

type StrictQuad_Ref struct {
	// Types that are valid to be assigned to Value:
	//	*StrictQuad_Ref_BnodeLabel
	//	*StrictQuad_Ref_Iri
	Value isStrictQuad_Ref_Value `protobuf_oneof:"value"`
}

func (*StrictQuad_Ref) Descriptor

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

func (*StrictQuad_Ref) GetBnodeLabel

func (m *StrictQuad_Ref) GetBnodeLabel() string

func (*StrictQuad_Ref) GetIri

func (m *StrictQuad_Ref) GetIri() string

func (*StrictQuad_Ref) GetValue

func (m *StrictQuad_Ref) GetValue() isStrictQuad_Ref_Value

func (*StrictQuad_Ref) Marshal

func (m *StrictQuad_Ref) Marshal() (data []byte, err error)

func (*StrictQuad_Ref) MarshalTo

func (m *StrictQuad_Ref) MarshalTo(data []byte) (int, error)

func (*StrictQuad_Ref) ProtoMessage

func (*StrictQuad_Ref) ProtoMessage()

func (*StrictQuad_Ref) ProtoSize

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

func (*StrictQuad_Ref) Reset

func (m *StrictQuad_Ref) Reset()

func (*StrictQuad_Ref) String

func (m *StrictQuad_Ref) String() string

func (*StrictQuad_Ref) ToNative

func (m *StrictQuad_Ref) ToNative() (qv quad.Value)

ToNative converts protobuf Value to quad.Value.

func (*StrictQuad_Ref) Unmarshal

func (m *StrictQuad_Ref) Unmarshal(data []byte) error

func (*StrictQuad_Ref) XXX_OneofFuncs

func (*StrictQuad_Ref) 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 StrictQuad_Ref_BnodeLabel

type StrictQuad_Ref_BnodeLabel struct {
	BnodeLabel string `protobuf:"bytes,2,opt,name=bnode_label,json=bnodeLabel,proto3,oneof"`
}

func (*StrictQuad_Ref_BnodeLabel) MarshalTo

func (m *StrictQuad_Ref_BnodeLabel) MarshalTo(data []byte) (int, error)

func (*StrictQuad_Ref_BnodeLabel) ProtoSize

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

type StrictQuad_Ref_Iri

type StrictQuad_Ref_Iri struct {
	Iri string `protobuf:"bytes,3,opt,name=iri,proto3,oneof"`
}

func (*StrictQuad_Ref_Iri) MarshalTo

func (m *StrictQuad_Ref_Iri) MarshalTo(data []byte) (int, error)

func (*StrictQuad_Ref_Iri) ProtoSize

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

type Value

type Value struct {
	// Types that are valid to be assigned to Value:
	//	*Value_Raw
	//	*Value_Str
	//	*Value_Iri
	//	*Value_Bnode
	//	*Value_TypedStr
	//	*Value_LangStr
	//	*Value_Int
	//	*Value_Float
	//	*Value_Boolean
	//	*Value_Time
	Value isValue_Value `protobuf_oneof:"value"`
}

func MakeValue

func MakeValue(qv quad.Value) *Value

MakeValue converts quad.Value to its protobuf representation.

func (*Value) Descriptor

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

func (*Value) GetBnode

func (m *Value) GetBnode() string

func (*Value) GetBoolean

func (m *Value) GetBoolean() bool

func (*Value) GetFloat

func (m *Value) GetFloat() float64

func (*Value) GetInt

func (m *Value) GetInt() int64

func (*Value) GetIri

func (m *Value) GetIri() string

func (*Value) GetLangStr

func (m *Value) GetLangStr() *Value_LangString

func (*Value) GetRaw

func (m *Value) GetRaw() []byte

func (*Value) GetStr

func (m *Value) GetStr() string

func (*Value) GetTime

func (m *Value) GetTime() *Value_Timestamp

func (*Value) GetTypedStr

func (m *Value) GetTypedStr() *Value_TypedString

func (*Value) GetValue

func (m *Value) GetValue() isValue_Value

func (*Value) Marshal

func (m *Value) Marshal() (data []byte, err error)

func (*Value) MarshalTo

func (m *Value) MarshalTo(data []byte) (int, error)

func (*Value) ProtoMessage

func (*Value) ProtoMessage()

func (*Value) ProtoSize

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

func (*Value) Reset

func (m *Value) Reset()

func (*Value) String

func (m *Value) String() string

func (*Value) ToNative

func (m *Value) ToNative() (qv quad.Value)

ToNative converts protobuf Value to quad.Value.

func (*Value) Unmarshal

func (m *Value) Unmarshal(data []byte) error

func (*Value) XXX_OneofFuncs

func (*Value) 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 Value_Bnode

type Value_Bnode struct {
	Bnode string `protobuf:"bytes,4,opt,name=bnode,proto3,oneof"`
}

func (*Value_Bnode) MarshalTo

func (m *Value_Bnode) MarshalTo(data []byte) (int, error)

func (*Value_Bnode) ProtoSize

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

type Value_Boolean

type Value_Boolean struct {
	Boolean bool `protobuf:"varint,9,opt,name=boolean,proto3,oneof"`
}

func (*Value_Boolean) MarshalTo

func (m *Value_Boolean) MarshalTo(data []byte) (int, error)

func (*Value_Boolean) ProtoSize

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

type Value_Float

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

func (*Value_Float) MarshalTo

func (m *Value_Float) MarshalTo(data []byte) (int, error)

func (*Value_Float) ProtoSize

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

type Value_Int

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

func (*Value_Int) MarshalTo

func (m *Value_Int) MarshalTo(data []byte) (int, error)

func (*Value_Int) ProtoSize

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

type Value_Iri

type Value_Iri struct {
	Iri string `protobuf:"bytes,3,opt,name=iri,proto3,oneof"`
}

func (*Value_Iri) MarshalTo

func (m *Value_Iri) MarshalTo(data []byte) (int, error)

func (*Value_Iri) ProtoSize

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

type Value_LangStr

type Value_LangStr struct {
	LangStr *Value_LangString `protobuf:"bytes,6,opt,name=lang_str,json=langStr,oneof"`
}

func (*Value_LangStr) MarshalTo

func (m *Value_LangStr) MarshalTo(data []byte) (int, error)

func (*Value_LangStr) ProtoSize

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

type Value_LangString

type Value_LangString struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	Lang  string `protobuf:"bytes,2,opt,name=lang,proto3" json:"lang,omitempty"`
}

func (*Value_LangString) Descriptor

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

func (*Value_LangString) Marshal

func (m *Value_LangString) Marshal() (data []byte, err error)

func (*Value_LangString) MarshalTo

func (m *Value_LangString) MarshalTo(data []byte) (int, error)

func (*Value_LangString) ProtoMessage

func (*Value_LangString) ProtoMessage()

func (*Value_LangString) ProtoSize

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

func (*Value_LangString) Reset

func (m *Value_LangString) Reset()

func (*Value_LangString) String

func (m *Value_LangString) String() string

func (*Value_LangString) Unmarshal

func (m *Value_LangString) Unmarshal(data []byte) error

type Value_Raw

type Value_Raw struct {
	Raw []byte `protobuf:"bytes,1,opt,name=raw,proto3,oneof"`
}

func (*Value_Raw) MarshalTo

func (m *Value_Raw) MarshalTo(data []byte) (int, error)

func (*Value_Raw) ProtoSize

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

type Value_Str

type Value_Str struct {
	Str string `protobuf:"bytes,2,opt,name=str,proto3,oneof"`
}

func (*Value_Str) MarshalTo

func (m *Value_Str) MarshalTo(data []byte) (int, error)

func (*Value_Str) ProtoSize

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

type Value_Time

type Value_Time struct {
	Time *Value_Timestamp `protobuf:"bytes,10,opt,name=time,oneof"`
}

func (*Value_Time) MarshalTo

func (m *Value_Time) MarshalTo(data []byte) (int, error)

func (*Value_Time) ProtoSize

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

type Value_Timestamp

type Value_Timestamp struct {
	Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
	Nanos   int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
}

From https://github.com/golang/protobuf/blob/master/ptypes/timestamp/timestamp.proto

func (*Value_Timestamp) Descriptor

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

func (*Value_Timestamp) Marshal

func (m *Value_Timestamp) Marshal() (data []byte, err error)

func (*Value_Timestamp) MarshalTo

func (m *Value_Timestamp) MarshalTo(data []byte) (int, error)

func (*Value_Timestamp) ProtoMessage

func (*Value_Timestamp) ProtoMessage()

func (*Value_Timestamp) ProtoSize

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

func (*Value_Timestamp) Reset

func (m *Value_Timestamp) Reset()

func (*Value_Timestamp) String

func (m *Value_Timestamp) String() string

func (*Value_Timestamp) Unmarshal

func (m *Value_Timestamp) Unmarshal(data []byte) error

type Value_TypedStr

type Value_TypedStr struct {
	TypedStr *Value_TypedString `protobuf:"bytes,5,opt,name=typed_str,json=typedStr,oneof"`
}

func (*Value_TypedStr) MarshalTo

func (m *Value_TypedStr) MarshalTo(data []byte) (int, error)

func (*Value_TypedStr) ProtoSize

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

type Value_TypedString

type Value_TypedString struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	Type  string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
}

func (*Value_TypedString) Descriptor

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

func (*Value_TypedString) Marshal

func (m *Value_TypedString) Marshal() (data []byte, err error)

func (*Value_TypedString) MarshalTo

func (m *Value_TypedString) MarshalTo(data []byte) (int, error)

func (*Value_TypedString) ProtoMessage

func (*Value_TypedString) ProtoMessage()

func (*Value_TypedString) ProtoSize

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

func (*Value_TypedString) Reset

func (m *Value_TypedString) Reset()

func (*Value_TypedString) String

func (m *Value_TypedString) String() string

func (*Value_TypedString) Unmarshal

func (m *Value_TypedString) Unmarshal(data []byte) error

type WireQuad

type WireQuad struct {
	Subject   *Value `protobuf:"bytes,1,opt,name=subject" json:"subject,omitempty"`
	Predicate *Value `protobuf:"bytes,2,opt,name=predicate" json:"predicate,omitempty"`
	Object    *Value `protobuf:"bytes,3,opt,name=object" json:"object,omitempty"`
	Label     *Value `protobuf:"bytes,4,opt,name=label" json:"label,omitempty"`
}

WireQuad is a quad that allows any value for it's directions.

func (*WireQuad) Descriptor

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

func (*WireQuad) GetLabel

func (m *WireQuad) GetLabel() *Value

func (*WireQuad) GetObject

func (m *WireQuad) GetObject() *Value

func (*WireQuad) GetPredicate

func (m *WireQuad) GetPredicate() *Value

func (*WireQuad) GetSubject

func (m *WireQuad) GetSubject() *Value

func (*WireQuad) Marshal

func (m *WireQuad) Marshal() (data []byte, err error)

func (*WireQuad) MarshalTo

func (m *WireQuad) MarshalTo(data []byte) (int, error)

func (*WireQuad) ProtoMessage

func (*WireQuad) ProtoMessage()

func (*WireQuad) ProtoSize

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

func (*WireQuad) Reset

func (m *WireQuad) Reset()

func (*WireQuad) String

func (m *WireQuad) String() string

func (*WireQuad) ToNative

func (m *WireQuad) ToNative() (q quad.Quad)

ToNative converts protobuf WireQuad to quad.Quad.

func (*WireQuad) Unmarshal

func (m *WireQuad) Unmarshal(data []byte) error

type Writer

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

func NewWriter

func NewWriter(w io.Writer, opts *Options) *Writer

NewWriter creates protobuf quads encoder.

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) MaxSize

func (w *Writer) MaxSize() int

MaxSize returns a maximal message size written.

func (*Writer) SetCloser added in v0.7.0

func (w *Writer) SetCloser(c io.Closer)

func (*Writer) WriteQuad

func (w *Writer) WriteQuad(q quad.Quad) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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