Documentation ¶
Overview ¶
Package triplestore provides APIs to manage, store and query triples, sources and RDFGraphs
Index ¶
- Constants
- Variables
- func BnodePred(s, p string) *tripleBuilder
- func BnodePredRes(s, p, r string) *triple
- func IsNTFormat(r io.Reader) (bool, io.Reader)
- func ParseBoolean(obj Object) (bool, error)
- func ParseDateTime(obj Object) (time.Time, error)
- func ParseFloat32(obj Object) (float32, error)
- func ParseFloat64(obj Object) (float64, error)
- func ParseInt16(obj Object) (int16, error)
- func ParseInt8(obj Object) (int8, error)
- func ParseInteger(obj Object) (int, error)
- func ParseLiteral(obj Object) (interface{}, error)
- func ParseString(obj Object) (string, error)
- func ParseUint16(obj Object) (uint16, error)
- func ParseUint8(obj Object) (uint8, error)
- func ParseUinteger(obj Object) (uint, error)
- func SubjPred(s, p string) *tripleBuilder
- func SubjPredBnode(s, p, r string) *triple
- func SubjPredLit(s, p string, l interface{}) (*triple, error)
- func SubjPredRes(s, p, r string) *triple
- type Context
- type DecodeResult
- type Decoder
- type Encoder
- type Literal
- type Object
- func BooleanLiteral(bl bool) Object
- func DateTimeLiteral(tm time.Time) Object
- func Float32Literal(i float32) Object
- func Float64Literal(i float64) Object
- func Int16Literal(i int16) Object
- func Int8Literal(i int8) Object
- func IntegerLiteral(i int) Object
- func ObjectLiteral(i interface{}) (Object, error)
- func Resource(s string) Object
- func StringLiteral(s string) Object
- func StringLiteralWithLang(s, l string) Object
- func Uint16Literal(i uint16) Object
- func Uint8Literal(i uint8) Object
- func UintegerLiteral(i uint) Object
- type RDFGraph
- type Source
- type StreamDecoder
- type StreamEncoder
- type Tree
- func (t *Tree) TraverseAncestors(node string, each func(RDFGraph, string, int) error, depths ...int) error
- func (t *Tree) TraverseDFS(node string, each func(RDFGraph, string, int) error, depths ...int) error
- func (t *Tree) TraverseSiblings(node string, siblingCriteriaFunc func(RDFGraph, string) (string, error), ...) error
- type Triple
- type Triples
- type UnsupportedLiteralTypeError
- type XsdType
Constants ¶
const XMLSchemaNamespace = "http://www.w3.org/2001/XMLSchema"
Variables ¶
var ( XsdString = XsdType("xsd:string") XsdBoolean = XsdType("xsd:boolean") XsdDateTime = XsdType("xsd:dateTime") // 64-bit floating point numbers XsdDouble = XsdType("xsd:double") // 32-bit floating point numbers XsdFloat = XsdType("xsd:float") // signed 32 or 64 bit XsdInteger = XsdType("xsd:integer") // signed (8 bit) XsdByte = XsdType("xsd:byte") // signed (16 bit) XsdShort = XsdType("xsd:short") // unsigned 32 or 64 bit XsdUinteger = XsdType("xsd:unsignedInt") // unsigned 8 bit XsdUnsignedByte = XsdType("xsd:unsignedByte") // unsigned 16 bit XsdUnsignedShort = XsdType("xsd:unsignedShort") )
var RDFContext = &Context{ Prefixes: map[string]string{ "xsd": "http://www.w3.org/2001/XMLSchema#", "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs": "http://www.w3.org/2000/01/rdf-schema#", }, }
Functions ¶
func BnodePredRes ¶
func BnodePredRes(s, p, r string) *triple
func IsNTFormat ¶
Loosely detect if a ntriples format contrary to a binary format Used for retro compatibilty when changing file format on existing stores Detecttion work with ntriples format flushed by this library (i.e. no comment, no spaces, ...)
func ParseBoolean ¶
func ParseFloat32 ¶
func ParseFloat64 ¶
func ParseInt16 ¶
func ParseInteger ¶
func ParseLiteral ¶
func ParseString ¶
func ParseUint16 ¶
func ParseUint8 ¶
func ParseUinteger ¶
func SubjPredBnode ¶
func SubjPredBnode(s, p, r string) *triple
func SubjPredLit ¶
func SubjPredRes ¶
func SubjPredRes(s, p, r string) *triple
Types ¶
type Context ¶
func NewContext ¶
func NewContext() *Context
type DecodeResult ¶
type Decoder ¶
func NewAutoDecoder ¶
Use for retro compatibilty when changing file format on existing stores
func NewBinaryDecoder ¶
func NewDatasetDecoder ¶
NewDatasetDecoder - a dataset is a basically a collection of RDFGraph.
func NewLenientNTDecoder ¶
type Object ¶
type Object interface { Literal() (Literal, bool) Resource() (string, bool) Bnode() (string, bool) Equal(Object) bool }
Object is a resource (i.e. IRI), a literal or a blank node.
func BooleanLiteral ¶
func DateTimeLiteral ¶
func Float32Literal ¶
func Float64Literal ¶
func Int16Literal ¶
func Int8Literal ¶
func IntegerLiteral ¶
func ObjectLiteral ¶
func StringLiteral ¶
func StringLiteralWithLang ¶
func Uint16Literal ¶
func Uint8Literal ¶
func UintegerLiteral ¶
type RDFGraph ¶
type RDFGraph interface { Contains(Triple) bool Triples() []Triple Count() int WithSubject(s string) []Triple WithPredicate(p string) []Triple WithObject(o Object) []Triple WithSubjObj(s string, o Object) []Triple WithSubjPred(s, p string) []Triple WithPredObj(p string, o Object) []Triple }
A RDFGraph is an immutable set of triples. It is a snapshot of a source and it is queryable.
type Source ¶
type Source interface { Add(...Triple) Remove(...Triple) Snapshot() RDFGraph CopyTriples() []Triple }
A source is a persistent yet mutable source or container of triples.
type StreamDecoder ¶
type StreamDecoder interface {
StreamDecode(context.Context) <-chan DecodeResult
}
func NewBinaryStreamDecoder ¶
func NewBinaryStreamDecoder(r io.ReadCloser) StreamDecoder
func NewLenientNTStreamDecoder ¶
func NewLenientNTStreamDecoder(r io.Reader) StreamDecoder
type StreamEncoder ¶
func NewBinaryStreamEncoder ¶
func NewBinaryStreamEncoder(w io.Writer) StreamEncoder
func NewLenientNTStreamEncoder ¶
func NewLenientNTStreamEncoder(w io.Writer) StreamEncoder
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
A tree is defined from a RDF Graph when given a specific predicate as an edge and considering triples pointing to RDF resource Object
The tree defined by the graph/predicate should have no cycles and node should have at most one parent
func (*Tree) TraverseAncestors ¶
func (t *Tree) TraverseAncestors(node string, each func(RDFGraph, string, int) error, depths ...int) error
Traverse all ancestors from the given node
type Triple ¶
Triple consists of a subject, a predicate and a object
func TriplesFromStruct ¶
Convert a Struct or ptr to Struct into triples using field tags. For each struct's field a triple is created: - Subject: function first argument - Predicate: tag value - Literal: actual field value according to field's type Unsupported types are ignored
type UnsupportedLiteralTypeError ¶
type UnsupportedLiteralTypeError struct {
// contains filtered or unexported fields
}
func (UnsupportedLiteralTypeError) Error ¶
func (e UnsupportedLiteralTypeError) Error() string