use of org.apache.jena.hadoop.rdf.types.TripleWritable in project jena by apache.
the class TriplesToQuadsConstantGraphMapperTest 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(Quad.defaultGraphNodeGenerated, 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.TripleWritable in project jena by apache.
the class TurtleBlankNodeOutputTests method generateTuples.
@Override
protected Iterator<TripleWritable> generateTuples(int num) {
List<TripleWritable> ts = new ArrayList<TripleWritable>();
Node subject = NodeFactory.createBlankNode();
for (int i = 0; i < num; i++) {
Triple t = new Triple(subject, NodeFactory.createURI("http://example.org/predicate"), NodeFactory.createLiteral(Integer.toString(i), XSDDatatype.XSDinteger));
ts.add(new TripleWritable(t));
}
return ts.iterator();
}
use of org.apache.jena.hadoop.rdf.types.TripleWritable in project jena by apache.
the class HadoopRdfIORegistry method createTripleWriter.
/**
* Tries to create a triple writer for the given language
*
* @param lang
* Language
* @param writer
* Writer
* @param config
* Configuration
* @return Triple writer if one is available
* @throws IOException
* Thrown if a triple writer is not available or the given
* language does not support triple
*/
public static <TKey> RecordWriter<TKey, TripleWritable> createTripleWriter(Lang lang, Writer writer, Configuration config) throws IOException {
if (lang == null)
throw new IOException("Cannot create a triple writer for an undefined language");
WriterFactory f = writerFactories.get(lang);
if (f == null)
throw new IOException("No factory registered for language " + lang.getName());
if (!f.canWriteTriples())
throw new IOException(lang.getName() + " does not support writing triples");
RecordWriter<TKey, TripleWritable> rwriter = f.<TKey>createTripleWriter(writer, config);
if (rwriter == null)
throw new IOException("Registered factory for " + lang.getName() + " produced a null triples writer");
return rwriter;
}
use of org.apache.jena.hadoop.rdf.types.TripleWritable in project jena by apache.
the class HadoopRdfIORegistry method createTripleReader.
/**
* Tries to create a triple reader for the given language
*
* @param lang
* Language
* @return Triple reader if one is available
* @throws IOException
* Thrown if a triple reader is not available or the given
* language does not support triple
*/
public static RecordReader<LongWritable, TripleWritable> createTripleReader(Lang lang) throws IOException {
if (lang == null)
throw new IOException("Cannot create a triple 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.canReadTriples())
throw new IOException(lang.getName() + " does not support reading triples");
RecordReader<LongWritable, TripleWritable> reader = f.createTripleReader();
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.TripleWritable in project jena by apache.
the class TestDistinctTriples method distinct_triples_02.
@Test
public void distinct_triples_02() throws IOException {
MapReduceDriver<LongWritable, TripleWritable, TripleWritable, NullWritable, NullWritable, TripleWritable> driver = this.getMapReduceDriver();
Triple t = new Triple(NodeFactory.createURI("urn:s"), NodeFactory.createURI("urn:p"), NodeFactory.createLiteral("1"));
TripleWritable tw = new TripleWritable(t);
for (int i = 0; i < 100; i++) {
driver.addInput(new LongWritable(i), tw);
}
driver.addOutput(NullWritable.get(), tw);
driver.runTest();
}
Aggregations