Skip to main content
Version: v2.1.0

Triplestore

Overview

The okp4-cognitarium smart contract enables the storage of RDF graphs triples (i.e. subject-predicate-object) in any Cosmos blockchains using the CosmWasm framework.

InstantiateMsg

Instantiate message

parameterdescription
limitsStoreLimitsInput. Limitations regarding store usage.
limits.max_byte_sizeUint128. The maximum number of bytes the store can contains. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. Default to [Uint128::MAX] if not set, which can be considered as no limit.
Default: "340282366920938463463374607431768211455"
limits.max_insert_data_byte_sizeUint128. The maximum number of bytes an insert data query can contains. Default to [Uint128::MAX] if not set, which can be considered as no limit.
Default: "340282366920938463463374607431768211455"
limits.max_insert_data_triple_countUint128. The maximum number of triples an insert data query can contains (after parsing). Default to [Uint128::MAX] if not set, which can be considered as no limit.
Default: "340282366920938463463374607431768211455"
limits.max_query_limitinteger. The maximum limit of a query, i.e. the maximum number of triples returned by a select query. Default to 30 if not set.
Default: 30
limits.max_query_variable_countinteger. The maximum number of variables a query can select. Default to 30 if not set.
Default: 30
limits.max_triple_byte_sizeUint128. The maximum number of bytes the store can contains for a single triple. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. The limit is used to prevent storing very large triples, especially literals. Default to [Uint128::MAX] if not set, which can be considered as no limit.
Default: "340282366920938463463374607431768211455"
limits.max_triple_countUint128. The maximum number of triples the store can contains. Default to [Uint128::MAX] if not set, which can be considered as no limit.
Default: "340282366920938463463374607431768211455"

ExecuteMsg

Execute messages

ExecuteMsg::InsertData

Insert the data as RDF triples in the store. For already existing triples it acts as no-op.

Only the smart contract owner (i.e. the address who instantiated it) is authorized to perform this action.

parameterdescription
insert_data*(Required.) * object.
insert_data.data*(Required.) * Binary. The data to insert. The data must be serialized in the format specified by the format field. And the data are subject to the limitations defined by the limits specified at contract instantiation.
insert_data.formatDataFormat|null. The data format in which the triples are serialized. If not provided, the default format is Turtle format.

ExecuteMsg::DeleteData

Delete the data (RDF triples) from the store matching the patterns defined by the provided query. For non-existing triples it acts as no-op.

Example: json { "prefixes": [ { "prefix": "foaf", "namespace": "http://xmlns.com/foaf/0.1/" } ], "delete": [ { "subject": { "variable": "s" }, "predicate": { "variable": "p" }, "object": { "variable": "o" } } ], "where": [ { "simple": { "triplePattern": { "subject": { "variable": "s" }, "predicate": { "node": { "namedNode": {"prefixed": "foaf:givenName"} } }, "object": { "literal": { "simple": "Myrddin" } } } } }, { "simple": { "triplePattern": { "subject": { "variable": "s" }, "predicate": { "variable": "p" }, "object": { "variable": "o" } } } } ]

Only the smart contract owner (i.e. the address who instantiated it) is authorized to perform this action.

parameterdescription
delete_data*(Required.) * object.
delete_data.delete*(Required.) * Array<TriplePattern>. The items to delete.
delete_data.prefixes*(Required.) * Array<Prefix>. The prefixes used in the operation.
delete_data.wherearray|null. The WHERE clause to apply. If not provided, all the RDF triples are considered.

QueryMsg

Query messages

QueryMsg::Store

Returns information about the triple store.

literal
"store"

QueryMsg::Select

Returns the resources matching the criteria defined by the provided query.

parameterdescription
select*(Required.) * object.
select.query*(Required.) * SelectQuery. The query to execute.

QueryMsg::Describe

Returns a description of the resource identified by the provided IRI as a set of RDF triples serialized in the provided format.

parameterdescription
describe*(Required.) * object.
describe.formatDataFormat|null. The format in which the triples are serialized. If not provided, the default format is Turtle format.
describe.query*(Required.) * DescribeQuery. The query to execute.

Responses

describe

Represents the response of a [QueryMsg::Describe] query.

propertydescription
data*(Required.) * Binary. The data serialized in the specified format.
format*(Required.) * DataFormat. The format of the data.

select

Represents the response of a [QueryMsg::Select] query.

propertydescription
head*(Required.) * Head. The head of the response, i.e. the set of variables mentioned in the results.
head.varsArray<string>. The variables selected in the query.
results*(Required.) * Results. The results of the select query.
results.bindingsArray<object>. The bindings of the results.

store

Contains information related to triple store.

propertydescription
limits*(Required.) * StoreLimits. The store limits.
limits.max_byte_sizeUint128. The maximum number of bytes the store can contains. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any.
limits.max_insert_data_byte_sizeUint128. The maximum number of bytes an insert data query can contains.
limits.max_insert_data_triple_countUint128. The maximum number of triples an insert data query can contains (after parsing).
limits.max_query_limitinteger. The maximum limit of a query, i.e. the maximum number of triples returned by a select query.
limits.max_query_variable_countinteger. The maximum number of variables a query can select.
limits.max_triple_byte_sizeUint128. The maximum number of bytes the store can contains for a single triple. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. The limit is used to prevent storing very large triples, especially literals.
limits.max_triple_countUint128. The maximum number of triples the store can contains.
owner*(Required.) * string. The store owner.
stat*(Required.) * StoreStat. The store current usage.
stat.byte_sizeUint128. The total triple size in the store, in bytes.
stat.namespace_countUint128. The total number of IRI namespace present in the store.
stat.triple_countUint128. The total number of triple present in the store.

Definitions

Binary

A string containing Base64-encoded data.

type
string.

BlankNode

An RDF blank node.

propertydescription
blank_node*(Required.) * string.

DataFormat

Represents the format in which the data are serialized, for example when returned by a query or when inserted in the store.

variantdescription
RDF XMLstring: rdf_xml. Output in RDF/XML format.
Turtlestring: turtle. Output in Turtle format.
N-Triplesstring: n_triples. Output in N-Triples format.
N-Quadsstring: n_quads. Output in N-Quads format.

DescribeQuery

Represents a DESCRIBE query over the triple store, allowing to retrieve a description of a resource as a set of triples serialized in a specific format.

propertydescription
prefixes*(Required.) * Array<Prefix>. The prefixes used in the query.
resource*(Required.) * VarOrNamedNode. The resource to describe given as a variable or a node.
where*(Required.) * Array<WhereCondition>. The WHERE clause. This clause is used to specify the resource identifier to describe using variable bindings.

Full

A full IRI.

propertydescription
full*(Required.) * string.

Represents the head of a [SelectResponse].

propertydescription
vars*(Required.) * Array<string>. The variables selected in the query.

IRI

Represents an IRI.

variantdescription
Prefixedobject. An IRI prefixed with a prefix. The prefixed IRI is expanded to a full IRI using the prefix definition specified in the query. For example, the prefixed IRI rdf:type is expanded to http://www.w3.org/1999/02/22-rdf-syntax-ns#type.
Fullobject. A full IRI.

LanguageTaggedString

A language-tagged string

propertydescription
language_tagged_string*(Required.) * object.
language_tagged_string.language*(Required.) * string. The language tag.
language_tagged_string.value*(Required.) * string. The lexical form.

Literal

An RDF literal.

variantdescription
Simpleobject. A simple literal without datatype or language form.
LanguageTaggedStringobject. A language-tagged string
TypedValueobject. A value with a datatype.

N-Quads

Output in N-Quads format.

literal
"n_quads"

N-Triples

Output in N-Triples format.

literal
"n_triples"

NamedNode

An RDF IRI.

propertydescription
named_node*(Required.) * Prefixed|Full.

Node

Represents either an IRI (named node) or a blank node.

variantdescription
NamedNodeobject. An RDF IRI.
BlankNodeobject. An RDF blank node.

Prefix

Represents a prefix in a [SelectQuery]. A prefix is a shortcut for a namespace used in the query.

propertydescription
namespace*(Required.) * string. The namespace associated with the prefix.
prefix*(Required.) * string. The prefix.

Prefixed

An IRI prefixed with a prefix. The prefixed IRI is expanded to a full IRI using the prefix definition specified in the query. For example, the prefixed IRI rdf:type is expanded to http://www.w3.org/1999/02/22-rdf-syntax-ns#type.

propertydescription
prefixed*(Required.) * string.

RDF XML

Output in RDF/XML format.

literal
"rdf_xml"

Results

Represents the results of a [SelectResponse].

propertydescription
bindings*(Required.) * Array<object>. The bindings of the results.

SelectItem

Represents an item to select in a [SelectQuery].

variantdescription
Variableobject. Represents a variable.

SelectQuery

Represents a SELECT query over the triple store, allowing to select variables to return and to filter the results.

propertydescription
limitinteger|null. The maximum number of results to return. If None, there is no limit. Note: the value of the limit cannot exceed the maximum query limit defined in the store limitations.
prefixes*(Required.) * Array<Prefix>. The prefixes used in the query.
select*(Required.) * Array<SelectItem>. The items to select. Note: the number of items to select cannot exceed the maximum query variable count defined in the store limitations.
where*(Required.) * Array<WhereCondition>. The WHERE clause. If None, there is no WHERE clause, i.e. all triples are returned without filtering.

Simple

A simple literal without datatype or language form.

propertydescription
simple*(Required.) * string.

SimpleWhereCondition

Represents a simple condition in a [WhereCondition].

variantdescription
TriplePatternobject. Represents a triple pattern, i.e. a condition on a triple based on its subject, predicate and object.

StoreLimits

Contains limitations regarding store usages.

propertydescription
max_byte_size*(Required.) * Uint128. The maximum number of bytes the store can contains. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any.
max_insert_data_byte_size*(Required.) * Uint128. The maximum number of bytes an insert data query can contains.
max_insert_data_triple_count*(Required.) * Uint128. The maximum number of triples an insert data query can contains (after parsing).
max_query_limit*(Required.) * integer. The maximum limit of a query, i.e. the maximum number of triples returned by a select query.
max_query_variable_count*(Required.) * integer. The maximum number of variables a query can select.
max_triple_byte_size*(Required.) * Uint128. The maximum number of bytes the store can contains for a single triple. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. The limit is used to prevent storing very large triples, especially literals.
max_triple_count*(Required.) * Uint128. The maximum number of triples the store can contains.

StoreLimitsInput

Contains requested limitations regarding store usages.

propertydescription
max_byte_sizeUint128. The maximum number of bytes the store can contains. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. Default to [Uint128::MAX] if not set, which can be considered as no limit.
max_insert_data_byte_sizeUint128. The maximum number of bytes an insert data query can contains. Default to [Uint128::MAX] if not set, which can be considered as no limit.
max_insert_data_triple_countUint128. The maximum number of triples an insert data query can contains (after parsing). Default to [Uint128::MAX] if not set, which can be considered as no limit.
max_query_limitinteger. The maximum limit of a query, i.e. the maximum number of triples returned by a select query. Default to 30 if not set.
max_query_variable_countinteger. The maximum number of variables a query can select. Default to 30 if not set.
max_triple_byte_sizeUint128. The maximum number of bytes the store can contains for a single triple. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. The limit is used to prevent storing very large triples, especially literals. Default to [Uint128::MAX] if not set, which can be considered as no limit.
max_triple_countUint128. The maximum number of triples the store can contains. Default to [Uint128::MAX] if not set, which can be considered as no limit.

StoreStat

Contains usage information about the triple store.

propertydescription
byte_size*(Required.) * Uint128. The total triple size in the store, in bytes.
namespace_count*(Required.) * Uint128. The total number of IRI namespace present in the store.
triple_count*(Required.) * Uint128. The total number of triple present in the store.

TriplePattern

Represents a triple pattern in a [SimpleWhereCondition].

propertydescription
object*(Required.) * VarOrNodeOrLiteral. The object of the triple pattern.
predicate*(Required.) * VarOrNode. The predicate of the triple pattern.
subject*(Required.) * VarOrNode. The subject of the triple pattern.

Turtle

Output in Turtle format.

literal
"turtle"

TypedValue

A value with a datatype.

propertydescription
typed_value*(Required.) * object.
typed_value.datatype*(Required.) * IRI. The datatype IRI.
typed_value.value*(Required.) * string. The lexical form.

URI

Represents an IRI.

propertydescription
type*(Required.) * string.
value*(Required.) * IRI. The value of the IRI.

Uint128

A string containing a 128-bit integer in decimal representation.

type
string.

Value

variantdescription
URIobject. Represents an IRI.
Literalobject. Represents a literal S with optional language tag L or datatype IRI D.
BlankNodeobject. Represents a blank node.

VarOrNamedNode

Represents either a variable or a named node (IRI).

variantdescription
Variableobject. A variable.
NamedNodeobject. An RDF IRI.

VarOrNode

Represents either a variable or a node.

variantdescription
Variableobject. A variable.
Nodeobject. A node, i.e. an IRI or a blank node.

VarOrNodeOrLiteral

Represents either a variable, a node or a literal.

variantdescription
Variableobject. A variable.
Nodeobject. A node, i.e. an IRI or a blank node.
Literalobject. An RDF literal, i.e. a simple literal, a language-tagged string or a typed value.

Variable

A variable.

propertydescription
variable*(Required.) * string.

WhereCondition

Represents a condition in a [WhereClause].

variantdescription
Simpleobject. Represents a simple condition.

Rendered by Fadroma (@fadroma/schema 1.1.0) from okp4-cognitarium.json (d3b06f180713c0ea)