sst

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: None detected not legal advice Imports: 0 Imported by: 0

README

Semantic STEP Technology - SST API

Abstract

SST is based on the W3C Semantic Web standards RDF, RDFS and OWL with Turtle (*.ttl files) as the main exchange respectively representation format. However, unlike other general purpose tools in this field, the goal of SST is not to support all possible usages of these W3C standards. Instead, the focus of SST is to effectively support the integration of industrial product data similar to what is defined in:

  • STEP, the STandard for the Exchange of Product model data, ISO 10303 series;
  • Oil & Gas, the standard for "Integration of life-cycle data for process plants including oil and gas production facilities”, ISO 15926 series.
Specific RDF handling

To achieve these goals, the RDF handling in SST is optimized and constrained as follows:

  • All IRI subjects defined in a NamedGraph are composed of a base IRI for the NamedGraph and a fragment to indicate the subject node within the NamedGraph. This also enforces that the IRI subject is "owned" by the NamedGraph. Note that this "ownership" is not enforced by the RDF standard, but is in fact common usage.
  • SST is extensively using UUIDs (Universally unique identifier) for all kind of application data. Random UUIDs (type 4) usages are to ensure that not two UUID in different places are by accident identical. When the same UUID is used in different places the same concept is meant.
    • Random UUIDs are used for the base IRI of application data in the form of a UUID-URN. This is to also ensure that the data itself does not declare any kind of owner or location to where the data belongs to. Example: urn:uuid:0062e750-abd3-5c7e-adfe-3486fe2fc699
    • Random UUIDs are also used for the fragments of IRI nodes Example: urn:uuid:0062e750-abd3-5c7e-adfe-3486fe2fc699#65787e4e-810f-441a-bf46-71a4fec1491e
    • Namespace name-based UUIDs (type 3 and 5) are used to provide a hash for the content and is used for blank nodes and collections.
  • Blank nodes can also be used for predicates. In the W3C recommendation "RDF 1.1 Concepts and Abstract Syntax" this extended used is documented under "Generalized RDF Triples, Graphs, and Datasets".
  • A NamedGraph can directly be based on other NamedGraphs by using owl:import. A default NamedGraph together with all imported NamedGraph, directly and indirectly, form together a Dataset. A Dataset and its default NamedGraph are identified by the same base IRI.
  • SST stores all RDF data internally in a special binary format that is optimized for processing speed and memory consumption. For this the binary data is normalized with strict ordering in all places. This also enables very fast calculate of differences between similar files.
SST Repositories with revision control, using GIT concepts

SST tracks changes of RDF data in an SST Repository similar to the capabilities of the revision control system GIT. While GIT is using SHA1 for all hash calculation and identification, SST uses SHA256. While GIT can manage any kind of files, an SST Repository manages only binary NamedGraph files. The main concepts of an SST Repository are:

  • NamedGraphRevision which is a particular revision of a binary NamedGraph that is identified by a SHA256
  • DatasetRevision that is a revision of a Dataset, that identifies the default NamedGraph and all imported NamedGraphs (directly and indirectly) as NamedGraphRevisions
  • Commits that identify who, when and why one or several DatasetRevisions have been modified, and what are the parent commits.
  • An SST Repository can either exist
    • on a local computer and be accessed from a local application through the SST API
    • or be hosted on a server computer and be accessed through the SST Protocol from another SST client
    • an application can also access a remote SST Repository through the SST API without the need for a local SST Repository (this capability is not available for GIT).
  • Data can arbitrarily be replicated between SST Repositories without any loss of consistency. This replication might be for all stored data in another repository, or only for some NamedGraphs or some of the history (Commits).
SST Ontologies

SST comes with a set of pre-defined higher level ontologies. These are in hierarchical order:

  • the Fundamental Ontologies are:
    • RDF and RDFS for the basic concepts
    • OWL 2 for the logical layer
    • XSD for the datatypes defined in the XML-Schema
    • SSMETA that contains definitions to direct details to the SST-Core on how to operate
    • SKOS, the Simple Knowledge Organization System Reference
    • SH to represent SHACL data model constraints; no yet implemented
  • the Application Independent Ontologies are on top of the fundamental ontologies:
    • LCI "Live Cycle Integration" that is derived from the ontology defined in ISO/TS 15926-12 to support the concepts defined in the data model of ISO 10303-2
    • Quantities & Units as defined in ISO 80000
    • Country codes as defined in ISO 3166
    • Currency codes as defined in ISO 4217
  • the "STEP Specific Ontologies" are on top of the Application Independent Ontologies:
    • ssrep for all STEP definitions on "representation", based on ISO 10303-43. This includes geometry, topology, presentation/styling, kinematics and others
    • sso for the STEP PDM (Product Data Management) concepts
    • eed for Schematic Diagrams
  • Reference data
    • IEC Common Data Dictionary as defined in IEC 61360 (draft)
    • ... more reference data sources to be added over time
SST Compiler, late & early binding

Like other RDF tools the SST API provides support of arbitrary ontologies by using the URI of the referenced resources that are provided as STRING to the API methods. This is called late binding because only when running an application the API can check if the provided string is valid.

SST provides special support for the above listed SST Ontologies by using the SST Compiler. Primarily the SST Compiler is converting an SST Ontology (provides as ttl file) into corresponding GO code, so that the concepts defined in an ontology are directly accessible as GO elements. This is called early binding; meaning that already at the GO compile time of an SST application basic consistency with the referenced ontology elements can be checked.

Example: In the "RDF Schema vocabulary" the concept http://www.w3.org/2000/01/rdf-schema#label is defined. In a Turtle (ttl) file this is typically abbreviated as rdfs:label. In SST early binding it is sufficient to use the GO code ssrdfs.Label for the same concept.

SST does not rely on any extensice inferencing that is otherwise needed when using OWL. This is achieved by another output of the SST Compiler that is generating efficient data structures to dynamically provide answers about:

  • hierachy of rdfs:subClassOf in combination with rdf:type
  • hierachy of rdsf:subPropertyOf in combination with with owl:inverseOf
API

The SST API is the default API to access and manipulate data in an SST Repository. It is written in the GO programming language (Golang) and also allows importing and exporting from/to other formats such as RDF-Turtle and STEP.

Terms and Definitions

The **Resource Description Framework (RDF 1.1 Concepts and Abstract Syntax) provides essential definitions that are essential for the understanding of SST:

  • RDF Graph:a sets of subject-predicate-object triples
  • Triple: consisting of a subject, predicate and object element that are either IRIs, blank nodes, or datatyped literals
  • IRI: Internationalized Resource Identifier
  • IRIs with Fragment Identifiers, or in short "fragment"
  • literal and literal value
  • blank node
  • RDF datasets, consisting of one default graph and zero or more named graph

SST used in addition the following terms:

  • IBNode that is either an IRI node or a blank node
  • Dataset that is an RDF dataset identified by an IRI and consisting of a default graph that is typically importing other named graph

Overview

SST organises RDF/OWL data in memory as follows:

  • an RDF graph consists of RDF triples

  • RDF triples consists of the three parts subject, predicate and object where subject and predicate are always of type IBNodes while the object might be an IBNode, Literal or Collection.

  • an IBNode is either an IRI node or a blank node.

  • an IBNode

  • the SST triplex structure allows traversing of the RDF triples that makes up an RDF graph in any direction, either starting from the subject, predicate or object if it is an IBNode.

  • an IBNode

  • an IBNode together with all triples with this IBNode as subject are owned by the NamedGraph of which the IBNode is a fragment of. All RDF triples together with the used Literals, Collections and blank nodes are owned by the NamedGraph that also owns the subject

  • IBNodes, Literals and Collections are stored within a NamedGraph that is "owning" these objects. The owning NamedGraph

  • Every NamedGraph is the default RDF Graph for a corresponding Dataset in a one to one relationship. A Dataset and its default NamedGraph are identified by a IRI.

  • A NamedGraph can import other NamedGraph with owl:import. A default NamedGraph together with all imported (directly and indirectly) other NamedGraphs form together a Dataset.

  • An SST Repository stores revisions of Datasets and NamedGraphs together with corresponding Commits by which these Datasets and NamedGraphs have been created.

  • A revision of a Dataset together with the revision of its corresponding default NamedGraph and all imported other NamedGraphs (directly and indirectly) are made available in memory as a Stage. The data in a Stage can be modified and then stored by a commit as new revisions of Datasets and NamedGraphs in the SST Repository that is linked to the Stage.

SST organises RDF/OWL data in an SST Repository as follows:

  • a binary NG-SST file stores a particular revision of a NamedGraph together with all RDF triples Binary NG-SST files are self-contained and include all references to other NamedGraphs. Binary NG-SST files are identified by their SHA256 key.

  • A commit contains:

    • a timestamp when the data was created or changed
    • the identity of the committer and author of the data
    • a comment describing the changes or reasons of the commit
    • the affect Dataset revisions
  • Change history is recorded by commits that are chained with each other by parent Commits. A Commit might have 0, 1 or several parent Commits. If there is no parent Commit, then newly created Datasets are identified. If there is a single parent Commit, then simple modifications of the affected Datasets are identified. If there are several parent Commits, two different cases might happen:

    • the Commits are on different Datasets. .... TBD
    • the Commit represents a Merge actions of two or more revisions. ISSUE? what if adding a new import
  • Creating new Datasets, NamedGraphs, IBNodes, ... can be done in a Stage before the first Commit

Documentation

Overview

Package sst contains the **SST Core API**. The main interfaces for an application to use are Repository, Dataset, Stage, NamedGraph and IBNode

Package stagefs allows to use file system abstraction for Stage writing/reading.

Index

Constants

View Source
const (
	TermKindIBNode = TermKind(iota)
	TermKindLiteral
	TermKindLiteralCollection
	TermKindTermCollection
)

TermKindIBNode, TermKindLiteral, TermKindLiteralCollection and TermKindTermCollection denote respectively Object of either IBNode, Literal, LiteralCollection or TermCollection type. These values are returned from the TermKind() method of all types implementing the Term interface.

View Source
const DefaultBranch = "master"

DefaultBranch specifies the "master" branch as a default branch in SST.

View Source
const VaultDirName = "document_vault"

Variables

View Source
var (
	ErrUnsupportedRepository      = errors.New("unsupported repository")
	ErrUnknownRefType             = errors.New("unknown ref type")
	ErrDatasetRevisionNotFound    = errors.New("dataset revision not found")
	ErrNamedGraphRevisionNotFound = errors.New("named graph revision not found")
	ErrConcurrentModification     = errors.New("concurrent modification")
)
View Source
var (
	ErrNodeTripleNotSet                   = errors.New("node triple not set")
	ErrTriplePredicateNotSet              = errors.New("triple predicate not set")
	ErrTripleObjectNotSet                 = errors.New("triple object not set")
	ErrDuplicateTriplex                   = errors.New("duplicate triplex")
	ErrNodeNotModifiable                  = errors.New("node not modifiable")
	ErrNodeDeletedOrInvalid               = errors.New("node deleted or invalid")
	ErrStatementsNotSupported             = errors.New("statements not supported")
	ErrLiteralDataTypesDiffer             = errors.New("literal data types differ")
	ErrCannotSetCollectionMemberPredicate = errors.New("can not set collection member predicate")
	ErrIndexOutOfRange                    = errors.New("index out of range")
)
View Source
var (
	ErrIRINodeNotFound    = errors.New("iri node not found")
	ErrDuplicatedFragment = errors.New("duplicated fragment")

	ErrStagesAreNotTheSame                 = errors.New("stages are not the same")
	ErrNamedGraphAlreadyImported           = errors.New("namedGraph already imported")
	ErrNamedGraphNotImported               = errors.New("namedGraph is not imported")
	ErrNamedGraphImportCycle               = errors.New("namedGraph import cycle")
	ErrNothingToCommit                     = errors.New("nothing to commit")
	ErrNamedGraphInvalid                   = errors.New("NamedGraph is invalid")
	ErrNamedGraphAlreadyDeleted            = errors.New("NamedGraph is deleted")
	ErrInternNodeNotFound                  = errors.New("intern node not found")
	ErrInternNodesNotAccessible            = errors.New("intern nodes not accessible")
	ErrNamedGraphIsImported                = errors.New("this NamedGraph is imported by others")
	ErrIBNodeInNamedGraphIsUsedElseWhere   = errors.New("this NamedGraph is referenced by others")
	ErrReferencedNamedGraphCanNotBeDeleted = errors.New("referenced NamedGraph can not be deleted")
)
View Source
var (
	ErrGraphNotEmpty               = errors.New("graph not empty")
	ErrIllegalTripleSubject        = errors.New("illegal triple subject")
	ErrUnsupportedLiteral          = errors.New("unsupported literal")
	ErrGenericIRINotAllowed        = errors.New("generic IRI not allowed")
	ErrContentCouldNotBeRecognized = errors.New("content could not be recognized")
	ErrMissingContent              = errors.New("missing content")
	ErrMultipleGraphsNotSupported  = errors.New("multiple graphs not supported")
	ErrStageNotFound               = errors.New("stage not found")
)

These errors represent conditions that may occur during NamedGraph read function invocations.

View Source
var (
	RecoverHandler = readErrorHandler(func(error) error { return nil })
	StrictHandler  = readErrorHandler(func(err error) error { return err })
)

RecoverHandler and StrictHandler provides predefined recover functions. RecoverHandler ignores given parse error and indicates that reading loop should continue. StrictHandler returns given parse error causing reading loop termination.

View Source
var (
	ErrRepoClosed   = errors.New("repo is closed")
	ErrStageExpired = errors.New("stage lease expired (repo closing/closed)")
	ErrRepoNotFound = errors.New("repository not found")
)
View Source
var (
	ErrTerminalRepositoryOptionHasHasWrongPosition = errors.New("terminal repository option has has wrong position")
	ErrTerminalRepositoryOptionMissing             = errors.New("terminal repository option missing")
	ErrUnsupported                                 = errors.New("unsupported")
	ErrRepositoryNotFound                          = errors.New("repository not found")
	ErrDatasetNotFound                             = errors.New("dataset not found")
	ErrDatasetAlreadyExists                        = errors.New("dataset already exists")
	ErrNotAvailable                                = errors.New("not available")
	ErrNotSupported                                = errors.New("not supported")

	ErrRepositoryDoesNotExist   = errors.New("sst repository does not exist")
	ErrNotALocalFlatRepository  = errors.New("not a LocalFlat Repository")
	ErrNotALocalFullRepository  = errors.New("not a LocalFull Repository")
	ErrNotALocalBasicRepository = errors.New("not a LocalBasic Repository")
	ErrUnrecognizedOption       = errors.New("unrecognized option")
	ErrBranchNotFound           = errors.New("branch not found")
	ErrEmptyCommitMessage       = errors.New("empty commit message")
)
View Source
var (
	ErrMisalignedDiff        = errors.New("misaligned diff")
	ErrUnrecognizedDiffEntry = errors.New("unrecognized diff entry")
	ErrMissingBaseFile       = errors.New("missing base file")
)
View Source
var (
	ErrHeaderExpected  = errors.New("header expected")
	ErrEOFExpected     = errors.New("eof expected")
	ErrDuplicatedNodes = errors.New("duplicated nodes")
	ErrNoContent       = errors.New("no content")
)
View Source
var (
	ErrNamedGraphNotFound = errors.New("named graph not found")

	ErrStageDeletedOrInvalid    = errors.New("stage deleted or invalid")
	ErrStageNotLinkToRepository = errors.New("stage does not link to a repository")
	ErrCommitWasNotCreated      = errors.New("commit was not created")
	ErrPreCommitConditionFailed = errors.New("pre-commit condition failed")
)
View Source
var (
	ErrCommitNotFound = errors.New("commit not found")
)
View Source
var (
	ErrDatasetHasBeenDeleted = errors.New("Dataset has been deleted")
)
View Source
var ErrDirectoryExpectedAsBasePath = errors.New("directory expected as base path")
View Source
var ErrElementInformerNotFound = errors.New("element informer not found")
View Source
var ErrGraphIRIsMismatch = errors.New("graph URLs mismatch")
View Source
var ErrIllegalHashLength = errors.New("illegal hash length")

Error that indicates that a byte array has not the correct size for a SHA 256 [HASH] value.

View Source
var ErrInvalidDictionaryStage = errors.New("invalid dictionary stage")
View Source
var (
	ErrIsDir = errors.New("is a directory")
)
View Source
var ErrMissingImports = errors.New("missing import(s)")
View Source
var ErrNotImplemented = errors.New("not implemented")
View Source
var (
	ErrSameRevisions = errors.New("expected different revisions provided")
)
View Source
var ErrWriterClosed = errors.New("writer is closed and cannot write anymore")

ErrWriterClosed is the error returned from write() when the Triple/Quad-Writer is closed

View Source
var GlobalLogger, AtomicLevel = newLogger()

GlobalLogger is an instance of a zap.Logger, which is a structured and high-performance logging library. It is configured with a JSON encoder and writes logs to os.Stdout. The logger includes caller information and stack traces for errors. It is used throughout the application for logging messages AtomicLevel is a zap.AtomicLevel, which allows dynamic control of the logging level at runtime. For example, you can change the logging level (e.g., from info to debug) by AtomicLevel.SetLevel(zap.DebugLevel) without restarting the application. It is tied to the GlobalLogger and provides flexibility in managing log verbosity.

Functions

func ElementPkg

func ElementPkg(t ElementInformer) string

ElementPkg takes an ElementInformer and gets its type info and removes the type name part from the type's string. Then it gives back the package name of the ElementInformer.

func IsKindIBNode

func IsKindIBNode(o interface{ TermKind() TermKind }) bool

IsKindIBNode returns true if given object is of IBNode kind. This is a convenience method equal to

o.TermKind() == sst.TermKindIBNode

func NamespaceToPrefix

func NamespaceToPrefix(iri string) (prefix string, found bool)

NamespaceToPrefix returns prefix by given IRI. This also can be used to determine if the NameGraph is from the dictionary stage or not.

func NewLocalSuperRepository

func NewLocalSuperRepository(rootDir string) (*localSuperRepository, error)

NewLocalSuperRepository creates or opens a local SuperRepository at the specified directory. If the directory does not exist, it will be created with permissions 0755. If a SuperRepository already exists at the location, it will be opened.

The function performs the following:

  • Creates the root directory if it doesn't exist
  • Scans the directory for existing repositories
  • Creates a "default" repository if it doesn't exist

Returns an error if the directory cannot be created or accessed.

func OpenRemoteSuperRepository

func OpenRemoteSuperRepository(
	ctx context.Context,
	URL string,
	tlsOption grpc.DialOption,
) (*remoteSuperRepository, error)

func RegisterDictionary

func RegisterDictionary(vm map[Element]ElementInformer, dictFS embed.FS, np map[string]string)

RegisterDictionary initializes the vocabulary map and namespace-to-prefix map, and registers the dictionary provider.

Parameters:

  • vm: Map where the key is an Element and the value is an ElementInformer.
  • dictFS: Filesystem, that is typically embedded in the SST source code, containing the dictionary Repository as SST files.
  • np: Map where the key is a namespace and the value is its corresponding prefix.

Types

type Boolean

type Boolean bool

Boolean is a wrapper for the build-in bool type that implements the Literal interface.

func (Boolean) DataType

func (Boolean) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the Boolean data type. e.g. Boolean.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#boolean, or in short xsd:boolean question: can we use in go switch statement: case xsd.Boolean

func (Boolean) TermKind

func (Boolean) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type Byte

type Byte int8

xsd:byte

func (Byte) DataType

func (Byte) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the Byte data type. e.g. Byte.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#byte, or in short xsd:byte

func (Byte) TermKind

func (Byte) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type CommitDetails

type CommitDetails struct {
	Commit              Hash
	Author              string
	AuthorDate          time.Time
	Message             string
	ParentCommits       map[IRI][]Hash
	DatasetRevisions    map[IRI]Hash
	NamedGraphRevisions map[IRI]Hash
}

CommitDetails provide detailed information about a commit. This structure is returned by Repository CommitDetails method and Dataset methods CommitDetailsByHash and CommitDetailsByBranch. This structure is only used as returned value; therefore any changes on the values of this structure will not affect SST.

func (*CommitDetails) Dump

func (r *CommitDetails) Dump()

print CommitDetails content into standard out; e.g.

Output of CommitDetails.Dump()
commit Hash: 6r7cqYdrKKJmCNnfKoKCxfVbUjCd7uK8PwxZAQCGXSeN
Author: default@semanticstep.net
Author Date: 2025-01-23 02:00:25 +0000 UTC
Message: First commit of C
No Parents
Datasets:
	Dataset ID:  c1efcf54-3e8e-4cc7-a7d1-82a9f613a363

type Dataset

type Dataset interface {
	// IRI returns the IRI of the default NamedGraph of this [Dataset].
	IRI() IRI

	// Branches returns all available branch Names and corresponding commitHashes.
	// A SST Repository that does not support history returns an empty map.
	// This method can also be used to check if this Dataset is deleted or not.
	// If a Dataset is deleted, all branches are removed and thus an empty map is returned.
	Branches(ctx context.Context) (map[string]Hash, error)

	// LeafCommits returns all leaf commits of this Dataset that are not identified by a branch Name.
	// A SST Repository that does not support history returns an empty slice.
	LeafCommits(ctx context.Context) ([]Hash, error)

	// CommitDetailsByHash provides detail information about a commit identified by
	// commitID in scope of a Dataset. If the commitID is not know for the
	// Dataset an error ErrCommitNotFound is returned.
	CommitDetailsByHash(ctx context.Context, commit Hash) (*CommitDetails, error)

	// CommitDetailsByBranch provides detail information about a commit identified by
	// branch in scope of a Dataset. If the branch is not know for the
	// Dataset an error errBranchNotFound is returned.
	CommitDetailsByBranch(ctx context.Context, branch string) (*CommitDetails, error)

	// SetBranch moves or sets a branch Name to the revision of this Dataset that was created in the specified commit.
	// If this branch Name was set before to another revision of this Dataset, it is removed from that revision.
	SetBranch(ctx context.Context, commit Hash, branch string) error

	// RemoveBranch deletes a dataset branch from the repository.
	RemoveBranch(ctx context.Context, branch string) error

	// Repository returns [Repository] to which the [Dataset] belongs.
	Repository() Repository

	// CheckoutCommit returns a new Stage that is based on the given commit but is not
	// related to any branch optionally using provided options.
	CheckoutCommit(ctx context.Context, commitID Hash, mode TriplexMode) (Stage, error)

	// CheckoutBranch returns a Stage that operates on the receiver Dataset for the commit that is
	// specified by the tip of the given branch and optionally using provided options.
	CheckoutBranch(ctx context.Context, branchName string, mode TriplexMode) (Stage, error)

	// CheckoutRevision returns a new Stage that is based on the given DatasetRevision.
	// This is useful when a DatasetRevision exists that is not associated with a branch name.
	CheckoutRevision(ctx context.Context, datasetRevision Hash, mode TriplexMode) (Stage, error)

	// FindCommonParentRevision searches for a common ancestor of commit revision1 and commit revision2
	// of this Dataset and returns its common parent commit revision Hash.
	// For this, the two revisions must belong to the same Dataset and exist in the the same Repository.
	// Only then, it is possible to compare the two revisions of the same Dataset.
	// This method traverses the commit revision history of both revisions in the Repository
	// by following the commit tree that contain information about the parents.
	// This method returns either revision1 or revision2 or another revision of this Dataset in the same Repository.
	// This method returns Hash of empty string and nil if there is no common parent revision.
	// Note: This method is used for three-way diff and merge.
	FindCommonParentRevision(context context.Context, revision1, revision2 Hash) (parent Hash, err error)
}

Dataset is the representation of an RDF Dataset and all it's revisions within an SST Repository. Like an RDF Dataset an SST Dataset consists of a default NamedGraph and all the other NamedGraphs that are either directly or indirectly imported. Note: For SST also the default graph is a NamedGraph. Note: In OWL2, direct imported NamedGraphs are provided by owl:imports. An example of an indirect import is when NamedGraph A imports NamedGraph B which then imports NamedGraph C. In this case NamedGraph A directly imports NamedGraph B and indirectly imports NamedGraph C. All imports of NamedGraph within a Dataset must form zero, one or several directed acyclic graphs. SST ensures this by checking for cyclic imports during [NamedGraph.AddImport] for the current Stage. Inside the SST API imports are handled by the special methods [NamedGraph.DirectImports], [NamedGraph.AddImport], and [NamedGraph.RemoveImport].

The set of DatasetRevisions of a Dataset form a directed acyclic graph following their parents with either 0 (if new), one (if it is a revision of previous one) or 2 (if merging). This parent information is imbedded in commit structure.

Unique BranchNames within a Dataset can be stored for particular DatasetRevisions. BranchNames are set by SetBranch and removed by RemoveBranch. BranchNames by default are not synchronized between different Datasets.

An SST Dataset can be retrieve from an SST Repository by methods such as [Repository.CreateDataset] or [Repository.OpenDataset]. The latest revision of a Dataset of any branch is loaded into a new Stage by method [Dataset.StageForBranch]. A specific revision of a Dataset is loaded into a new Stage by method [Dataset.StageAtCommit]. All these methods ensure that the default NamedGraphs and other direct and indirect imported NamedGraphs are loaded in the revisions that corresponds to the specified branch or commit.

type Dictionary

type Dictionary interface {
	Stage
	// Vocabulary returns a NamedGraph for the given Vocabulary
	// that belongs to the read-only dictionary stage.
	Vocabulary(v Vocabulary) (NamedGraph, error)
	// Element returns an IBNode for the given VocabularyElement
	// that is located in a NamedGraph that belongs to the
	// read-only dictionary stage.
	Element(e Element) (IBNode, error)
}

The Dictionary interface is an extension of the Stage interface to provides access to the build in ontologies of SST in read-only mode. The single Dictionary object can be accessed by StaticDictionary(). Dictionary provides access to dictionary [NamedGraph]s and [IBNode]s within the dictionary stage. The dictionary stage is distinct from application data stages, is read-only and does not belong to any Repository. It is completely managed by SST internally.

Example:

lenIBNode, _ := StaticDictionary().Element(ssqau.Length)

func StaticDictionary

func StaticDictionary() Dictionary

StaticDictionary returns the read-only dictionary stage.

type DiffTriple

type DiffTriple struct {
	Flag DiffTripleFlag
	Sub  string
	Pred string
	Obj  string
}

func SstWriteDiff

func SstWriteDiff(rFrom, rTo *bufio.Reader, w io.Writer, writeDiffTriple bool) ([]DiffTriple, error)

Returns: A slice of DiffTriple (if writeDiffTriple is true), otherwise nil. An error if the operation fails.

type DiffTripleFlag

type DiffTripleFlag int8

DiffTripleFlag is used in DiffTriple to indicate modifications. The possible values are

-1: Triple is removed, indicated by "-"
 0: Triple is not changed, indicated by "="
+1: Triple is added, indicated by "+"
const (
	TripleAdded   DiffTripleFlag = 1
	TripleEqual   DiffTripleFlag = 0
	TripleRemoved DiffTripleFlag = -1
)

type DocumentInfo

type DocumentInfo struct {
	Hash      Hash      `json:"id"`
	MIMEType  string    `json:"mime_type"`
	Author    string    `json:"author"`
	Timestamp time.Time `json:"timestamp"`
	Size      int64     `json:"size"`
}

Metadata represents metadata information of a stored document.

type Double

type Double float64

Double is a wrapper for the build-in float64 type that implements the Literal interface.

func (Double) DataType

func (Double) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the Double data type. e.g. Double.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#double, or in short xsd:double

func (Double) TermKind

func (Double) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type Element

type Element struct {
	Vocabulary Vocabulary
	Name       string
}

An Element represents an IRI node of a Vocabulary for early binding access. For this purpose the SST Ontology Compiler generates a global variable for each IRI node defined in the selected ontologies. Element implements the Elementer interface. Example: the physical quantity qau:Length as defined in ISO 80000.

func (Element) GoSimpleName

func (e Element) GoSimpleName() string

GoSimpleName provides the name of the corresponding GO variable for that element.

func (Element) IRI

func (e Element) IRI() IRI

ResourceID returns the RDF resource identifier of the element as IRI string.

func (Element) IsTermCollection

func (Element) IsTermCollection() bool

func (Element) TermKind

func (Element) TermKind() TermKind

func (Element) VocabularyElement

func (e Element) VocabularyElement() Element

VocabularyElement implements the corresponding Elementer interface method.

type ElementInfo

type ElementInfo struct {
	Element
	AClass            bool // true if the element is an owl:Class.
	AnOptionClass     bool // true is the element is a ssmeta:OptionClass.
	AnAbstractClass   bool // true if the element is a ssmeta:AbstractClass.
	ARootClass        bool // true if the element is a ssmeta:RootClass.
	AProperty         bool // true if the element is an rdf:Property.
	ADatatypeProperty bool // true if the element is an owl:DatatypeProperty.
	AnObjectProperty  bool // true if the element is an owl:ObjectProperty.
	ADatatype         bool // true if the element is an rdfs:Datatype.
	AnIndividual      bool // true if the property is neither a class nor a property nor a datatype.

	// AMainClassSupersedure provides the main classes this element supersedes.
	// AMainClassSupersedure is set to empty map[Element]struct{} in case the
	// element denotes a main class but does not supersedes any other element.
	// AMainClassSupersedure is set to nil if this element is not a main class.
	AMainClassSupersedure map[Element]struct{}

	ADomain               ElementInformer   // The rdfs:domain of a property.
	ARange                ElementInformer   // The rdfs:range of a property.
	ACollectionMemberType ElementInformer   // represent collection member type
	ASubtypeOf            []ElementInformer // Superclasses from zero or more rdfs:subClassOf statements.

	ASubPropertyOf ElementInformer // Super-property from rdfs:subPropertyOf statement or nil.
	AnInverseOf    ElementInformer // The owl:inverseOf of a property if available.
}

A ElementInfo provides additional ontological information for an Element. The fields of ElementInfo are not intended to be directly accessed by an application; instead the methods for Element and ElementInformer are to be used. ElementInfo and it's extensions are only generated for selected externally defined ontologies that are not only treated as reference data but that contain upper level ontologies. For such ontologies, the SST Ontology compiler generates global variables of types that embeds ElementInfo structures but with no additional fields so that compile time checks become available. For these extended ElementInfo structures the SST Ontology compiler also generates additional methods that implement the ElementInformer interface.

func (ElementInfo) CollectionMember

func (i ElementInfo) CollectionMember() ElementInformer

func (ElementInfo) Domain

func (i ElementInfo) Domain() ElementInformer

Domain implements the corresponding ElementInformer interface method.

func (ElementInfo) InverseOf

func (i ElementInfo) InverseOf() ElementInformer

InverseOf implements the corresponding ElementInformer interface method.

func (ElementInfo) IsClass

func (i ElementInfo) IsClass() bool

IsClass implements the corresponding ElementInformer interface method.

func (ElementInfo) IsDatatype

func (i ElementInfo) IsDatatype() bool

IsDatatype implements the corresponding ElementInformer interface method.

func (ElementInfo) IsDatatypeProperty

func (i ElementInfo) IsDatatypeProperty() bool

IsDatatypeProperty implements the corresponding ElementInformer interface method.

func (ElementInfo) IsIndividual

func (i ElementInfo) IsIndividual() bool

IsIndividual implements the corresponding ElementInformer interface method.

func (ElementInfo) IsMainClass

func (i ElementInfo) IsMainClass(prevMainClass Element) bool

IsMainClass implements the corresponding ElementInformer interface method.

func (ElementInfo) IsObjectProperty

func (i ElementInfo) IsObjectProperty() bool

IsObjectProperty implements the corresponding ElementInformer interface method.

func (ElementInfo) IsProperty

func (i ElementInfo) IsProperty() bool

IsProperty implements the corresponding ElementInformer interface method.

func (ElementInfo) Range

func (i ElementInfo) Range() ElementInformer

Range implements the corresponding ElementInformer interface method.

func (ElementInfo) SubPropertyOf

func (i ElementInfo) SubPropertyOf() ElementInformer

SubPropertyOf implements the corresponding ElementInformer interface method.

func (ElementInfo) SubtypeOf

func (i ElementInfo) SubtypeOf() []ElementInformer

SubtypeOf implements the corresponding ElementInformer interface method.

type ElementInformer

type ElementInformer interface {
	Node
	Elementer
	IsClass() bool            // true if the element is an owl:Class
	IsProperty() bool         // true if the element is an rdf:Property or owl:DatatypeProperty or owl:ObjectProperty.
	IsDatatypeProperty() bool // true if the element is an owl:DatatypeProperty.
	IsObjectProperty() bool   // true if the element is an owl:ObjectProperty.
	IsDatatype() bool         // true if the element is an rdfs:Datatype.
	IsIndividual() bool       // true if the target is neither a class nor a property nor a datatype.

	// IsMainClass returns true if the target is directly or indirectly of the mainClass type.
	IsMainClass(mainClass Element) bool
	// Domain returns the rdfs:domain of a property.
	Domain() ElementInformer
	// Range returns the rdfs:range of a property.
	Range() ElementInformer
	// SubtypeOf returns superclasses from zero or more rdfs:subClassOf statements.
	SubtypeOf() []ElementInformer
	// SubPropertyOf returns super-property from rdfs:subPropertyOf statement or nil.
	SubPropertyOf() ElementInformer
	// InverseOf returns the owl:inverseOf of a property if available.
	InverseOf() ElementInformer
	// CollectionMember() returns the collection member type.
	CollectionMember() ElementInformer
}

The ElementInformer defines the methods that are available for IRI node specific extensions of VocabularyElement. This interface embeds the Elementer and Node interfaces.

type Elementer

type Elementer interface {
	VocabularyElement() Element
}

type Float

type Float float32

Float is a wrapper for the build-in float32 type that implements the Literal interface.

func (Float) DataType

func (Float) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the Float data type. e.g. Float.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#float, or in short xsd:float

func (Float) TermKind

func (Float) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type ForEachNode

type ForEachNode func(d IBNode) error

ForEachNode is a callback function that is invoked from IBNode iterating functions. Returning non nil error from this function indicates that iteration loop should be terminated. This type is used by NamedGraph method `NamedGraph.ForAllIBNodes` .

type Hash

type Hash [sha256.Size]byte

Hash is an 32 byte object containing a SHA 256 hash value. Hash is used throughout SST-Core to identify NamedGraph revisions, dataset revisions and commits. SST applications might use this functionality as well for other purposes.

func BytesToHash

func BytesToHash[K ~[]byte | ~string](hashBytes K) (hash Hash)

BytesToHash converts a byte array into a corresponding Hash object.

func HashNil

func HashNil() Hash

HashNil returns the emptyHash value. The emptyHash value is the SHA-256 hash of an empty string.

func StringToHash

func StringToHash(str string) (h Hash, _ error)

StringToHash converts a string that contains 44 character long string in Base58 encoding into a SHA 256 value into a corresponding Hash object.

func (Hash) IsNil

func (h Hash) IsNil() bool

IsNil returns true if the Hash is the emptyHash value. The emptyHash value is the SHA-256 hash of an empty string.

func (Hash) String

func (h Hash) String() string

String returns the Base58 encoded string representation of the Hash. It uses the BTCAlphabet for encoding. If the encoded string is shorter than maxBase58StringLen, it pads the string with pre-defined padding characters to reach the required length.

type IBNode

type IBNode interface {
	Node
	// TypeOf returns the IBNode that represents the main type this IBNode is an rdf:type of.
	// An IBNode might be a type of several classes.
	// The main class is indicated in the SST Vocabularies by rdf:type ssmeta:MainClass.
	// Applications should ensure that only one main class is used for an IBNode.
	TypeOf() IBNode

	// IRI() returns the IRI (Internationalized Resource Identifier) of the IBNode.
	// If the IBNode is of type IRI Node, it will return its IRI.
	// If the IBNode is of type blank Node, it will panic.
	IRI() IRI

	// Fragment returns the fragment part of the RDF resource identifier of the IBNode.
	// if the IBNode is of type IRI Node, it will return its fragment.
	// if the IBNode is of type blank Node, it will panic.
	Fragment() string

	// ID returns the UUID of the ibNode. It checks the type of the ibNode
	// and retrieves the UUID accordingly.
	// If the ibNode is of type blank Node, it returns the fragment UUID if it is not nil.
	// If the ibNode is of type IRI Node, it will panic.
	ID() uuid.UUID

	// PrefixedFragment returns the IRI of the IBNode in shorthand notation as
	// it is used in Turtle syntax (https://www.w3.org/TR/turtle/).
	// It is legal to invoke this method for the zero valued IBNode as well.
	// In such case the predefined string "(nil)" is returned.
	//
	// Example:
	//
	// fmt.Print(ib.PrefixedFragment()) // prints "sso:Part"
	PrefixedFragment() string

	// TripleCount returns the number of triples this IBNode is used as either subject, predicate or object.
	// This TripleCount may used in combination with GetTriple method.
	TripleCount() int

	// OwningGraph returns the owning NamedGraph of the IBNode.
	OwningGraph() NamedGraph

	// ForAll iterates over all triples (subject, predicate or object triplex) of this IBNode.
	//
	// The triples of the owning graph that have receiver node as its subject are called forward triples.
	// The triples of the owning graph that have receiver node as its object are called inverse triples.
	// The triples of the owning graph that have receiver node as its predicate are called middle triples.
	// The triples of the owning graph that have receiver node both as its subject and object are called
	// self referenced triple.
	//
	// For each forward triple the given callback function c is invoked with s set to the receiver node and
	// p, o set to the triple's predicate and object accordingly.
	// For each inverse triple the given callback function c is invoked with s, p set to triple's subject
	// and object accordingly and o set to the receiver node.
	// For the self referenced triple the given callback function invoked with s and o set to
	// receiver node and p to the triple's predicate.
	// When the callback function returns an error, the ForAll loop is ended immediately and this error is returned.
	ForAll(c func(a int, subject IBNode, predicate IBNode, object Term) error) error

	// GetObjects returns all Objects for the given Subject(IBNode) with specified Node.
	// later on: support also subProperty of predicate
	// return values: a slice of objects which length may be 0 or 1 or more
	GetObjects(predicate Node) []Term

	// GetTriple returns particular triple that identified by index related to the IBNode.
	// The triple is returned as subject(s), predicate(p), and object(o).
	// The IBNode is used either as subject, predicate, or object.
	// The number of triples that are associated to an IBNode is available by TripleCount().
	// The order of triples is managed internally by SST and can not be influenced by the API.
	// The possible error codes are: ErrIndexOutOfRange, ErrNodeDeletedOrInvalid
	GetTriple(index int) (IBNode, IBNode, Term)

	// AddStatement() method adds a triple to the target IBNode that is used as subject with p for the predicate and o for the object.
	// User has to ensure that the triple to be added does not already exist; otherwise this method will panic.
	AddStatement(predicate Node, object Term)

	// AddStatementAlt() method adds a triple to the target IBNode that is used as subject with p for the predicate and o for the object.
	// This method is an alternative to AddStatement() with the difference that it is tolerant in case that the triple to be added already exist.
	// An error will be returned if the triple to be added already exist.
	AddStatementAlt(predicate Node, object Term) error

	// CheckTriple() checks is a triple with the given subject, predicate and object exist and returns TRUE in this case; otherwise FALSE is returned.
	CheckTriple(predicate Node, object Term) bool

	// Delete deletes the target IBNode and all triples
	// where the target is used as either subject, predicate or object.
	// After deletion this IBNode is no longer valid and IBNode.IsValid() will return false.
	Delete()

	// ForDelete iterates over all forward triples of this IBNode and invokes the fallback function c
	// for each triple with it's subject, predicate and object.
	// If the invoked callback function c returns true for one or several triples, then these triples are removed.
	ForDelete(c func(int, IBNode, IBNode, Term) bool)

	// DeleteTriples deletes all subject triples of this IBNode
	DeleteTriples()

	// InVocabulary returns a corresponding ElementInformer for the IBNode.
	// It is legal to invoke this method for the zero valued IBNode as well.
	// This method is in most cases invoked for IBNodes from ReferencedGraphs.
	//
	// This method often used to determine the actual ElementInformer interface
	// which can be done by using "Type Switch" or "Type Assertion" from the Golang specification.
	//
	// Example of using Type Switch:
	//
	//	var d sst.IBNode
	//	switch d.TypeOf().InVocabulary().(type) {
	//	case sso.KindPart:
	//		// d is sso:Part or any of its subtypes
	//		// ...
	//	}
	//
	// Example of using Type Assertion:
	//
	//	 if _, ok := p.InVocabulary().(lci.KindHasArrangedPart); ok {
	//		    // do something
	//
	//     }
	InVocabulary() ElementInformer

	// Is checks if the IBNode is the same as a given vocabulary element.
	// It is legal to invoke this method for the zero valued IBNode as well.
	// It is legal to invoke this method for the nil valued IBNode as well.
	// This method is in most cases invoked for IBNodes from ReferencedGraphs.
	// This method is in most cases invoked for IBNodes from ReferencedGraphs
	// for which a corresponding dictionary or vocabulary included in the SST ontologies.
	Is(e Elementer) bool

	// IsKind checks if the IBNode is of given vocabulary element type.
	IsKind(e ElementInformer) bool

	// IsValid return true if the IBNode represents a non-zero value of the IBNode type
	// that belongs to a valid NamedGraph.
	IsValid() bool

	// IsUuidFragment checks on whether the ibNode has a uuid fragment.
	// If it has, true is returned. Otherwise, false is returned.
	IsUuidFragment() bool

	// IsReferenced returns whether the NamedGraph of this IBNode is Referenced,
	// and as a consequences, it does not contain any subject triples.
	// It is not possible to modify an IBNode that is in a referenced state.
	IsReferenced() bool

	// IsIRINode returns true if the IBNode is an IRI node.
	IsIRINode() bool

	// IsBlankNode returns true if the IBNode is a blank node.
	IsBlankNode() bool

	// AsCollection() checks if an IBNode is in fact a TermCollections and returns it if successful.
	AsCollection() (TermCollection, bool)

	// DumpTriples returns a slice of all subject triples of this IBNode
	// consisting of [3]string for the subject, predicate and object of the triple.
	// All IRIs are given with the default or automatically assigned prefixes, similar to standard Turtle format.
	DumpTriples() [][3]string

	// Equal compares this IBNode with another IBNode in another NamedGraph and another Stage.
	// Equal compares the IRI of IRI Nodes and all subject triples of all IRI and BlankNodes.
	// Returns true if the two IBNodes are considered equal, false otherwise.
	// Note: In the case that the predicate or object of a triple exists in another NamedGraph, these must be IRI Nodes not BlankNodes;
	//       Equal only compares the IRIs of such IRI Nodes.
	// Typical use case:
	//   Use this method to determine if two IBNode instances represent the same logical node in the graph,
	//   regardless of their memory address or instantiation.
	// TBD: blankNode comparison
	Equal(ib IBNode) bool

	// implements sort.Interface method.
	// Len() returns the number of triples of this IBNode.
	Len() int
	// Less() compares the order of two triples of this IBNode.
	Less(i int, j int) bool
	// Swap() changes the position of two triples of this IBNode.
	Swap(i int, j int)
	// contains filtered or unexported methods
}

An IBNode represents either an IRI node or a blank node within an RDF graph. An IBNode provides access to the RDF triples associated to it either as subject, predicate or object. An IBNode should contain at least one subject triple, otherwise it cannot be written out into a rdf file. Every IBNode is owned by a NamedGraph with the same base URI.

type IRI

type IRI string

IRI is a specialization of IRI for the purpose of SST Vocabularies.

func NewIRI

func NewIRI(s string) (IRI, error)

NewIRI returns a new IRI, or an error if it's not valid.

A valid IRI cannot be empty, or contain any of the disallowed characters: [\x00-\x20<>"{}|^`\].

func (IRI) IRI

func (i IRI) IRI() IRI

func (IRI) IsTermCollection

func (IRI) IsTermCollection() bool

func (IRI) Split

func (u IRI) Split() (base, fragment string)

Split splits the IRI into a base and fragment based on the last occurrence of the '#' character. If the '#' character is not found, the entire IRI is returned as the base, and the fragment is empty. If the '#' character is found, the base is the part before the '#', and the fragment is the part after the '#'.

func (IRI) String

func (u IRI) String() string

String returns the IRI string.

func (IRI) TermKind

func (IRI) TermKind() TermKind

func (IRI) VocabularyElement

func (i IRI) VocabularyElement() Element

VocabularyElement implements the corresponding Elementer interface method.

type Int

type Int int32

xsd:int

func (Int) DataType

func (Int) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the Int data type. e.g. Int.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#int, or in short xsd:int

func (Int) TermKind

func (Int) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type Integer

type Integer int64

Integer is a wrapper for the build-in int64 type that implements the Literal interface.

func (Integer) DataType

func (Integer) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the Integer data type. e.g. Integer.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#integer, or in short xsd:integer

func (Integer) TermKind

func (Integer) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type LangString

type LangString struct {
	Val     string
	LangTag string
}

LangString is a struct for rdf:langString that implements the Literal interface.

func LangStringOf

func LangStringOf(val, langTag string) LangString

LangStringOf constructs LangString from given value and language.

func (LangString) DataType

func (LangString) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the LangString data type. e.g. LangString.DataType().IRI() will return http://www.w3.org/1999/02/22-rdf-syntax-ns#langString, or in short rdf:langString

func (LangString) TermKind

func (LangString) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type Literal

type Literal interface {
	Term

	// DataType returns the DataType of this Literal as an IBNode.
	DataType() IBNode
	// contains filtered or unexported methods
}

Literal is an Term that represents a literal value. The Literal provides method DataType that returns it's type as an IBNode and method Value that returns it's of unspecified type.

There exists specialized interfaces for optimized access of literal value. These are:

  • type [StringLiteral] for xsd:string
  • type [LangStringLiteral] for rdf:langString
  • type [DoubleLiteral] for xsd:double
  • type [IntegerLiteral] for xsd:integer
  • type [BooleanLiteral] for xsd:boolean

Applications should never expect concrete type as literal value but use this interface of it's specialization interfaces to access literal value or data type.

type LiteralCollection

type LiteralCollection interface {
	// TermKind() returns TermKindLiteralCollection
	Term

	// ForMembers invokes callback function e for each member in the collection.
	ForMembers(e func(int, Literal))

	// MemberCount returns the number of members in this ObjectionCollection.
	MemberCount() int

	// Member returns the member as the indicated position starting with 0 for the first position.
	// It will panic if the index is negative or if it is equal or greater than MemberCount().
	Member(index int) Literal

	// Values returns a slice of interface{} containing the values of the LiteralCollection.
	Values() []interface{}

	// DataType returns the DataType of this LiteralCollection as an IBNode.
	DataType() IBNode
}

LiteralCollection represents a restricted and memory optimized RDF Collection whose members are all [Literal]s of the same DataType. A LiteralCollection is implementing the Term interface and can therefor be used as object e.g. for AddStatement. A LiteralCollection is created by NewLiteralCollection.

LiteralCollection is only used as function/method parameter, it is not linked with the internal memory structure. So there is no need to delete it when no longer needed.

func NewLiteralCollection

func NewLiteralCollection(member0 Literal, members1N ...Literal) LiteralCollection

NewLiteralCollection creates a collection where all members are Literals of the same DataType. Providing members of different DataTypes will result in panic.

type Long

type Long int64

xsd:long

func (Long) DataType

func (Long) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the Long data type. e.g. Long.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#long, or in short xsd:long

func (Long) TermKind

func (Long) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type MergeAction

type MergeAction struct {
	Type        MergeActionType `json:"type"`
	GraphID     string          `json:"graph_id,omitempty"`
	BaseIRI     string          `json:"base_iri,omitempty"`
	Description string          `json:"description,omitempty"`
	Result      string          `json:"result,omitempty"` // success / skipped / failed
	Timestamp   time.Time       `json:"timestamp"`
}

MergeAction records a single operation performed during MoveAndMerge, including its type, target graph, description, result, timestamp, and optional metadata.

type MergeActionType

type MergeActionType string

MergeActionType defines the type of action performed during the MoveAndMerge process. Typical values include merging graphs, redirecting graphs, changing graph types, marking as modified, updating triples, skipping, or other custom actions.

const (
	ActionMergeGraph       MergeActionType = "merge_graph"
	ActionRedirectGraph    MergeActionType = "redirect_graph"
	ActionChangeToLocal    MergeActionType = "change_to_local"
	ActionMarkModified     MergeActionType = "mark_modified"
	ActionUpdateTriples    MergeActionType = "update_triples"
	ActionSkipSameRevision MergeActionType = "skip_same_revision"
	ActionThreeWayMerge    MergeActionType = "three_way_merge"
	ActionOther            MergeActionType = "other"
)

type MoveAndMergeReport

type MoveAndMergeReport struct {
	Actions      []MergeAction  `json:"actions"`
	BetweenRepos bool           `json:"between_repos"`
	StageFrom    string         `json:"stage_from,omitempty"`
	StageTo      string         `json:"stage_to,omitempty"`
	StartTime    time.Time      `json:"start_time"`
	EndTime      time.Time      `json:"end_time"`
	Duration     time.Duration  `json:"duration"`
	Stats        map[string]int `json:"stats"`              // count of each kind of action
	Warnings     []string       `json:"warnings,omitempty"` // collect warnings
}

MoveAndMergeReport provides a summary and detailed log of all actions performed during a MoveAndMerge operation. It includes a list of actions, statistics, warnings, timing and Stage's information about the operation.

func (*MoveAndMergeReport) AddAction

func (r *MoveAndMergeReport) AddAction(act MergeActionType, ng *namedGraph, desc, result string, meta map[string]any)

func (*MoveAndMergeReport) String

func (r *MoveAndMergeReport) String() string

String returns the string of JSON representation of the MoveAndMergeReport.

type NamedGraph

type NamedGraph interface {
	// Base returns the base IRI by which the NamedGraph is identified.
	// The IRIs of the IBNodes of the NamedGraph are constructed by concatenation the base IRI with IBNode.Fragment(), i.e. "urn:uuid:" + ID().
	IRI() IRI

	// ID returns named graph identifier as uuid.UUID.
	// If the IRI of this NamedGraph is of type a urn:uuid, the returned value is that uuid; typically a random uuid (version 4).
	// Otherwise, if the IRI is of any other type, the returned value is a NameSpaceURL hash uuid of that IRI (version 5).
	//
	// Deprecated: Use IRI() instead. NamedGraph is identified by its IRI.
	ID() uuid.UUID

	// IsValid indicates that this NamedGraph and its Stage are valid; so this NamedGraph is neither deleted nor its Stage is closed.
	IsValid() bool

	// A NamedGraph in a Stage, so one that is contained in Stage.NamedGraphs() is either in a referenced or a local state.
	// This state is indicated by IsReferenced(). If the returned value is false, this NamedGraph is in a local state.
	// IsReferenced returns true if this NamedGraph contains only IBNodes without any subject triple.
	// This happens when these IBNodes are only referenced by triples in other NamedGraphs within the same Stage,
	// and the owning NamedGraph is not imported.
	// As a consequence, a NamedGraph in referenced state is not written in to SST Repository during commit.
	IsReferenced() bool

	// IsEmpty() returns true if this NamedGraph does not contain any triples.
	// Note: Each NamedGraph has an implicit IBNode with empty fragment, representing the whole NamedGraph.
	IsEmpty() bool

	// IsModified() returns the modified state of this NamedGraph.
	IsModified() bool

	// BlankNodeCount returns the number of blank nodes in this graph
	// or error if blank nodes are not accessible by this graph.
	BlankNodeCount() int

	// IRINodeCount returns the number of IRI nodes in this graph.
	IRINodeCount() int

	// IRINodeCount returns the number of TermCollection in this graph.
	TermCollectionCount() int

	// ForAllIBNodes invokes callback function c for each of its IBNode for a given named graph.
	// In case the callback function c returns an error, the loop terminates and this method
	// is returning this error.
	ForAllIBNodes(c ForEachNode) error

	// ForIRINodes calls given callback function c for reach IRI node.
	// In case the callback function c returns an error, the loop terminates and this method
	// is returning this error.
	ForIRINodes(c ForEachNode) error

	// ForBlankNodes calls given callback function c for each blank node.
	// In case the callback function c returns an error, the loop terminates and this method
	// is returning this error.
	ForBlankNodes(c ForEachNode) error

	// ForTermCollection calls given callback function c for each TermCollection.
	// In case the callback function c returns an error, the loop terminates and this method
	// is returning this error.
	ForTermCollection(c func(TermCollection) error) error

	// ForUndefinedIBNodes is checking for IBNodes in this NamedGraph that do not have
	// any subject triple and therefore we do not know their rdf:type and invoke the callback function for them.
	// Note 1: The NG Node has a default rdf:type owl:Ontology and therefore is not considered undefined.
	// Note 2: Every IBNode must be involve in at least one triple to exist; otherwise it can't be
	//         represent in a rdf file. SST allows the existence of IBNodes that do not show up in any triple within that NamedGraph.
	//         This is not possible in any standard RDF formats e.g. Turtle.
	ForUndefinedIBNodes(c func(IBNode) error) error

	// GetSortedIBNodes returns all sorted IBNodes for this NamedGraph.
	// The result contains first all IRI Nodes sorted by their fragments and then all
	// blank Nodes sorted by their usages of IRI Nodes either directly or indirectly.
	// TBD: what will happen if the blank Nodes are not referenced by any IRI Nodes?
	GetSortedIBNodes() []IBNode

	// RdfWrite writes given NamedGraph to an rdf file with given name and of given format.
	// Currently, only the RDF format Turtle is supported.
	// The resulting file will contain a special NamedGraph-Node with empty fragment that represents the whole NamedGraph and that is of type owl:Ontology.
	// In addition, the NamedGraph-Node might have further owl:imports triples for the imported NamedGraphs.
	RdfWrite(w io.Writer, format RdfFormat) error

	// Stage returns the stage this named graph belongs to.
	Stage() Stage

	// CreateIRINode creates a new IRI IBNode with optional triples of rdf:type for the indicated types.
	// The parameter fragment indicates the fragment of the IRI Node to create.
	// If this value is an empty string, a new random UUID for the fragment is created.
	// Note: The special Node that represents the complete the NamedGraph also has an empty fragment, but it is created only implicitly and always
	// available when needed. This special NamedGraph-Node can be accessed by GetIRINodeByFragment() with empty string for the fragment parameter.
	CreateIRINode(fragment string, types ...Term) IBNode

	// CreateBlankNode creates a new blank node within the NamedGraph.
	// The returned blank node is not (yet) associated with any triple.
	CreateBlankNode(types ...Term) IBNode

	// CreateCollection returns a TermCollection, which is created by given members in the namedGraph.
	// A TermCollection with no member is treated in SST by rdf:nil.
	// a TermCollection is (at least in Turtle) treated as a BlankNode
	CreateCollection(members1 ...Term) TermCollection

	// GetIRINodeByFragment returns IBNode which is an IRI node with given fragment.
	GetIRINodeByFragment(fragment string) IBNode

	// GetBlankNodeByID returns IBNode which is a blank node with given id.
	GetBlankNodeByID(id uuid.UUID) IBNode

	// AddImport adds the NamedGraph ng to this NamedGraph.
	// When exporting to rdf/ttl, this is indicated by owl:imports.
	// Panic will be called if ng is already imported by this NamedGraph.
	AddImport(ng NamedGraph) error

	// RemoveImport removes the NamedGraph ng from this NamedGraph.
	// Panic will be called if ng is not imported by this NamedGraph.
	RemoveImport(ng NamedGraph) error

	// DirectImports returns directly imported NamedGraphs.
	DirectImports() []NamedGraph

	// FindCommonParentRevision searches for a common ancestor of this and the other NamedGraph and returns this.
	// For this, the two NamedGraphs must have the same IRI and needs to be opened in different Stages
	// that are both linked to the same Repository. Only then, it is possible to compare the two revisions of the
	// same NamedGraph.
	// This method traverses the revision history of both NamedGraphs in the Repository
	// by following the commit tree that contain information about the parents.
	// This method returns either this NamedGraph or the other NamedGraph or a 3rd NamedGraph
	// with the same IRI in a new 3rd Stage of the same Repository.
	// This method returns nil if there is no common parent revision.
	// Note: This method is used for three-way diff and merge.
	FindCommonParentRevision(ctx context.Context, other NamedGraph) NamedGraph

	// MoveIBNode moves the specified IBNode `s` from its owning NamedGraph to the receiver NamedGraph.
	// If an IBNode with the same fragment already exists in the target graph, it will result in panic.
	// If fragment is non-empty, it will be used for the new IRI of Node.
	// TODO: The NG Node (fragment="") cannot be moved, it will result in panic.
	// The function checks access permissions and ensures both graphs belong to the same stage before moving.
	// Returns an error if access is denied or the graphs are not in the same stage.
	// Note: MoveIBNode can also be used to renamed the fragment of an IRI Node within the same NamedGraph.
	MoveIBNode(s IBNode, fragment string) error

	// SstWrite writes NamedGraph into given writer using SST file format.
	SstWrite(w io.Writer) error

	// Empty() removes all IBNodes that are not referenced from other NamedGraphs in the same Stage.
	// Unlike the Delete() method, Empty() keeps the NamedGraph valid.
	Empty()

	// Delete() tries to remove a NamedGraph if it is not imported by any other NamedGraphs in the same Stage.
	// If the NamedGraph is imported by any other NamedGraphs in the same Stage, the error ErrNamedGraphIsImported is returned.
	// Otherwise, all IBNodes in this NamedGraph that are not referenced by IBNodes of other NamedGraphs are deleted.
	// If this NamedGraph still contains IBNodes that are referenced by IBNodes of other NamedGraphs, in the same Stage,
	// then this NamedGraph is turned into a referenced one. Otherwise, this NamedGraph is completely removed from the
	// Stage and NamedGraph.IsValid() will return false.
	// Note: If only the content of the NamedGraph to be removed, use Empty() method.
	//       When committing this Stage, a new DatasetRevision of this deleted NamedGraph is created, and the corresponding NamedGraphRevision
	//       filed is set to HashNil(). There is no new entry created in NamedGraphRevision bucket.
	//       Then, when this Dataset is accessed in future, Repository.Dataset() method could got this Dataset.
	//       But if Dataset.CheckoutCommit() or Dataset.CheckoutBranch() is called to load the commit that deleting this NamedGraph,
	//       error ErrDatasetHasBeenDeleted is returned.
	//       The history of this deleted NamedGraph is still kept and could be accessed by CheckoutCommit/CheckoutBranch its previous commits.
	Delete() error

	// Equal compares this NamedGraph with another NamedGraph for structural and content equality.
	// It compares the NamedGraph IRIs, all IRIs and blankNodes with all their subject triples.
	// Returns true if the graphs are equal, false otherwise.
	// Note: The two NamedGraphs need to be in different Stages to be identical.
	//       The memory addresses of IBNodes in the two NamedGraphs are different; different Stages don't share memory.
	// TBD: add blankNodes comparison
	Equal(ng NamedGraph) bool

	// Info returns a NamedGraphInfo struct containing statistics about this NamedGraph.
	// The info includes the number of direct imported graphs, the number of indirect imported graphs,
	// and the number of triples in the named graph.
	//
	// Returns:
	// - NamedGraphInfo: A struct containing the following fields:
	//   - NumberOfDirectImportedGraphs: The number of directly imported named graphs.
	//   - NumberOfIndirectImportedGraphs: The number of indirectly imported named graphs.
	//   - NumberOfTriples: The total number of triples in the named graph.
	//
	// The function performs the following steps:
	// 1. Initializes counters for direct imported graphs, indirect imported graphs, and triples.
	// 2. Counts the number of direct imported graphs by getting the length of the directImports map.
	// 3. Defines a recursive function to count the number of indirect imported graphs.
	// 4. Iterates over the directImports map and applies the recursive function to count indirect imports.
	// 5. Iterates over the triplexStorage slice and counts the number of triples.
	Info() NamedGraphInfo

	// SetCommits sets 0, 1, or many CheckoutCommit values that are to be used for further Commit operations
	// on the owning Stage resulting in new parent commits.
	// Note: This method is only to be used for NamedGraph in the fromStage in MoveAndMerge method or when manually merging is performed.
	//       In all other cases, SST takes care of all the correct parent commits when making a new commit.
	SetCommits(Commits ...Hash)

	// method for debugging purpose that prints out the content of this NamedGraph into os.Stderr.
	// Dump() will print all triples in a list format.
	// Example:
	// TTL format:
	// :b750eaf5-55ff-4679-bb82-2cb01c22d1b2	a	lci:Individual ;
	// 	    rdfs:label	"HelloWorld" .
	// Output:
	// 	2025/10/21 13:35:41 NamedGraph ID: eedb4dec-f20c-4a44-aeb4-57bc3f684798
	// 	2025/10/21 13:35:41 graph BaseURI: urn:uuid:eedb4dec-f20c-4a44-aeb4-57bc3f684798
	// 	2025/10/21 13:35:41 graph flags:  isReferenced: false
	// 	2025/10/21 13:35:41              trackPredicates: true    modified: true
	// 	2025/10/21 13:35:41 directImports ( 0 ) :
	// 	2025/10/21 13:35:41 stringNodes ( 1 ) :
	// 	2025/10/21 13:35:41 0
	// 	2025/10/21 13:35:41 ib: &{{<nil>} 0xc000b1e000 0 0 0}
	// 	2025/10/21 13:35:41 typedResource.typeOf: <nil>
	// 	2025/10/21 13:35:41 ib.triplexStart: 0 ib.triplexEnd: 0
	// 	2025/10/21 13:35:41 ib.flags: 0
	// 	2025/10/21 13:35:41 ib frag:
	// 	2025/10/21 13:35:41
	// 	2025/10/21 13:35:41 uuidNodes ( 1 ) :
	// 	2025/10/21 13:35:41 0
	// 	2025/10/21 13:35:41 ib: &{{0xc000bf3aa0} 0xc000b1e000 0 6 1}
	// 	2025/10/21 13:35:41 typedResource.typeOf: &{{<nil>} 0xc000b1e380 0 6 0}
	// 	2025/10/21 13:35:41 ib.triplexStart: 0 ib.triplexEnd: 6
	// 	2025/10/21 13:35:41 ib.flags: 1
	// 	2025/10/21 13:35:41 ib id: b750eaf5-55ff-4679-bb82-2cb01c22d1b2
	// 	2025/10/21 13:35:41
	// 	2025/10/21 13:35:41 graph triplexStorage ( 6 ):
	// 	2025/10/21 13:35:41 0
	// 	2025/10/21 13:35:41  subjectTriplex
	// 	2025/10/21 13:35:41  http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://ontology.semanticstep.net/lci#Individual
	// 	2025/10/21 13:35:41 1
	// 	2025/10/21 13:35:41  subjectTriplex
	// 	2025/10/21 13:35:41  http://www.w3.org/2000/01/rdf-schema#label HelloWorld^^http://www.w3.org/2001/XMLSchema#string
	Dump()

	// method for debugging purpose that prints out all IBNodes with their triples into standard output.
	// PrintTriples() will print all triples in Subject-Predicate-Object format.
	// Example:
	// TTL format:
	// :b750eaf5-55ff-4679-bb82-2cb01c22d1b2	a	lci:Individual ;
	// 	    rdfs:label	"HelloWorld" .
	// Output:
	// 	IBNode: urn:uuid:eedb4dec-f20c-4a44-aeb4-57bc3f684798#b750eaf5-55ff-4679-bb82-2cb01c22d1b2
	// 	http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://ontology.semanticstep.net/lci#Individual
	// 	IBNode: urn:uuid:eedb4dec-f20c-4a44-aeb4-57bc3f684798#b750eaf5-55ff-4679-bb82-2cb01c22d1b2
	// 	http://www.w3.org/2000/01/rdf-schema#label "HelloWorld"
	PrintTriples()
	// contains filtered or unexported methods
}

NamedGraph is the memory representation of an RDF named graph that contain IBNode's. A NamedGraph is either referenced or not. The purpose of a referenced NamedGraph is to hold the IBNodes that are only referenced from other NamedGraphs in the same Stage, but there are no subject statements recorded for these IBNodes. Referenced NamedGraphs cannot be changed directly, cannot be saved/committed, cannot be written out (SstWrite/RdfWrite). If a NamedGraph is not referenced, each IBNode in it must have at least one subject triple (eg. rdf.type). A NamedGraph should contain at least one subject triple, otherwise it can not be usefully written into a rdf file.

func SstRead

func SstRead(r *bufio.Reader, mode TriplexMode) (NamedGraph, error)

SstRead reads an SST binary file and returns the contained main NamedGraph.

func SstReadDiff

func SstReadDiff(mode TriplexMode, rBase *bufio.Reader, rDiff *bufio.Reader) (NamedGraph, error)

SstReadDiff reads a base sst binary and a binary diff on this and returns the resulting NamedGraph. TBD: add a plusNotMinus parameter func SstReadDiff(mode TriplexMode, rBase *bufio.Reader, rDiff *bufio.Reader, plusNotMinus bool) (NamedGraph, error)

func SstReadOld

func SstReadOld(r *bufio.Reader, mode TriplexMode) (NamedGraph, error)

SstReadOld reads an SST binary file using the old float64 format (Uvarint encoded). This is useful for reading legacy SST files that were written before the format change. It is identical to SstRead except it uses readFloat64Old instead of readFloat64.

type NamedGraphInfo

type NamedGraphInfo struct {
	// same as NamedGraph method IRI()
	Iri IRI
	// same as NamedGraph method ID()
	Id uuid.UUID
	// same as NamedGraph method IsReferenced()
	IsReferenced bool
	// same as NamedGraph method IsEmpty()
	IsEmpty bool
	// same as NamedGraph method IsModified()
	IsModified bool
	// same as NamedGraph method IRINodeCount()
	NumberOfIRINodes int
	// same as NamedGraph method BlankNodeCount()
	NumberOfBlankNodes int
	// same as NamedGraph method TermCollectionCount()
	NumberOfTermCollections int
	// the number of direct imported NamedGraphs by this NamedGraph
	NumberOfDirectImportedGraphs int
	// the number of direct and indirect imported NamedGraphs by this NamedGraph
	NumberOfAllImportedGraphs int

	// the number of subject triples in current Triplex structure in memory for this NamedGraph
	NumberOfSubjectTriples int

	// the number of predicate triples in current Triplex structure in memory for this NamedGraph
	NumberOfPredicateTriples int

	// the number of object triples in current Triplex structure in memory for this NamedGraph
	NumberOfObjectTriples int

	// the number of term collection triples in current Triplex structure in memory for this NamedGraph
	NumberOfTermCollectionTriples int

	// the commits of this NamedGraph
	// If the NamedGraph is a new one, then there is no Commit (yet).
	// If the NamedGraph was checked out from an SST Repository with history then there is exactly one NamedGraph.
	// After one or several MoveAndMerge invocations there might be several Commit entries.
	// After a successful invocation of the Stage method Commit() on a repository with history support; there will be exactly one entry.
	Commits []Hash

	// the NamedGraph Revision Hash of this NamedGraph
	// If this is a new NamedGraph, NamedGraphRevision and DatasetRevision will be HashNil() value.
	// Otherwise if the NamedGraph is loaded from a Repository with history,
	// then the NamedGraphRevision and DatasetRevision reflect the revision stored in the Repository.
	NamedGraphRevision Hash

	// the Dataset Revision Hash of this NamedGraph's corresponding Dataset
	DatasetRevision Hash
}

NamedGraphInfo struct is the return type of the NamedGraph method Info(). The data contained in this struct represents the state of a NamedGraph at the time when Info() was invoked. NamedGraphInfo is not used for any other purpose; changes on the data in NamedGraphInfo do not have any effect on NamedGraph.

type Node

type Node interface {
	Term
	// IsTermCollection returns true if the IBNode is a term collection.
	// In this case, the IBNode can be converted into a TermCollection.
	// e.g.
	// var ib IBNode
	// if ib.IsTermCollection() {
	//    col := ib.(TermCollection)
	// }
	IsTermCollection() bool

	// IRI returns the IRI of this [Node].
	IRI() IRI
}

Node represents an interface for nodes that can be either a TermCollection or an IBNode.

type RdfFormat

type RdfFormat int

RdfFormat represents a RDF serialization format.

const (
	RdfFormatTurtle RdfFormat = iota
	RdfFormatTriG
)

Supported parser/serialization formats for Triples and Quads.

type Repository

type Repository interface {
	// URL returns the specific location where this repository is stored.
	// For a remote main repository (not an item in a SuperRepository) the returned URL has NO FRAGMENT.
	// For a remote repository that is an item in a SuperRepository the returned URL has a Fragment that is the name/id of the repository.
	// For a local repository the returned URL is URL for the local path (normal/default or item in a super repository).
	URL() string

	// SuperRepository() either returns the SuperRepository this Repository belongs to or otherwise return a nil value.
	SuperRepository() SuperRepository

	// OpenStage(DefaultTriplexMode) will create an empty stage to work on persistent data in this SST Repository to which it is linked to.
	// Linking means that data can be loaded from the SST Repository to the Stage and written back to it.
	// As a result, Datasets from this Repository can be loaded, modified, committed or created anew to this SST Repository.
	// TODO: Several Stages for the same Repository can be opened.
	OpenStage(mode TriplexMode) Stage

	// ForDatasets calls given callback function c for each Dataset in the Repository.
	// In case the callback function c returns an error, the loop terminates and this method
	// is returning this error.
	ForDatasets(ctx context.Context, c func(ds Dataset) error) error

	// ForDocuments calls given callback function c for each DocumentInfo in the Repository.
	// In case the callback function c returns an error, the loop terminates and this method
	// is returning this error.
	ForDocuments(ctx context.Context, c func(d DocumentInfo) error) error

	// Datasets retrieves all dataset IRIs from the SST Repository.
	// If there is no Dataset stored in the Repository, an empty slice will be returned.
	Datasets(ctx context.Context) ([]IRI, error)

	// Dataset returns the existing Dataset from the Repository.
	Dataset(ctx context.Context, iri IRI) (Dataset, error)

	// CommitDetails returns commit metadata for the given list of commit hashes.
	CommitDetails(ctx context.Context, hashes []Hash) ([]*CommitDetails, error)

	// A new created sst.Repository has initially no indexMapping, meaning there is no query functionality.
	// RegisterIndexHandler checks if the provided DerivePackageVersion is same with the DerivePackageVersion in the Repository.
	// If they are different,  the complete recreation of the bleve index will be performed.
	// Application might use the default index mapping provided by defaultderive.DeriveInfo()
	// or create their own specific index mapping.
	// IndexMapping can be empty SSTDeriveInfo struct to remove an existing bleve index.
	// RegisterIndexHandler is only available for local Repositories.
	// Remote repository has predefined index handler which can modified/recreated only on the installation/deployment level.
	// When the Repository is a member of a SuperRepository, this will return ErrNotAvailable.
	RegisterIndexHandler(*SSTDeriveInfo) error

	// Bleve() returns the bleve index if one is registered.
	// A nil value is returned if no one is registered.
	// For Remote Repository, it returns the bleve client. So there is no need to add context parameter.
	Bleve() bleve.Index

	// Close closes the Repository
	Close() error

	// Info returns basic information about the repository content and history.
	// If the the branchName is an empty string, then NumberOfDatasetsInBranch contains those Datasets that are in any branch.
	// Otherwise, NumberOfDatasetsInBranch lists only those Datasets that are in the specified branch.
	Info(ctx context.Context, branchName string) (RepositoryInfo, error)

	// Log returns a list of log entries.
	//
	// Parameters:
	// - `start`: the starting logKey (inclusive). If nil or 0, starts from the latest logKey.
	// - `end`:
	//     - If negative, returns at most `-end` entries.
	//     - If positive, defines the exclusive lower bound (entries with logKey > end will be returned).
	//       That is, entries with logKey ≤ end will be excluded.
	//
	// Behavior Examples:
	//   start=nil, end=-100      → return the latest 100 entries
	//   start=123456, end=-50    → return 50 entries from logKey 123456 down to 123407 (inclusive)
	//   start=123, end=100       → return entries from 123 down to 101 (inclusive); excludes 100
	//   start=nil, end=nil       → return all entries from latest to earliest
	Log(ctx context.Context, start, end *int) ([]RepositoryLogEntry, error)

	// ExtractSstFile extracts a particular revision of a NamedGraph into a io.Writer that will create a SST-file.
	ExtractSstFile(ctx context.Context, namedGraphRevision Hash, w io.Writer) error

	// Only used in remoteRepository and LocalFullRepository.
	// For RemoteRepository, it can sync from a LocalFullRepository to the method receiver.
	// For LocalFullRepository, it can sync from a RemoteRepository to the method receiver.
	// Options can be used to specify which datasets and branches to sync:
	// - If no options are provided, syncs all datasets and all branches.
	// - Use WithDatasetIRIs() to specify which datasets to sync (including their imported dependencies).
	// - Use WithBranch() to specify which branch to sync (use "*" or empty string for all branches).
	SyncFrom(ctx context.Context, from Repository, options ...SyncOption) error

	// DocumentSet stores the given document in the repository and returns its hash.
	// The document is read from source and associated with the provided MIME type.
	DocumentSet(ctx context.Context, MIMEType string, source *bufio.Reader) (Hash, error)

	// Document retrieves the document with the given hash and writes it to target.
	// It returns the associated document info.
	// If target is nil, then only the DocumentInfo is returned
	Document(ctx context.Context, hash Hash, target io.Writer) (*DocumentInfo, error)

	// Documents returns a list of all document metadata stored in the repository.
	Documents(ctx context.Context) ([]DocumentInfo, error)

	// DocumentDelete removes the document content and its DocumentInfo from the repository using the given hash.
	DocumentDelete(ctx context.Context, hash Hash) error
	// contains filtered or unexported methods
}

All Repository methods have a context parameter to specify things like timeout e.g. for remote Repository access. Context parameter is also used for user identification and authentication. User identification is done by email address stored in the context. TBD: To be clarified. SST identifies Datasets by a UUID that is derived from the Dataset IRI.

func CreateLocalFlatRepository

func CreateLocalFlatRepository(repoDir string) (Repository, error)

CreateLocalFlatRepository creates a new LocalFlatRepository at the specified path. If the directory already exists, it returns an error indicating that the repository already exists. If the directory does not exist, it creates a new directory with the specified permissions.

Parameters:

  • repoDir: The path to the directory where the repository should be created.

Returns:

  • Repository: The created repository object.
  • error: An error if the repository could not be created or if the directory already exists.

Possible errors:

  • errRepositoryAlreadyExists: The directory already exists.
  • errDirectoryExpected: The path exists but is not a directory.
  • Other errors related to directory creation and path resolution.

func CreateLocalRepository

func CreateLocalRepository(repoDir string, email string, name string, revisionHistory bool) (Repository, error)

CreateLocalRepository creates a new local repository at the specified directory. It returns a Repository or an error if any issues occur during the process.

Parameters: - repoDir: The directory path where the repository will be created. - email: The email address of the user creating the repository. - name: The name of the user creating the repository. - revisionHistory: A boolean indicating whether to enable revision history for the repository.

Returns: - Repository: An interface representing the created repository. - error: An error if the repository cannot be created or if there are issues during the creation process.

The function performs the following steps: 1. Checks if the specified directory already exists. If it does, it returns errRepositoryAlreadyExists. 2. If there are other errors (e.g., permission issues), it returns the error. 3. If the directory does not exist, it creates the directory with appropriate permissions. 4. Constructs the path to the bbolt database file. 5. Creates and opens the bbolt database with specific options (e.g., no freelist sync, using a map-type freelist). 6. If revisionHistory is true, it creates a LocalFullRepository with history supporting. 7. If revisionHistory is false, it creates a local repository without history supporting.

Example usage:

repo, err := CreateLocalRepository("/path/to/repo", "default@semanticstep.net", "default", true)
if err != nil {
    log.Fatal(err)
}
// Use the created repository (repo)...

func OpenLocalFlatFileSystemRepository

func OpenLocalFlatFileSystemRepository(dictFS fs.FS) (Repository, error)

func OpenLocalFlatRepository

func OpenLocalFlatRepository(repoDir string) (Repository, error)

LocalFlatRepository is a kind of SST Repository where NamedGraphs are written as individual SST Binary files in the local file system. As each SST Binary file is written independently no transaction functionality is provided. No change history is recorded for this Repository kind. The names of the SST Binary files are named by their UUID and suffixed by ".sst"

Eg. 3ffe6728-9a14-4ae8-8db7-5b4ae7984ab9.sst

If a NamedGraph is identified by arbitrary IRI that is not urn-uuid then UUID is derived from the IRI as SHA1 (Version 5) UUID. Note: The full IRI of a NamedGraph is stored within the SST Binary file.

OpenLocalFlatRepository opens a LocalFlatRepository. It takes the path to the repository directory as an argument and returns a Repository instance or an error if the directory does not exist or is not a directory.

Parameters:

  • repoDir: The path to the repository directory.

Returns:

  • Repository: The repository instance if the directory exists and is valid.
  • error: An error if the directory does not exist, is not a directory, or if there is any other issue.

func OpenLocalRepository

func OpenLocalRepository(repoDir string, email string, name string) (Repository, error)

OpenLocalRepository opens an existing local repository located at the specified directory. It returns a Repository interface and an error if any issues occur during the process.

Parameters: - repoDir: The directory path where the repository is located. - email: The email address of the user accessing the repository. - name: The name of the user accessing the repository.

Returns: - Repository: An interface representing the opened repository. - error: An error if the repository does not exist or if there are issues opening it.

The function performs the following steps: 1. Checks if the specified directory exists. If it does not exist, it returns ErrRepositoryDoesNotExist. 2. If there are other errors (e.g., permission issues), returns it. 3. If the directory exists, it constructs the path to the bbolt database file. 4. Opens the bbolt database with specific options (e.g., no freelist sync, using a map-type freelist). 5. If there is an error opening the bbolt database, returns it.

Example usage:

repo, err := OpenLocalRepository("/path/to/repo", "default@semanticstep.net", "default")
if err != nil {
    log.Fatal(err)
}
// Use the opened repository (repo)...

func OpenRemoteRepository

func OpenRemoteRepository(ctx context.Context, URL string, tlsOption grpc.DialOption) (Repository, error)

OpenRemoteRepository initializes and opens a remote SST repository.

Parameters:

  • ctx: The context for managing request deadlines and cancellation signals, also contains the [AuthProvider].
  • targetURL: The URI of the remote repository server.
  • tlsOption: The gRPC dial option for TLS configuration.

Returns:

  • Repository: The opened remote repository instance.
  • error: An error if the repository could not be opened.

The function performs the following steps:

  1. Sets up the gRPC connection options, including TLS configuration.
  2. Dials the remote repository server using the provided URI and connection options.
  3. Retrieves the OAuth2 token from the context's auth provider and adds it to the gRPC call options.
  4. Attempts to get the repository's index mapping to verify the connection.
  5. Returns the repository instance if successful, or an error if any step fails.

type RepositoryInfo

type RepositoryInfo struct {
	URL                         string `json:"url"`
	AccessRight                 string `json:"AccessRight"`
	MasterDBSize                int    `json:"masterDBSize"`  // BboltSize
	DerivedDBSize               int    `json:"derivedDBSize"` // BleveSize
	DocumentDBSize              int    `json:"documentDBSize"`
	NumberOfDatasets            int    `json:"numberOfDatasets"`
	NumberOfDatasetsInBranch    int    `json:"numberOfDatasetsInBranch"`
	NumberOfDatasetRevisions    int    `json:"numberOfDatasetRevisions"`
	NumberOfNamedGraphRevisions int    `json:"numberOfNamedGraphRevisions"`
	NumberOfCommits             int    `json:"numberOfCommits"`
	NumberOfRepositoryLogs      int    `json:"NumberOfRepositoryLogs"`
	NumberOfDocuments           int    `json:"NumberOfDocuments"`
	IsRemote                    bool   `json:"isRemote"`
	SupportRevisionHistory      bool   `json:"supportRevisionHistory"`
	BleveName                   string `json:"bleveName"`
	BleveVersion                string `json:"bleveVersion"`
	VersionHash                 string `json:"versionHash"`
}

RepositoryInfo represents the statistics of a repository.

func (RepositoryInfo) String

func (r RepositoryInfo) String() string

type RepositoryLogEntry

type RepositoryLogEntry struct {
	LogKey uint64
	Fields map[string]string // timestamp, type, commit_id, message, ...
}

type = "remove_branch":

  • "author": string, Author email.
  • "dataset": string, UUID of the dataset.
  • "branch": string, Branch name removed.
  • "message": string, Additional info.
  • "ds_revision": string, Dataset revision hash.
  • "timestamp": string, RFC3339 format.

type = "upload_document":

  • "author": string, Author email.
  • "hash": string, Document SHA256 hash (hex).
  • "file_name": string, Original file name.
  • "mime_type": string, MIME type.
  • "message": string, Description.
  • "timestamp": string, RFC3339 format.

type = "download_document":

  • "author": string,. Author email.
  • "hash": string, Document SHA256 hash (hex).
  • "mime_type": string, MIME type.
  • "message": string
  • "timestamp": string, RFC3339 format.

type = "delete_document":

  • "author": string, Author email.
  • "hash": string, Document SHA256 hash (hex).
  • "mime_type": string, MIME type.
  • "message": string
  • "timestamp": string, RFC3339 format.

type RepositoryServer

type RepositoryServer struct {
	*grpc.Server
	// contains filtered or unexported fields
}

RepositoryServer represents a SST Repository server instance. Should have a default Repository that always exists called "default".

func NewServer

NewServer creates and initializes a new RepositoryServer instance using the provided configuration. If the repository does not exist at the specified directory, it will be created automatically. If the repository exists, it will be opened. Typical use: // announces on the local network address lis, err := net.Listen("tcp", bindAddress)

if err != nil {
	log.Fatalf("failed to listen: %v", err)
}

// create SST server s, err := sst.NewServer(&config)

if err != nil {
	return
}

// start serving SST repository service

if err := s.Serve(lis); err != nil {
	log.Fatalf("failed to serve: %v", err)
}

func (RepositoryServer) GracefulStopAndClose

func (s RepositoryServer) GracefulStopAndClose() error

GracefulStopAndClose gracefully stops the gRPC server and closes the repository.

type RepositoryServerConfig

type RepositoryServerConfig struct {
	RepoDir    string           // repository folder
	Issuer     string           // OIDC issuer URL
	ClientID   string           // OIDC client ID
	ServerCert *tls.Certificate // tls.Certificate
	Verbose    bool             // verbose log output, the value is a bool value, default false
	DeriveInfo *SSTDeriveInfo   `json:"-"` //the bleve configuration(mapping)
}

Repository initial setup configuration.

type SSTDeriveInfo

type SSTDeriveInfo struct {
	DerivePackageName    string                                                                                                                      `json:"DerivePackageName"`
	DerivePackageVersion string                                                                                                                      `json:"DerivePackageVersion"`
	DefaultIndexMapping  func() *mapping.IndexMappingImpl                                                                                            `json:"-"`
	DeriveDocuments      func(r Repository, g NamedGraph) (id string, document map[string]interface{}, preConditionQueries []query.Query, err error) `json:"-"`
}

SSTDeriveInfo describes which bleve package the Repository is using. [Repository.RegisterIndexHandler] needs this struct. Repository method [Repository.IndexMapping] returns the DerivePackageName and DerivePackageVersion.

type Short

type Short int16

xsd:short

func (Short) DataType

func (Short) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the Short data type. e.g. Short.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#short, or in short xsd:short

func (Short) TermKind

func (Short) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type Stage

type Stage interface {
	// Creates a NamedGraph in this Stage whose name is the provided IRI.
	// Note that the NamedGraph IRI must be unique within the Stage and also unique within the linked Repository.
	// The ID of the created NamedGraph will be a hash UUID (version 5) of the IRI of this NamedGraph.
	// A created NamedGraph is in local state(NamedGraph.IsReferenced() will return false).
	// e.g.
	// ng := stage.CreateNamedGraph(sst.IRI("http://example.com/test1"))
	CreateNamedGraph(iri IRI) NamedGraph

	// NamedGraph returns the local NamedGraph for the specified IRI.
	// If the NamedGraph with the IRI is not used in the Stage then the nil value is returned.
	NamedGraph(iri IRI) NamedGraph

	// NamedGraphs returns a slice of all local NamedGraphs in this Stage.
	// The returned slice does not contain Referenced NamedGraphs.
	// The returned slice might be empty.
	NamedGraphs() []NamedGraph

	// ReferencedGraph returns the Referenced NamedGraph for the specified base URI.
	// If the NamedGraph with the baseIRI is not used in the Stage then the nil value is returned.
	ReferencedGraph(iri IRI) NamedGraph

	// ReferencedGraphs returns a slice of all referenced NamedGraph in this Stage.
	// The returned slice does not contain loaded NamedGraphs.
	// The returned slice might be empty.
	ReferencedGraphs() []NamedGraph

	// ForNamedGraphs loops through all NamedGraphs in this Stage that are not in Referenced state
	// and invokes the callback function c for each of them.
	// In case the callback function c returns an error, the loop terminates and this method
	// is returning this error.
	ForNamedGraphs(c func(ng NamedGraph) error) error

	// ForReferencedNamedGraphs loops through all referenced NamedGraphs in this Stage
	// and invokes the callback function c for each of them.
	// In case the callback function c returns an error, the loop terminates and this method
	// is returning this error.
	ForReferencedNamedGraphs(c func(ng NamedGraph) error) error

	// IsValid returns true if the Stage is valid and represents the non-zero value of Stage type.
	// Methods such as MoveAndMerge() results in invalid Stages.
	// References to invalid Stages should be removed so that they can be taken care by garbage collector.
	IsValid() bool

	// Repository returns the SST [Repository] this Stage is linked to.
	Repository() Repository

	// Commit is saving all changes of the [NamedGraph]s and [IBNode]s in this Stage into the linked repository.
	// For each modified NamedGraph a new NamedGraphRevision is created.
	// Corresponding DatasetRevisions are created for each new NamedGraphRevisions or if one of the imported NamedGraphs has changed.
	// if branchName is an empty string, then the branchNames for each modified Dataset in the target repository is not changed.
	// if branchName is not an empty string, then for each modified Dataset with a branchName is set respectively moved
	// to the new Dataset Revision. Note: The specified branchName might be a new one.
	// If the stage is ephemeral (not linked to a repository), error sst.ErrStageNotLinkToRepository is returned.
	// Other errors may be returned from the underlying file system or connection to a remote repository.
	// If this method is successful, a Hash value is returned that identifies the commit together with the new DatasetRevisions.
	Commit(ctx context.Context, message string, branchName string) (Hash, []uuid.UUID, error)

	// MoveAndMerge tries to automatically move and merges all NamedGraphs and referenced graphs from the source Stage (`from`) into the target Stage (`to`).
	// After merging, the source Stage is cleared of all local and referenced graphs.
	// If a source NamedGraph does not exist in the target Stage, it is taken as it is.
	// If a source NamedGraph does exist in the target Stage, this method tries to merge these two NamedGraphs.
	// For merging two NamedGraph revisions, this method tries to find a common ancestor in the revision history in the Repository of the target Stage.
	// If a common ancestor is found:
	// 	1. if fromNG is a xxx-parent of the toNG, keep te toNG, and skip the fromNG
	// 	2. if the toNG is a xxx-parent of the fromNG, replace the toNG by the the fromNG
	// 	3. TBD: otherwise, use a common parent to perform a 3-diff merge
	// If no common ancestor is found, the fromNG is merged into the toNG by adding all IBNodes and triples from the fromNG into the toNG.
	// Returns:
	//   *MoveAndMergeReport - A report with detailed statistics about moved, merged, and deleted graphs/nodes.
	//   error               - An error if the operation fails.
	//
	// Typical usage:
	//   report, err := stage.MoveAndMerge(ctx, fromStage)
	//   if err != nil {
	//       // handle error
	//   }
	//   fmt.Println(report)
	MoveAndMerge(ctx context.Context, from Stage) (*MoveAndMergeReport, error)

	// ForUndefinedIBNodes is looping through all local NamedGraphs for IBNodes that do not have any subject triple
	// and invoke callback function for them. The undefined IBNodes might be referenced as predicate or object in the same NamedGraph or not.
	// In case the callback function c returns an error, the loop terminates and this method
	// is returning this error.
	// Note: SST allows the existence of IBNodes that do not show up in any triple within that NamedGraph.
	//       This is not possible in any standard RDF formats e.g. Turtle.
	ForUndefinedIBNodes(c func(IBNode) error) error

	// IBNodeByVocabulary locates the IBNode with the IRI for the specified vocabulary element.
	IBNodeByVocabulary(t Elementer) (IBNode, error)

	// Close() ensures that all memory allocated by the stage is released and can be taken away by garbage collection.
	// After calling this method, the stage can no longer be used and it is invalid.
	// TODO: ensure all underlying objects become invalid
	Close()

	// WriteToSstFiles writes this Stage data to the specified directory.
	//
	// Parameters:
	//   - stageDir: The filesystem directory where the stage data will be written.
	//
	// Returns:
	//   - err: An error if the write operation fails, otherwise nil.
	WriteToSstFiles(stageDir fs.FS) (err error)

	// WriteToSstFilesWithBaseURL writes this Stage data to the specified directory using the graph's base URL as filename.
	// Unlike WriteToSstFiles which uses UUIDs as filenames, this function uses a base64-encoded version of the base URL
	// portion of each graph's IRI. This ensures the filename is filesystem-safe while being reversible.
	//
	// Parameters:
	//   - stageDir: The filesystem directory where the stage data will be written.
	//
	// Returns:
	//   - err: An error if the write operation fails, otherwise nil.
	WriteToSstFilesWithBaseURL(stageDir fs.FS) (err error)

	// Info returns a StageInfo struct containing information about the Stage.
	// The information include the number of local graphs, the number of referenced graphs,
	// and the total number of triples across all local graphs.
	//
	// Returns:
	// - StageInfo: A struct containing the following fields:
	//   - NumberOfLocalGraphs: The number of local named graphs in the stage.
	//   - NumberOfReferencedGraphs: The number of referenced named graphs in the stage.
	//   - TotalNumberOfTriples: The total number of triples across all local named graphs.
	//
	// The function performs the following steps:
	// 1. Initializes counters for local graphs, referenced graphs, and total triples.
	// 2. Counts the number of local graphs by getting the length of the localGraphs map.
	// 3. Counts the number of referenced graphs by getting the length of the referencedGraphs map.
	// 4. Iterates over the localGraphs map and sums the number of triples from each graph's Info method.
	Info() StageInfo

	// Dump prints the repository information and dumps all localGraphs to the standard error output.
	// It logs the index of each graph before dumping it.
	Dump()

	// RdfWrite writes all NamedGraphs in this Stage to the given writer in the specified RDF format.
	// Currently supports RdfFormatTriG which allows exporting multiple named graphs in a single file.
	// For RdfFormatTurtle, only the first NamedGraph will be written (use NamedGraph.RdfWrite instead).
	RdfWrite(w io.Writer, format RdfFormat) error
	// contains filtered or unexported methods
}

A Stage is the representation of one or more NamedGraphs in memory together with the IBNodes and triples. A Stage might either work on persistent data when it is linked to a SST Repository or ephemeral data when it is not linked to a SST Repository. A particular revision of a Dataset from a SST Repository can be loaded into a Stage, resulting in a memory representation of the default NamedGraph and all other directly and indirectly imported NamedGraphs. A Stage can contain particular NamedGraph in only one revision or with no revision information when it is created anew. To work on different revisions of the same NamedGraphs, these NamedGraphs need to be opened in different Stages. Modified or new data in a Stage that is linked to a SST Repository can be committed to the SST Repository.

Note: A Stage corresponds to what is known as checkout data in Git, where only one version of a source file can exist.

func OpenStage

func OpenStage(mode TriplexMode) Stage

Creates a new Stage for ephemeral data as it is not linked to any SST Repository. To make created data in an ephemeral stage persistent the data needs to be moved or copied into another Stage that is linked to a SST Repository by [sst.MoveAndMerge()].

func RdfRead

func RdfRead(reader *bufio.Reader, f RdfFormat, readError readErrorHandler, Mode TriplexMode) (st Stage, err error)

RdfRead reads rdf from given bufio.Reader with given rdf format and creates a new NamedGraph from file content. The NamedGraph is created as a default named graph in a new Stage. This function returns the created Stage.

func ReadStageFromSstFiles

func ReadStageFromSstFiles(stageDir fs.FS, mode TriplexMode) (Stage, error)

ReadStageFromSstFiles read sst binary SST files in a provided file system directory into a new Stage and returns it.

type StageInfo

type StageInfo struct {
	NumberOfLocalGraphs      int
	NumberOfReferencedGraphs int
	// total count of all three kinds of triples of local NamedGraphs?
	// or separated count?
	TotalNumberOfTriples int
}

type String

type String string

String is a wrapper for the build-in string type that implements the Literal interface.

func (String) DataType

func (String) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the String data type. e.g. String.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#string, or in short xsd:string

func (String) TermKind

func (String) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type SuperRepository

type SuperRepository interface {
	// URL returns the specific location where this SuperRepository is stored.
	// For a remote SuperRepository the returned URL uses grpc:// scheme.
	// For a local SuperRepository the returned URL uses file:// scheme.
	URL() string

	// Get retrieves an existing repository by name from the SuperRepository.
	// If name is empty, it returns the "default" repository.
	// Returns an error if the repository does not exist.
	Get(ctx context.Context, name string) (Repository, error)

	// Create creates a new repository with the given name in the SuperRepository.
	// Returns an error if a repository with the same name already exists.
	// The created repository is automatically opened and ready for use.
	Create(ctx context.Context, name string) (Repository, error)

	// Delete removes a repository by name from the SuperRepository.
	// If name is empty, it deletes the "default" repository.
	// This operation permanently removes all data in the repository.
	Delete(ctx context.Context, name string) error

	// List returns the names of all repositories in the SuperRepository.
	// The returned slice is sorted alphabetically.
	List(ctx context.Context) ([]string, error)

	// RegisterIndexHandler registers a Bleve index handler for all sub-repositories
	// in this SuperRepository. Similar to Repository.RegisterIndexHandler but applies
	// to all repositories managed by this SuperRepository.
	// Returns an error if index registration fails.
	RegisterIndexHandler(*SSTDeriveInfo) error

	// Close releases all resources, including closing all opened sub-Repositories.
	// Any error encountered while closing individual repositories is returned.
	Close() error
}

SuperRepository is a container that manages multiple related Repositories. It provides functionality to create, retrieve, list, and delete repositories within a single location (local directory or remote server).

A SuperRepository always contains at least one "default" repository. All methods are context-aware for timeout and cancellation support.

type SuperRepositoryServer

type SuperRepositoryServer struct {
	*grpc.Server
	// contains filtered or unexported fields
}

func NewSuperServer

func NewSuperServer(c *RepositoryServerConfig, opts ...grpc.ServerOption) (*SuperRepositoryServer, error)

NewSuperServer creates a gRPC server that exposes a SuperRepository over the network. It initializes a local SuperRepository at the configured directory and registers all necessary gRPC services for remote repository access.

The function performs the following:

  • Creates/opens a local SuperRepository at c.RepoDir
  • Registers the Bleve index handler for all repositories
  • Sets up gRPC services: Dataset, Ref, Commit, Index, and RepoManager
  • Enables gRPC reflection for client discovery

The returned SuperRepositoryServer wraps the gRPC server and provides methods for graceful shutdown. Use GracefulStopAndClose() to properly stop the server and release all resources.

Returns an error if the SuperRepository cannot be created or if service registration fails.

func (SuperRepositoryServer) GracefulStopAndClose

func (s SuperRepositoryServer) GracefulStopAndClose() error

GracefulStopAndClose gracefully stops the gRPC server and closes the repository.

type SyncOption

type SyncOption func(*SyncOptions)

SyncOption is a function that modifies SyncOptions.

func WithBranch

func WithBranch(branchName string) SyncOption

WithBranch specifies which branch to sync. If branchName is empty string "" or "*", all branches will be synced. Otherwise, only the specified branch will be synced.

func WithDatasetIRIs

func WithDatasetIRIs(datasetIRIs ...IRI) SyncOption

WithDatasetIRIs specifies which datasets (by IRI) to sync. If no dataset IRIs are provided, all datasets will be synced.

type SyncOptions

type SyncOptions struct {
	// DatasetIDs is a list of dataset UUIDs to sync.
	// If nil or empty, all datasets will be synced.
	DatasetIDs []uuid.UUID

	// BranchName specifies the branch to sync.
	// Empty string "" or "*" means sync all branches.
	// Otherwise, it specifies a particular branch name (e.g., "master").
	BranchName string
}

SyncOptions contains options for synchronizing data between repositories.

type Term

type Term interface {
	// Method [Term.TermKind] returns the kind of this Term which is one of
	//   - [TermKindIBNode]
	//   - [TermKindLiteral]
	//   - [TermKindTermCollection]
	//   - [TermKindLiteralCollection]
	TermKind() TermKind
}

Term represents the object on an RDF triple, that is either of type:

type TermCollection

type TermCollection interface {
	Node

	// ForMembers invokes callback function e for each member in the collection.
	ForMembers(e func(int, Term))

	// Members returns the members of this ObjectionCollection as a slice.
	Members() []Term

	// MemberCount returns the number of members in this ObjectionCollection.
	MemberCount() int

	// Member returns the member as the indicated position starting with 0 for the first position.
	// It will panic if the index is negative or if it is equal or greater than MemberCount().
	Member(index int) Term

	// SetMembers removes the current members of this TermCollection and set all members anew.
	SetMembers(members ...Term)

	// ID returns the UUID value of this TermCollection, which is a Random (Version 4) UUID .
	ID() uuid.UUID
}

TermCollection represents a full featured RDF Collection that may contain members of type IBNode, any type of [literal], [literalCollection] or other nested TermCollection.

A TermCollection is a special type of blank node that is created by [NamedGraph.CreateCollection]. A TermCollection is deleted by "casting" it to an IBNode using [TermCollection.AsIBNode] and then invoking the method [IBNode.Delete]. An empty TermCollection is equivalent to the IBNode represented by rdf.Nil.

TermCollection struct {
	IBNode
}

type TermKind

type TermKind = int

TermKind is kind of triple object witch is either TermKindIBNode, TermKindLiteral, TermKindLiteralCollection or TermKindTermCollection. These values are returned from the TermKind() method of all types implementing the [Object] interface.

type TriplexMode

type TriplexMode int

TriplexMode is a parameter for all functions and methods that create a new Stage, including OpenStage, [RepositoryOpenStage]. The TriplexMode parameter defines which triplexes to manage in the internal SST memory structure for a given RDF triple, consisting of a subject, a predicate and an object. For every RDF triple between 1 to 3 triplexes are created: * the subject triplex is always created and contains the predicate and object for a given subject * the optional predicate triplex is created and contains the subject and object for a given predicate. * the optional object triplex is created and contains the predicate and subject of a given object. Which triplex mode to use is a question on how to balance between performance and memory requirement: * to use only subject triplexes is most memory efficient * to use only subject and object triplexes is suitable for many applications that require to traverse RDF graphs both in forward and inverse directions * to use all three kinds of triplexes together is optimal for typical SST applications that uses a lot of application specific sub-properties that are also individuals. For the SST version 1.0 only the DefaultTriplexMode is available that uses all three kinds together. The triplex structure is internal to SST and can't be accessed, modified or manipulated by application other than by this parameter.

const (
	// The default TriplexMode that manages subject, predicate and object triplex in the internal SST memory structure.
	DefaultTriplexMode TriplexMode = iota
)

type TypedString

type TypedString struct {
	Val  string
	Type Node
}

func TypedStringOf

func TypedStringOf(val string, t Node) TypedString

TypedStringOf constructs LangString from given value and language.

func (TypedString) DataType

func (ts TypedString) DataType() IBNode

func (TypedString) TermKind

func (TypedString) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type UnsignedByte

type UnsignedByte uint8

xsd:unsignedByte

func (UnsignedByte) DataType

func (UnsignedByte) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the UnsignedByte data type. e.g. UnsignedByte.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#unsignedByte, or in short xsd:unsignedByte

func (UnsignedByte) TermKind

func (UnsignedByte) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type UnsignedInt

type UnsignedInt uint32

xsd:unsignedInt

func (UnsignedInt) DataType

func (UnsignedInt) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the UnsignedInt data type. e.g. UnsignedInt.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#unsignedInt, or in short xsd:unsignedInt

func (UnsignedInt) TermKind

func (UnsignedInt) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type UnsignedLong

type UnsignedLong uint64

xsd:unsignedLong

func (UnsignedLong) DataType

func (UnsignedLong) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the UnsignedLong data type. e.g. UnsignedLong.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#unsignedLong, or in short xsd:unsignedLong

func (UnsignedLong) TermKind

func (UnsignedLong) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type UnsignedShort

type UnsignedShort uint16

xsd:unsignedShort

func (UnsignedShort) DataType

func (UnsignedShort) DataType() IBNode

DataType implements Literal.DataType() that returns an internal const IBNode for the UnsignedShort data type. e.g. UnsignedShort.DataType().IRI() will return http://www.w3.org/2001/XMLSchema#unsignedShort, or in short xsd:unsignedShort

func (UnsignedShort) TermKind

func (UnsignedShort) TermKind() TermKind

TermKind implements sst.Object.TermKind().

type Vocabulary

type Vocabulary struct {
	BaseIRI string // the unique base URI of the externally defined ontology
}

A Vocabulary represents an externally defined ontology that is made available for compile time checks by early binding access constants and methods. For this the externally defined ontology is compiled into a corresponding GO package. A Vocabulary contains VocabularyElements for the IRI nodes defined in the ontology. Example: the package ssqau represents the Vocabulary for the quantities and units defined in ISO 80000.

func (Vocabulary) ElementInformer

func (v Vocabulary) ElementInformer(name string) (ElementInformer, error)

Jump to

Keyboard shortcuts

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