use of org.apache.jena.hadoop.rdf.types.QuadWritable in project jena by apache.
the class HadoopRdfIORegistry method createQuadReader.
/**
* Tries to create a quad reader for the given language
*
* @param lang
* Language
* @return Quad reader if one is available
* @throws IOException
* Thrown if a quad reader is not available or the given
* language does not support quads
*/
public static RecordReader<LongWritable, QuadWritable> createQuadReader(Lang lang) throws IOException {
if (lang == null)
throw new IOException("Cannot create a quad reader for an undefined language");
ReaderFactory f = readerFactories.get(lang);
if (f == null)
throw new IOException("No factory registered for language " + lang.getName());
if (!f.canReadQuads())
throw new IOException(lang.getName() + " does not support reading quads");
RecordReader<LongWritable, QuadWritable> reader = f.createQuadReader();
if (reader == null)
throw new IOException("Registered factory for " + lang.getName() + " produced a null triples reader");
return reader;
}
use of org.apache.jena.hadoop.rdf.types.QuadWritable in project jena by apache.
the class QuadsToTriplesMapperTest method quads_to_triples_mapper_01.
/**
* Tests quads to triples conversion
*
* @throws IOException
*/
@Test
public void quads_to_triples_mapper_01() throws IOException {
MapDriver<LongWritable, QuadWritable, LongWritable, TripleWritable> driver = this.getMapDriver();
Triple t = new Triple(NodeFactory.createURI("http://s"), NodeFactory.createURI("http://p"), NodeFactory.createLiteral("test"));
Quad q = new Quad(Quad.defaultGraphNodeGenerated, t);
driver.withInput(new Pair<LongWritable, QuadWritable>(new LongWritable(1), new QuadWritable(q))).withOutput(new Pair<LongWritable, TripleWritable>(new LongWritable(1), new TripleWritable(t)));
driver.runTest();
}
use of org.apache.jena.hadoop.rdf.types.QuadWritable in project jena by apache.
the class TriplesToQuadsBySubjectMapperTest method generateData.
protected void generateData(MapDriver<LongWritable, TripleWritable, LongWritable, QuadWritable> driver, int num) {
for (int i = 0; i < num; i++) {
Triple t = new Triple(NodeFactory.createURI("http://subjects/" + i), NodeFactory.createURI("http://predicate"), NodeFactory.createLiteral(Integer.toString(i), XSDDatatype.XSDinteger));
Quad q = new Quad(t.getSubject(), t);
driver.addInput(new LongWritable(i), new TripleWritable(t));
driver.addOutput(new LongWritable(i), new QuadWritable(q));
}
}
use of org.apache.jena.hadoop.rdf.types.QuadWritable in project jena by apache.
the class TriplesToQuadsConstantGraphMapperTest method triples_to_quads_mapper_01.
/**
* Tests quads to triples conversion
*
* @throws IOException
*/
@Test
public void triples_to_quads_mapper_01() throws IOException {
MapDriver<LongWritable, TripleWritable, LongWritable, QuadWritable> driver = this.getMapDriver();
Triple t = new Triple(NodeFactory.createURI("http://s"), NodeFactory.createURI("http://p"), NodeFactory.createLiteral("test"));
Quad q = new Quad(Quad.defaultGraphNodeGenerated, t);
driver.withInput(new Pair<LongWritable, TripleWritable>(new LongWritable(1), new TripleWritable(t))).withOutput(new Pair<LongWritable, QuadWritable>(new LongWritable(1), new QuadWritable(q)));
driver.runTest();
}
use of org.apache.jena.hadoop.rdf.types.QuadWritable in project jena by apache.
the class QuadsToTriplesMapperTest method generateData.
protected void generateData(MapDriver<LongWritable, QuadWritable, LongWritable, TripleWritable> driver, int num) {
for (int i = 0; i < num; i++) {
Triple t = new Triple(NodeFactory.createURI("http://subjects/" + i), NodeFactory.createURI("http://predicate"), NodeFactory.createLiteral(Integer.toString(i), XSDDatatype.XSDinteger));
Quad q = new Quad(Quad.defaultGraphNodeGenerated, t);
driver.addInput(new LongWritable(i), new QuadWritable(q));
driver.addOutput(new LongWritable(i), new TripleWritable(t));
}
}
Aggregations