Difference between revisions of "Transferable Graph"

From Developer Documents
Jump to navigation Jump to search
Line 40: Line 40:
 
: Contains all new statements that the transferable graph defines. The length of the array is 4*resourceCount. The array has for every statement its subject, predicate, inverse of the predicate and object in this order. If the statement does not have an inverse (that is different from itself), the inverse is -1.
 
: Contains all new statements that the transferable graph defines. The length of the array is 4*resourceCount. The array has for every statement its subject, predicate, inverse of the predicate and object in this order. If the statement does not have an inverse (that is different from itself), the inverse is -1.
 
; values
 
; values
: Assigns values to all literals in the transferable graph.
+
: Assigns values to all literals in the transferable graph. Literals are represented as variants.
 
; extensions
 
; extensions
 
: Any additional data represented as variants and identified by string keys. Allows transferable graph contents extensibility without format changes.
 
: Any additional data represented as variants and identified by string keys. Allows transferable graph contents extensibility without format changes.

Revision as of 09:00, 8 March 2012

Transferable Graph (.tg) is a statement container file. Transferable Graphs can be exported from and imported into graph databases.

Format

The format is defined as a binary serialization of the following datatype according to the Databoard Specification:

union TransferableGraph = TransferableGraph1

type TransferableGraph1 = {
    resourceCount : Integer,
    identities : Identity[],    
    statements : Integer[],
    values : Value[],
    extensions : Map(String, Variant)
}

type Identity {
    resource : Integer,
    definition : IdentityDefinition
}

type IdentityDefinition = 
    | Root { name : String, type : String }
    | External { parent : Resource, name : String }     
    | Optional { parent : Resource, name : String }
    | Internal { parent : Resource, name : String }

type Value = { 
    resource : Integer, 
    value : Variant
}

Each resource in a transferable graph is referred with a 32-bit integer beginning with zero.

resourceCount
Tells how many resources are used in the file. Some resources may already exist in the database, some will be new.
identities
Tells how to find the resources that should already exist in the database. Also the new resources with URI are given an identity so that it easier to refer to them when the graphs are compiled separately. The identities have to be ordered so that if the identity refers to another resource, its identity is already given.
  • Root defines a resource as a root. If name is "", the resource is the root library of the database. Other roots are interpreted in application specific ways.
  • External tells that a resource is a child of some other resource and should already exist in the database.
  • Optional tells that a resource is a child of some other resource. It may exist or not exist already in the database. In the latter case, it is created.
  • Internal tells that a resource is a child of some other resource. It may not yet exist in the database for the import to be successful.
statements
Contains all new statements that the transferable graph defines. The length of the array is 4*resourceCount. The array has for every statement its subject, predicate, inverse of the predicate and object in this order. If the statement does not have an inverse (that is different from itself), the inverse is -1.
values
Assigns values to all literals in the transferable graph. Literals are represented as variants.
extensions
Any additional data represented as variants and identified by string keys. Allows transferable graph contents extensibility without format changes.