pquads

package
v0.0.0-...-dc6e3ae Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

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

Index

Constants

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

Variables

View Source
var DefaultMaxSize = 1024 * 1024
View Source
var File_quads_proto protoreflect.FileDescriptor

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"`
	// contains filtered or unexported fields
}

func (*Header) Descriptor deprecated

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

Deprecated: Use Header.ProtoReflect.Descriptor instead.

func (*Header) GetFull

func (x *Header) GetFull() bool

func (*Header) GetNotStrict

func (x *Header) GetNotStrict() bool

func (*Header) ProtoMessage

func (*Header) ProtoMessage()

func (*Header) ProtoReflect

func (x *Header) ProtoReflect() protoreflect.Message

func (*Header) Reset

func (x *Header) Reset()

func (*Header) String

func (x *Header) String() string

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,proto3" json:"subject_value,omitempty"`
	PredicateValue *Value `protobuf:"bytes,6,opt,name=predicate_value,json=predicateValue,proto3" json:"predicate_value,omitempty"`
	ObjectValue    *Value `protobuf:"bytes,7,opt,name=object_value,json=objectValue,proto3" json:"object_value,omitempty"`
	LabelValue     *Value `protobuf:"bytes,8,opt,name=label_value,json=labelValue,proto3" json:"label_value,omitempty"`
	// contains filtered or unexported fields
}

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 deprecated

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

Deprecated: Use Quad.ProtoReflect.Descriptor instead.

func (*Quad) GetLabel

func (x *Quad) GetLabel() string

func (*Quad) GetLabelValue

func (x *Quad) GetLabelValue() *Value

func (*Quad) GetObject

func (x *Quad) GetObject() string

func (*Quad) GetObjectValue

func (x *Quad) GetObjectValue() *Value

func (*Quad) GetPredicate

func (x *Quad) GetPredicate() string

func (*Quad) GetPredicateValue

func (x *Quad) GetPredicateValue() *Value

func (*Quad) GetSubject

func (x *Quad) GetSubject() string

func (*Quad) GetSubjectValue

func (x *Quad) GetSubjectValue() *Value

func (*Quad) ProtoMessage

func (*Quad) ProtoMessage()

func (*Quad) ProtoReflect

func (x *Quad) ProtoReflect() protoreflect.Message

func (*Quad) Reset

func (x *Quad) Reset()

func (*Quad) String

func (x *Quad) String() string

func (*Quad) ToNative

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

ToNative converts protobuf Quad to quad.Quad.

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

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,proto3" json:"subject,omitempty"`
	Predicate *StrictQuad_Ref `protobuf:"bytes,2,opt,name=predicate,proto3" json:"predicate,omitempty"`
	Object    *Value          `protobuf:"bytes,3,opt,name=object,proto3" json:"object,omitempty"`
	Label     *StrictQuad_Ref `protobuf:"bytes,4,opt,name=label,proto3" json:"label,omitempty"`
	// contains filtered or unexported fields
}

StrictQuad is a quad as described by RDF spec.

func (*StrictQuad) Descriptor deprecated

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

Deprecated: Use StrictQuad.ProtoReflect.Descriptor instead.

func (*StrictQuad) GetLabel

func (x *StrictQuad) GetLabel() *StrictQuad_Ref

func (*StrictQuad) GetObject

func (x *StrictQuad) GetObject() *Value

func (*StrictQuad) GetPredicate

func (x *StrictQuad) GetPredicate() *StrictQuad_Ref

func (*StrictQuad) GetSubject

func (x *StrictQuad) GetSubject() *StrictQuad_Ref

func (*StrictQuad) ProtoMessage

func (*StrictQuad) ProtoMessage()

func (*StrictQuad) ProtoReflect

func (x *StrictQuad) ProtoReflect() protoreflect.Message

func (*StrictQuad) Reset

func (x *StrictQuad) Reset()

func (*StrictQuad) String

func (x *StrictQuad) String() string

func (*StrictQuad) ToNative

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

ToNative converts protobuf StrictQuad to quad.Quad.

type StrictQuadRaw

type StrictQuadRaw struct {
	Subject   []byte `protobuf:"bytes,1,opt,name=subject,proto3" json:"subject,omitempty"`
	Predicate []byte `protobuf:"bytes,2,opt,name=predicate,proto3" json:"predicate,omitempty"`
	Object    []byte `protobuf:"bytes,3,opt,name=object,proto3" json:"object,omitempty"`
	Label     []byte `protobuf:"bytes,4,opt,name=label,proto3" json:"label,omitempty"`
	// contains filtered or unexported fields
}

StrictQuadRaw is the same as StrictQuad, but doesn't decode underlying values.

func (*StrictQuadRaw) Descriptor deprecated

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

Deprecated: Use StrictQuadRaw.ProtoReflect.Descriptor instead.

func (*StrictQuadRaw) GetLabel

func (x *StrictQuadRaw) GetLabel() []byte

func (*StrictQuadRaw) GetObject

func (x *StrictQuadRaw) GetObject() []byte

func (*StrictQuadRaw) GetPredicate

func (x *StrictQuadRaw) GetPredicate() []byte

func (*StrictQuadRaw) GetSubject

func (x *StrictQuadRaw) GetSubject() []byte

func (*StrictQuadRaw) ProtoMessage

func (*StrictQuadRaw) ProtoMessage()

func (*StrictQuadRaw) ProtoReflect

func (x *StrictQuadRaw) ProtoReflect() protoreflect.Message

func (*StrictQuadRaw) Reset

func (x *StrictQuadRaw) Reset()

func (*StrictQuadRaw) String

func (x *StrictQuadRaw) String() string

type StrictQuad_Ref

type StrictQuad_Ref struct {

	// Types that are assignable to Value:
	//
	//	*StrictQuad_Ref_BnodeLabel
	//	*StrictQuad_Ref_Iri
	Value isStrictQuad_Ref_Value `protobuf_oneof:"value"`
	// contains filtered or unexported fields
}

func (*StrictQuad_Ref) Descriptor deprecated

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

Deprecated: Use StrictQuad_Ref.ProtoReflect.Descriptor instead.

func (*StrictQuad_Ref) GetBnodeLabel

func (x *StrictQuad_Ref) GetBnodeLabel() string

func (*StrictQuad_Ref) GetIri

func (x *StrictQuad_Ref) GetIri() string

func (*StrictQuad_Ref) GetValue

func (m *StrictQuad_Ref) GetValue() isStrictQuad_Ref_Value

func (*StrictQuad_Ref) ProtoMessage

func (*StrictQuad_Ref) ProtoMessage()

func (*StrictQuad_Ref) ProtoReflect

func (x *StrictQuad_Ref) ProtoReflect() protoreflect.Message

func (*StrictQuad_Ref) Reset

func (x *StrictQuad_Ref) Reset()

func (*StrictQuad_Ref) String

func (x *StrictQuad_Ref) String() string

func (*StrictQuad_Ref) ToNative

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

ToNative converts protobuf Value to quad.Value.

type StrictQuad_Ref_BnodeLabel

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

type StrictQuad_Ref_Iri

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

type Value

type Value struct {

	// Types that are assignable 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"`
	// contains filtered or unexported fields
}

func MakeValue

func MakeValue(qv quad.Value) *Value

MakeValue converts quad.Value to its protobuf representation.

func (*Value) Descriptor deprecated

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

Deprecated: Use Value.ProtoReflect.Descriptor instead.

func (*Value) GetBnode

func (x *Value) GetBnode() string

func (*Value) GetBoolean

func (x *Value) GetBoolean() bool

func (*Value) GetFloat

func (x *Value) GetFloat() float64

func (*Value) GetInt

func (x *Value) GetInt() int64

func (*Value) GetIri

func (x *Value) GetIri() string

func (*Value) GetLangStr

func (x *Value) GetLangStr() *Value_LangString

func (*Value) GetRaw

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

func (*Value) GetStr

func (x *Value) GetStr() string

func (*Value) GetTime

func (x *Value) GetTime() *Value_Timestamp

func (*Value) GetTypedStr

func (x *Value) GetTypedStr() *Value_TypedString

func (*Value) GetValue

func (m *Value) GetValue() isValue_Value

func (*Value) ProtoMessage

func (*Value) ProtoMessage()

func (*Value) ProtoReflect

func (x *Value) ProtoReflect() protoreflect.Message

func (*Value) Reset

func (x *Value) Reset()

func (*Value) String

func (x *Value) String() string

func (*Value) ToNative

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

ToNative converts protobuf Value to quad.Value.

type Value_Bnode

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

type Value_Boolean

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

type Value_Float

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

type Value_Int

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

type Value_Iri

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

type Value_LangStr

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

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"`
	// contains filtered or unexported fields
}

func (*Value_LangString) Descriptor deprecated

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

Deprecated: Use Value_LangString.ProtoReflect.Descriptor instead.

func (*Value_LangString) GetLang

func (x *Value_LangString) GetLang() string

func (*Value_LangString) GetValue

func (x *Value_LangString) GetValue() string

func (*Value_LangString) ProtoMessage

func (*Value_LangString) ProtoMessage()

func (*Value_LangString) ProtoReflect

func (x *Value_LangString) ProtoReflect() protoreflect.Message

func (*Value_LangString) Reset

func (x *Value_LangString) Reset()

func (*Value_LangString) String

func (x *Value_LangString) String() string

type Value_Raw

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

type Value_Str

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

type Value_Time

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

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"`
	// contains filtered or unexported fields
}

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

func (*Value_Timestamp) Descriptor deprecated

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

Deprecated: Use Value_Timestamp.ProtoReflect.Descriptor instead.

func (*Value_Timestamp) GetNanos

func (x *Value_Timestamp) GetNanos() int32

func (*Value_Timestamp) GetSeconds

func (x *Value_Timestamp) GetSeconds() int64

func (*Value_Timestamp) ProtoMessage

func (*Value_Timestamp) ProtoMessage()

func (*Value_Timestamp) ProtoReflect

func (x *Value_Timestamp) ProtoReflect() protoreflect.Message

func (*Value_Timestamp) Reset

func (x *Value_Timestamp) Reset()

func (*Value_Timestamp) String

func (x *Value_Timestamp) String() string

type Value_TypedStr

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

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"`
	// contains filtered or unexported fields
}

func (*Value_TypedString) Descriptor deprecated

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

Deprecated: Use Value_TypedString.ProtoReflect.Descriptor instead.

func (*Value_TypedString) GetType

func (x *Value_TypedString) GetType() string

func (*Value_TypedString) GetValue

func (x *Value_TypedString) GetValue() string

func (*Value_TypedString) ProtoMessage

func (*Value_TypedString) ProtoMessage()

func (*Value_TypedString) ProtoReflect

func (x *Value_TypedString) ProtoReflect() protoreflect.Message

func (*Value_TypedString) Reset

func (x *Value_TypedString) Reset()

func (*Value_TypedString) String

func (x *Value_TypedString) String() string

type WireQuad

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

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

func (*WireQuad) Descriptor deprecated

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

Deprecated: Use WireQuad.ProtoReflect.Descriptor instead.

func (*WireQuad) GetLabel

func (x *WireQuad) GetLabel() *Value

func (*WireQuad) GetObject

func (x *WireQuad) GetObject() *Value

func (*WireQuad) GetPredicate

func (x *WireQuad) GetPredicate() *Value

func (*WireQuad) GetSubject

func (x *WireQuad) GetSubject() *Value

func (*WireQuad) ProtoMessage

func (*WireQuad) ProtoMessage()

func (*WireQuad) ProtoReflect

func (x *WireQuad) ProtoReflect() protoreflect.Message

func (*WireQuad) Reset

func (x *WireQuad) Reset()

func (*WireQuad) String

func (x *WireQuad) String() string

func (*WireQuad) ToNative

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

ToNative converts protobuf WireQuad to quad.Quad.

type WireQuadRaw

type WireQuadRaw struct {
	Subject   []byte `protobuf:"bytes,1,opt,name=subject,proto3" json:"subject,omitempty"`
	Predicate []byte `protobuf:"bytes,2,opt,name=predicate,proto3" json:"predicate,omitempty"`
	Object    []byte `protobuf:"bytes,3,opt,name=object,proto3" json:"object,omitempty"`
	Label     []byte `protobuf:"bytes,4,opt,name=label,proto3" json:"label,omitempty"`
	// contains filtered or unexported fields
}

WireQuadRaw is the same as WireQuad, but doesn't decode underlying values.

func (*WireQuadRaw) Descriptor deprecated

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

Deprecated: Use WireQuadRaw.ProtoReflect.Descriptor instead.

func (*WireQuadRaw) GetLabel

func (x *WireQuadRaw) GetLabel() []byte

func (*WireQuadRaw) GetObject

func (x *WireQuadRaw) GetObject() []byte

func (*WireQuadRaw) GetPredicate

func (x *WireQuadRaw) GetPredicate() []byte

func (*WireQuadRaw) GetSubject

func (x *WireQuadRaw) GetSubject() []byte

func (*WireQuadRaw) ProtoMessage

func (*WireQuadRaw) ProtoMessage()

func (*WireQuadRaw) ProtoReflect

func (x *WireQuadRaw) ProtoReflect() protoreflect.Message

func (*WireQuadRaw) Reset

func (x *WireQuadRaw) Reset()

func (*WireQuadRaw) String

func (x *WireQuadRaw) String() string

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

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

func (*Writer) WriteQuad

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

func (*Writer) WriteQuads

func (w *Writer) WriteQuads(buf []quad.Quad) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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