Transferable Graph
Revision as of 10:57, 18 May 2012 by Hannu Niemisto (talk | contribs)
Transferable Graph (.tg) is a statement container file. Transferable Graphs can be exported from and imported into graph databases.
The format uses Binary Container Format where content is encoded with the following datatype according to the Databoard Specification:
Format (graph:1)
type TransferableGraph1 = { resourceCount : Integer, extensions : Map(String, Variant), identities : Identity[], statements : Integer[], values : Value[] } 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.
- extensions
- Any additional data represented as variants and identified by string keys. Allows transferable graph contents extensibility without format changes. Extensions will most probably contain data that is somehow related to statement and value data that comes after it. Therefore it is better for streaming input to have it available earlier than the data itself.
- 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. Ifname
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.
Conversions
Conversion from version 0 to version graph:1. File:Tg0 tg1.jar Usage:
java -jar tg0_tg1.jar graph input.tg output.tg