[[rdf-io-format]]
RDF IO Format
-------------

//!http://www.w3.org/RDF/icons/rdf_w3c_icon.128!

*InputFormat*:{nbsp}`com.thinkaurelius.titan.hadoop.formats.edgelist.rdf.RDFInputFormat`

The http://en.wikipedia.org/wiki/Semantic_Web[Semantic Web] community is one of the original promoters of the graph as an approach to data modeling. Their efforts have led to the development of the http://www.w3.org/RDF/[RDF] data model. While there are many serialization formats for RDF, an http://www.w3.org/TR/2014/REC-rdf11-concepts-20140225/#section-rdf-graph[RDF graph] is composed of RDF triples, in which a subject is connected to an object by a predicate. For instance:

```text
<http://thinkaurelius.com#hercules> <http://thinkaurelius.com#father> <http://thinkaurelius.com#jupiter> .
```

In this way, RDF is an edge list data model. Titan-Hadoop, on the other hand, makes use of an http://en.wikipedia.org/wiki/Adjacency_list[adjacency list] in its representation. Therefore, for these two formats to interoperate, the `RDFInputFormat` provided by Titan-Hadoop contains a MapReduce job that converts an edge list into a adjacency list.

Conversion Parameters
~~~~~~~~~~~~~~~~~~~~~

RDF Format
^^^^^^^^^^

`titan.hadoop.input.conf.format`

There are numerous RDF serialization formats. Titan-Hadoop currently supports the following formats:

* rdf-xml (http://www.w3.org/TR/rdf-syntax-grammar/[RDF/XML])
* n-triples (http://www.w3.org/2001/sw/RDFCore/ntriples/[N-Triples])
* turtle (http://www.w3.org/TR/2012/WD-turtle-20120710/[Turtle])
* n3 (http://www.w3.org/TeamSubmission/n3/[Notation3])
* trix (http://sw.nokia.com/trix/[TriX])
* trig (http://wifo5-03.informatik.uni-mannheim.de/bizer/trig/[TriG])

*NOTE*: Titan-Hadoop makes use of `LineRecordReader` to read statements from an RDF file. If a line (`\n`) does not contain a complete legal RDF fragment, then an exception is thrown by the RDF parser.

Literal as Property
^^^^^^^^^^^^^^^^^^^

`titan.hadoop.input.conf.literal-as-property`

There are two types of triples to be aware of -- one in which the object is a URI or blank node, and one in which the object is a literal value. The two types of triples are exemplified below.

[source,text]
<http://thinkaurelius.com#hercules> <http://thinkaurelius.com#father> <http://thinkaurelius.com#jupiter> .
<http://thinkaurelius.com#hercules> <http://thinkaurelius.com#age> "32"^^<http://www.w3.org/2001/XMLSchema#int> .

If the above Titan-Hadoop config property is set to `true`, then the Hercules vertex has an age property with an integer value of 32.

Use Local Name
^^^^^^^^^^^^^^

`titan.hadoop.input.conf.use-localname`

The theoretically infinite RDF graph is embedded with the infinite address space of URIs. In many situations, the full URI is not desired and as such, if the above property is set to `true`, then

[source,text]
<http://thinkaurelius.com#hercules> <http://thinkaurelius.com#father> <http://thinkaurelius.com#jupiter> .

Generates vertices with name `hercules` and `jupiter` connected by a `father` edge.

As Properties
^^^^^^^^^^^^^

`titan.hadoop.input.conf.as-properties`

RDF is a triple data model -- there are no properties, only vertices and edges. In some situations, an object URI should be treated as a property of the vertex. For instance, when `http://www.w3.org/1999/02/22-rdf-syntax-ns#type` is specified in the `String` list of the property above, then the triple

[source,text]
<http://thinkaurelius.com#hercules> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://thinkaurelius.com#demigod>

yields a Hercules vertex with type-property demigod. A typical setting for this property is below.

[source,text]
titan.hadoop.input.conf.as-properties=http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://www.w3.org/2000/01/rdf-schema#label
