You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2015/01/05 16:07:15 UTC
[07/52] [abbrv] jena git commit: Rebrand to Jena Elephas per
community vote
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/AbstractWholeFileQuadWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/AbstractWholeFileQuadWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/AbstractWholeFileQuadWriter.java
new file mode 100644
index 0000000..5fc0024
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/AbstractWholeFileQuadWriter.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.riot.RDFWriterRegistry;
+
+import com.hp.hpl.jena.sparql.core.DatasetGraph;
+import com.hp.hpl.jena.sparql.core.DatasetGraphFactory;
+import com.hp.hpl.jena.sparql.core.Quad;
+
+/**
+ * An abstract record writer for whole file triple formats
+ *
+ *
+ *
+ * @param <TKey>
+ * Key type
+ */
+public abstract class AbstractWholeFileQuadWriter<TKey> extends AbstractWholeFileNodeTupleWriter<TKey, Quad, QuadWritable> {
+
+ private DatasetGraph g = DatasetGraphFactory.createMem();
+
+ protected AbstractWholeFileQuadWriter(Writer writer) {
+ super(writer);
+ }
+
+ @Override
+ protected final void add(QuadWritable value) {
+ this.g.add(value.get());
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ protected void writeOutput(Writer writer) {
+ RDFDataMgr.write(writer, this.g, RDFWriterRegistry.defaultSerialization(this.getRdfLanguage()));
+ }
+
+ /**
+ * Gets the RDF language to write the output in
+ *
+ * @return RDF language
+ */
+ protected abstract Lang getRdfLanguage();
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/AbstractWholeFileTripleWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/AbstractWholeFileTripleWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/AbstractWholeFileTripleWriter.java
new file mode 100644
index 0000000..bb26093
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/AbstractWholeFileTripleWriter.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFDataMgr;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.sparql.graph.GraphFactory;
+
+/**
+ * An abstract record writer for whole file triple formats
+ *
+ *
+ *
+ * @param <TKey>
+ * Key type
+ */
+public abstract class AbstractWholeFileTripleWriter<TKey> extends AbstractWholeFileNodeTupleWriter<TKey, Triple, TripleWritable> {
+
+ private Graph g = GraphFactory.createDefaultGraph();
+
+ protected AbstractWholeFileTripleWriter(Writer writer) {
+ super(writer);
+ }
+
+ @Override
+ protected final void add(TripleWritable value) {
+ this.g.add(value.get());
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ protected final void writeOutput(Writer writer) {
+ RDFDataMgr.write(writer, this.g, this.getRdfLanguage());
+ }
+
+ /**
+ * Gets the RDF language to write the output in
+ *
+ * @return RDF language
+ */
+ protected abstract Lang getRdfLanguage();
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/QuadsToTriplesWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/QuadsToTriplesWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/QuadsToTriplesWriter.java
new file mode 100644
index 0000000..e932e1f
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/QuadsToTriplesWriter.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.hadoop.rdf.io.output.writers;
+
+import java.io.IOException;
+
+import org.apache.hadoop.mapreduce.RecordWriter;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+
+/**
+ * A record writer that converts quads into triples by stripping off the graph
+ * field
+ *
+ * @param <TKey>
+ * Key type
+ */
+public class QuadsToTriplesWriter<TKey> extends RecordWriter<TKey, QuadWritable> {
+
+ private RecordWriter<TKey, TripleWritable> writer;
+
+ /**
+ * Creates a new writer
+ *
+ * @param tripleWriter
+ * Triple writer to use
+ */
+ public QuadsToTriplesWriter(RecordWriter<TKey, TripleWritable> tripleWriter) {
+ if (tripleWriter == null)
+ throw new NullPointerException("tripleWriter cannot be null");
+ this.writer = tripleWriter;
+ }
+
+ @Override
+ public void write(TKey key, QuadWritable value) throws IOException, InterruptedException {
+ this.writer.write(key, new TripleWritable(value.get().asTriple()));
+ }
+
+ @Override
+ public void close(TaskAttemptContext context) throws IOException, InterruptedException {
+ this.writer.close(context);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/StreamRdfQuadWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/StreamRdfQuadWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/StreamRdfQuadWriter.java
new file mode 100644
index 0000000..e9156d2
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/StreamRdfQuadWriter.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.riot.system.StreamRDF;
+
+import com.hp.hpl.jena.sparql.core.Quad;
+
+/**
+ * A writer for {@link StreamRDF} based quad writers
+ *
+ * @param <TKey>
+ * Key type
+ */
+public class StreamRdfQuadWriter<TKey> extends
+ AbstractStreamRdfNodeTupleWriter<TKey, Quad, QuadWritable> {
+
+ public StreamRdfQuadWriter(StreamRDF stream, Writer writer) {
+ super(stream, writer);
+ }
+
+ @Override
+ protected void sendOutput(TKey key, QuadWritable value, StreamRDF stream) {
+ stream.quad(value.get());
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/StreamRdfTripleWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/StreamRdfTripleWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/StreamRdfTripleWriter.java
new file mode 100644
index 0000000..174edf3
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/StreamRdfTripleWriter.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.system.StreamRDF;
+
+import com.hp.hpl.jena.graph.Triple;
+
+/**
+ * A writer for {@link StreamRDF} based triple writers
+ *
+ * @param <TKey>
+ * Key type
+ */
+public class StreamRdfTripleWriter<TKey> extends AbstractStreamRdfNodeTupleWriter<TKey, Triple, TripleWritable> {
+
+ public StreamRdfTripleWriter(StreamRDF stream, Writer writer) {
+ super(stream, writer);
+ }
+
+ @Override
+ protected void sendOutput(TKey key, TripleWritable value, StreamRDF stream) {
+ stream.triple(value.get());
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/jsonld/JsonLDQuadWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/jsonld/JsonLDQuadWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/jsonld/JsonLDQuadWriter.java
new file mode 100644
index 0000000..1b4b62f
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/jsonld/JsonLDQuadWriter.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers.jsonld;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.io.output.writers.AbstractWholeFileQuadWriter;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFLanguages;
+
+public class JsonLDQuadWriter<TKey> extends AbstractWholeFileQuadWriter<TKey> {
+
+ public JsonLDQuadWriter(Writer writer) {
+ super(writer);
+ }
+
+ @Override
+ protected Lang getRdfLanguage() {
+ return RDFLanguages.JSONLD;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/jsonld/JsonLDTripleWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/jsonld/JsonLDTripleWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/jsonld/JsonLDTripleWriter.java
new file mode 100644
index 0000000..8d2079d
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/jsonld/JsonLDTripleWriter.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers.jsonld;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.io.output.writers.AbstractWholeFileTripleWriter;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFLanguages;
+
+public class JsonLDTripleWriter<TKey> extends AbstractWholeFileTripleWriter<TKey> {
+
+ public JsonLDTripleWriter(Writer writer) {
+ super(writer);
+ }
+
+ @Override
+ protected Lang getRdfLanguage() {
+ return RDFLanguages.JSONLD;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/nquads/NQuadsWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/nquads/NQuadsWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/nquads/NQuadsWriter.java
new file mode 100644
index 0000000..8df606d
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/nquads/NQuadsWriter.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers.nquads;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.io.output.writers.AbstractLineBasedQuadWriter;
+import org.apache.jena.riot.out.CharSpace;
+import org.apache.jena.riot.out.NodeFormatterNT;
+
+/**
+ * A record writer for NQuads
+ *
+ *
+ *
+ * @param <TKey>
+ */
+public class NQuadsWriter<TKey> extends AbstractLineBasedQuadWriter<TKey> {
+
+ /**
+ * Creates a new writer
+ *
+ * @param writer
+ * Writer
+ */
+ public NQuadsWriter(Writer writer) {
+ super(writer, new NodeFormatterNT());
+ }
+
+ /**
+ * Creates a new writer using the given character space
+ *
+ * @param writer
+ * Writer
+ * @param charSpace
+ * Character space
+ */
+ public NQuadsWriter(Writer writer, CharSpace charSpace) {
+ super(writer, new NodeFormatterNT(charSpace));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/ntriples/NTriplesNodeWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/ntriples/NTriplesNodeWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/ntriples/NTriplesNodeWriter.java
new file mode 100644
index 0000000..6413f21
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/ntriples/NTriplesNodeWriter.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers.ntriples;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.io.output.writers.AbstractNodeWriter;
+import org.apache.jena.riot.out.CharSpace;
+import org.apache.jena.riot.out.NodeFormatterNT;
+
+/**
+ * A NTriples based node writer
+ *
+ *
+ *
+ * @param <TValue>
+ * Value type
+ */
+public class NTriplesNodeWriter<TValue> extends AbstractNodeWriter<TValue> {
+
+ /**
+ * Creates a new writer
+ *
+ * @param writer
+ * Writer
+ */
+ public NTriplesNodeWriter(Writer writer) {
+ super(writer);
+ }
+
+ /**
+ * Creates a new writer
+ *
+ * @param writer
+ * Writer
+ * @param charSpace
+ * Character space to use
+ */
+ public NTriplesNodeWriter(Writer writer, CharSpace charSpace) {
+ super(writer, new NodeFormatterNT(charSpace));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/ntriples/NTriplesWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/ntriples/NTriplesWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/ntriples/NTriplesWriter.java
new file mode 100644
index 0000000..2b3c0b4
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/ntriples/NTriplesWriter.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers.ntriples;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.io.output.writers.AbstractLineBasedTripleWriter;
+import org.apache.jena.riot.out.CharSpace;
+import org.apache.jena.riot.out.NodeFormatterNT;
+
+/**
+ * A record writer for NTriples
+ *
+ *
+ * @param <TKey>
+ * Key type
+ *
+ */
+public class NTriplesWriter<TKey> extends AbstractLineBasedTripleWriter<TKey> {
+
+ /**
+ * Creates a new writer
+ *
+ * @param writer
+ * Writer
+ */
+ public NTriplesWriter(Writer writer) {
+ super(writer, new NodeFormatterNT());
+ }
+
+ /**
+ * Creates a new writer using the given character space
+ *
+ * @param writer
+ * Writer
+ * @param charSpace
+ * Character space
+ */
+ public NTriplesWriter(Writer writer, CharSpace charSpace) {
+ super(writer, new NodeFormatterNT(charSpace));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/rdfjson/RdfJsonWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/rdfjson/RdfJsonWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/rdfjson/RdfJsonWriter.java
new file mode 100644
index 0000000..30bd4fa
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/rdfjson/RdfJsonWriter.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers.rdfjson;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.io.output.writers.AbstractWholeFileTripleWriter;
+import org.apache.jena.riot.Lang;
+
+/**
+ * A record writer for RDF/JSON
+ *
+ *
+ * @param <TKey>
+ * Key type
+ *
+ */
+public class RdfJsonWriter<TKey> extends AbstractWholeFileTripleWriter<TKey> {
+
+ /**
+ * Creates a new record writer
+ *
+ * @param writer
+ * Writer
+ */
+ public RdfJsonWriter(Writer writer) {
+ super(writer);
+ }
+
+ @Override
+ protected Lang getRdfLanguage() {
+ return Lang.RDFJSON;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/rdfxml/RdfXmlWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/rdfxml/RdfXmlWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/rdfxml/RdfXmlWriter.java
new file mode 100644
index 0000000..f202914
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/rdfxml/RdfXmlWriter.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers.rdfxml;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.io.output.writers.AbstractWholeFileTripleWriter;
+import org.apache.jena.riot.Lang;
+
+/**
+ * A record writer for RDF/XML
+ *
+ *
+ * @param <TKey>
+ * Key type
+ *
+ */
+public class RdfXmlWriter<TKey> extends AbstractWholeFileTripleWriter<TKey> {
+
+ /**
+ * Creates a new record writer
+ *
+ * @param writer
+ * Writer
+ */
+ public RdfXmlWriter(Writer writer) {
+ super(writer);
+ }
+
+ @Override
+ protected Lang getRdfLanguage() {
+ return Lang.RDFXML;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/thrift/ThriftQuadWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/thrift/ThriftQuadWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/thrift/ThriftQuadWriter.java
new file mode 100644
index 0000000..599dba9
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/thrift/ThriftQuadWriter.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers.thrift;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.io.output.writers.AbstractWholeFileQuadWriter;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFLanguages;
+
+public class ThriftQuadWriter<TKey> extends AbstractWholeFileQuadWriter<TKey> {
+
+ public ThriftQuadWriter(Writer writer) {
+ super(writer);
+ }
+
+ @Override
+ protected Lang getRdfLanguage() {
+ return RDFLanguages.THRIFT;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/thrift/ThriftTripleWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/thrift/ThriftTripleWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/thrift/ThriftTripleWriter.java
new file mode 100644
index 0000000..0089459
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/thrift/ThriftTripleWriter.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers.thrift;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.io.output.writers.AbstractWholeFileTripleWriter;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFLanguages;
+
+public class ThriftTripleWriter<TKey> extends AbstractWholeFileTripleWriter<TKey> {
+
+ public ThriftTripleWriter(Writer writer) {
+ super(writer);
+ }
+
+ @Override
+ protected Lang getRdfLanguage() {
+ return RDFLanguages.THRIFT;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/trig/BatchedTriGWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/trig/BatchedTriGWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/trig/BatchedTriGWriter.java
new file mode 100644
index 0000000..4c0c75f
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/trig/BatchedTriGWriter.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers.trig;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.io.output.writers.AbstractBatchedQuadWriter;
+import org.apache.jena.riot.Lang;
+
+/**
+ * A record writer for TriG that uses the batched approach, note that this
+ * approach will produce invalid data when blank nodes span batches
+ *
+ * @param <TKey>
+ * Key type
+ */
+public class BatchedTriGWriter<TKey> extends AbstractBatchedQuadWriter<TKey> {
+
+ /**
+ * Creates a new record writer
+ *
+ * @param writer
+ * Writer
+ * @param batchSize
+ * Batch size
+ */
+ public BatchedTriGWriter(Writer writer, long batchSize) {
+ super(writer, batchSize);
+ }
+
+ @Override
+ protected Lang getRdfLanguage() {
+ return Lang.TRIG;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/turtle/BatchedTurtleWriter.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/turtle/BatchedTurtleWriter.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/turtle/BatchedTurtleWriter.java
new file mode 100644
index 0000000..86ab2f9
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/writers/turtle/BatchedTurtleWriter.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.output.writers.turtle;
+
+import java.io.Writer;
+
+import org.apache.jena.hadoop.rdf.io.output.writers.AbstractBatchedTripleWriter;
+import org.apache.jena.riot.Lang;
+
+/**
+ * A record writer for Turtle that uses the batched approach, note that this
+ * approach will produce invalid data when blank nodes span batches
+ *
+ *
+ *
+ * @param <TKey>
+ */
+public class BatchedTurtleWriter<TKey> extends
+ AbstractBatchedTripleWriter<TKey> {
+
+ /**
+ * Creates a new record writer
+ *
+ * @param writer
+ * Writer
+ * @param batchSize
+ * Batch size
+ */
+ public BatchedTurtleWriter(Writer writer, long batchSize) {
+ super(writer, batchSize);
+ }
+
+ @Override
+ protected Lang getRdfLanguage() {
+ return Lang.TURTLE;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/HadoopRdfIORegistry.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/HadoopRdfIORegistry.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/HadoopRdfIORegistry.java
new file mode 100644
index 0000000..7b04ef4
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/HadoopRdfIORegistry.java
@@ -0,0 +1,310 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.registry;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.ServiceLoader;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.RecordWriter;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+
+/**
+ * A registry which is used by various classes to dynamically select record
+ * readers and writers based on a provided {@link Lang}
+ * <p>
+ * Readers and writers are dynamically discovered using the Java
+ * {@link ServiceLoader} mechanism. This will look for files under
+ * {@code META-INF/services} named
+ * {@code org.apache.jena.hadoop.rdf.io.registry.ReaderFactory} and
+ * {@code org.apache.jena.hadoop.rdf.io.registry.WriterFactory}. This follows
+ * the standard {@linkplain ServiceLoader} format of provided one class name per
+ * line which implements the relevant interface.
+ * </p>
+ *
+ */
+public class HadoopRdfIORegistry {
+
+ private static Map<Lang, ReaderFactory> readerFactories = new HashMap<>();
+ private static Map<Lang, WriterFactory> writerFactories = new HashMap<>();
+ private static boolean init = false;
+
+ static {
+ init();
+ }
+
+ private static synchronized void init() {
+ if (init)
+ return;
+
+ // Dynamically load and register reader factories
+ ServiceLoader<ReaderFactory> readerFactoryLoader = ServiceLoader.load(ReaderFactory.class);
+ Iterator<ReaderFactory> readerFactoryIterator = readerFactoryLoader.iterator();
+ while (readerFactoryIterator.hasNext()) {
+ ReaderFactory f = readerFactoryIterator.next();
+ addReaderFactory(f);
+ }
+
+ // Dynamically load and register writer factories
+ ServiceLoader<WriterFactory> writerFactoryLoader = ServiceLoader.load(WriterFactory.class);
+ Iterator<WriterFactory> writerFactoryIterator = writerFactoryLoader.iterator();
+ while (writerFactoryIterator.hasNext()) {
+ WriterFactory f = writerFactoryIterator.next();
+ addWriterFactory(f);
+ }
+
+ init = true;
+ }
+
+ /**
+ * Resets the registry to the default configuration
+ */
+ public static synchronized void reset() {
+ if (!init)
+ return;
+
+ init = false;
+ init();
+ }
+
+ /**
+ * Registers the reader factory for all the languages it declares itself as
+ * supporting
+ *
+ * @param f
+ * Reader factory
+ */
+ public static void addReaderFactory(ReaderFactory f) {
+ if (f == null)
+ throw new NullPointerException("Factory cannot be null");
+
+ readerFactories.put(f.getPrimaryLanguage(), f);
+ for (Lang altLang : f.getAlternativeLanguages()) {
+ readerFactories.put(altLang, f);
+ }
+ }
+
+ /**
+ * Registers the writer factory for all the languages it declares itself as
+ * supporting
+ *
+ * @param f
+ * Writer factory
+ */
+ public static void addWriterFactory(WriterFactory f) {
+ if (f == null)
+ throw new NullPointerException("Factory cannot be null");
+
+ writerFactories.put(f.getPrimaryLanguage(), f);
+ for (Lang altLang : f.getAlternativeLanguages()) {
+ writerFactories.put(altLang, f);
+ }
+ }
+
+ /**
+ * Gets whether there is a quad reader available for the given language
+ *
+ * @param lang
+ * Language
+ * @return True if available, false otherwise
+ */
+ public static boolean hasQuadReader(Lang lang) {
+ if (lang == null)
+ return false;
+
+ ReaderFactory f = readerFactories.get(lang);
+ if (f == null)
+ return false;
+ return f.canReadQuads();
+ }
+
+ /**
+ * Gets whether there is a triple reader available for the given language
+ *
+ * @param lang
+ * Language
+ * @return True if available, false otherwise
+ */
+ public static boolean hasTriplesReader(Lang lang) {
+ if (lang == null)
+ return false;
+
+ ReaderFactory f = readerFactories.get(lang);
+ if (f == null)
+ return false;
+ return f.canReadTriples();
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Gets whether there is a quad writer available for the given language
+ *
+ * @param lang
+ * Language
+ * @return True if available, false otherwise
+ */
+ public static boolean hasQuadWriter(Lang lang) {
+ if (lang == null)
+ return false;
+
+ WriterFactory f = writerFactories.get(lang);
+ if (f == null)
+ return false;
+ return f.canWriteQuads();
+ }
+
+ /**
+ * Gets whether there is a triple writer available for the given language
+ *
+ * @param lang
+ * Language
+ * @return True if available, false otherwise
+ */
+ public static boolean hasTriplesWriter(Lang lang) {
+ if (lang == null)
+ return false;
+
+ WriterFactory f = writerFactories.get(lang);
+ if (f == null)
+ return false;
+ return f.canWriteTriples();
+ }
+
+ /**
+ * Tries to create a quad writer for the given language
+ *
+ * @param lang
+ * Language
+ * @param writer
+ * Writer
+ * @param config
+ * Configuration
+ *
+ * @return Quad writer if one is available
+ * @throws IOException
+ * Thrown if a quad writer is not available or the given
+ * language does not support quads
+ */
+ public static <TKey> RecordWriter<TKey, QuadWritable> createQuadWriter(Lang lang, Writer writer,
+ Configuration config) throws IOException {
+ if (lang == null)
+ throw new IOException("Cannot create a quad 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.canWriteQuads())
+ throw new IOException(lang.getName() + " does not support writeing quads");
+
+ RecordWriter<TKey, QuadWritable> rwriter = f.<TKey> createQuadWriter(writer, config);
+ if (rwriter == null)
+ throw new IOException("Registered factory for " + lang.getName() + " produced a null triples writer");
+ return rwriter;
+ }
+
+ /**
+ * 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/ReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/ReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/ReaderFactory.java
new file mode 100644
index 0000000..e1c98c7
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/ReaderFactory.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.registry;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+
+/**
+ * Interface for reader factories
+ *
+ */
+public interface ReaderFactory {
+
+ /**
+ * Gets the primary language this factory produces readers for
+ *
+ * @return Primary language
+ */
+ public abstract Lang getPrimaryLanguage();
+
+ /**
+ * Gets the alternative languages this factory can produce readers for
+ *
+ * @return Alternative languages
+ */
+ public abstract Collection<Lang> getAlternativeLanguages();
+
+ /**
+ * Gets whether this factory can produce readers that are capable of reading
+ * quads
+ *
+ * @return True if quads can be read, false if not
+ */
+ public abstract boolean canReadQuads();
+
+ /**
+ * Gets whether this factory can produce readers that are capable of reading
+ * triples
+ *
+ * @return True if triples can be read, false if not
+ */
+ public abstract boolean canReadTriples();
+
+ /**
+ * Creates a quad reader
+ *
+ * @return Quad reader
+ * @throws IOException
+ * May be thrown if a quad reader cannot be created
+ */
+ public abstract RecordReader<LongWritable, QuadWritable> createQuadReader() throws IOException;
+
+ /**
+ * Creates a triples reader
+ *
+ * @return Triples reader
+ * @throws IOException
+ * May be thrown if a triple reader cannot be created
+ */
+ public abstract RecordReader<LongWritable, TripleWritable> createTripleReader() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/WriterFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/WriterFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/WriterFactory.java
new file mode 100644
index 0000000..db5635f
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/WriterFactory.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.registry;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Collection;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.mapreduce.RecordWriter;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+
+/**
+ * Interface for writer factories
+ *
+ */
+public interface WriterFactory {
+
+ /**
+ * Gets the primary language this factory produces writers for
+ *
+ * @return Primary language
+ */
+ public abstract Lang getPrimaryLanguage();
+
+ /**
+ * Gets the alternative languages this factory can produce writers for
+ *
+ * @return Alternative languages
+ */
+ public abstract Collection<Lang> getAlternativeLanguages();
+
+ /**
+ * Gets whether this factory can produce writers that are capable of reading
+ * quads
+ *
+ * @return True if quads can be read, false if not
+ */
+ public abstract boolean canWriteQuads();
+
+ /**
+ * Gets whether this factory can produce writers that are capable of reading
+ * triples
+ *
+ * @return True if triples can be read, false if not
+ */
+ public abstract boolean canWriteTriples();
+
+ /**
+ * Creates a quad writer
+ *
+ * @param writer
+ * Writer
+ * @param config
+ * Configuration
+ *
+ * @return Quad writer
+ * @throws IOException
+ * May be thrown if a quad writer cannot be created
+ */
+ public abstract <TKey> RecordWriter<TKey, QuadWritable> createQuadWriter(Writer writer, Configuration config)
+ throws IOException;
+
+ /**
+ * Creates a triples writer
+ *
+ * @param writer
+ * Writer
+ * @param config
+ * Configuration
+ *
+ * @return Triples writer
+ * @throws IOException
+ * May be thrown if a triple writer cannot be created
+ */
+ public abstract <TKey> RecordWriter<TKey, TripleWritable> createTripleWriter(Writer writer, Configuration config)
+ throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractQuadsOnlyReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractQuadsOnlyReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractQuadsOnlyReaderFactory.java
new file mode 100644
index 0000000..7fe15a9
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractQuadsOnlyReaderFactory.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.registry.ReaderFactory;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+
+/**
+ * Abstract reader factory for languages that only support quads
+ */
+public abstract class AbstractQuadsOnlyReaderFactory implements ReaderFactory {
+
+ private Lang lang;
+ private Collection<Lang> alternateLangs = Collections.unmodifiableList(Collections.<Lang>emptyList());
+
+ public AbstractQuadsOnlyReaderFactory(Lang lang) {
+ this(lang, (Collection<Lang>)null);
+ }
+
+ public AbstractQuadsOnlyReaderFactory(Lang lang, Lang...altLangs) {
+ this(lang, Arrays.asList(altLangs));
+ }
+
+ public AbstractQuadsOnlyReaderFactory(Lang lang, Collection<Lang> altLangs) {
+ this.lang = lang;
+ if (altLangs != null)
+ this.alternateLangs = Collections.unmodifiableCollection(altLangs);
+ }
+
+ @Override
+ public final Lang getPrimaryLanguage() {
+ return this.lang;
+ }
+
+ @Override
+ public final Collection<Lang> getAlternativeLanguages() {
+ return this.alternateLangs;
+ }
+
+ @Override
+ public final boolean canReadQuads() {
+ return true;
+ }
+
+ @Override
+ public final boolean canReadTriples() {
+ return false;
+ }
+
+ @Override
+ public abstract RecordReader<LongWritable, QuadWritable> createQuadReader() throws IOException;
+
+ @Override
+ public final RecordReader<LongWritable, TripleWritable> createTripleReader() throws IOException {
+ throw new IOException(this.lang.getName() + " does not support reading triples");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractReaderFactory.java
new file mode 100644
index 0000000..60e45af
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractReaderFactory.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.registry.ReaderFactory;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+
+/**
+ * Abstract reader factory for languages that support triples and quads
+ */
+public abstract class AbstractReaderFactory implements ReaderFactory {
+
+ private Lang lang;
+ private Collection<Lang> alternateLangs = Collections.unmodifiableList(Collections.<Lang>emptyList());
+
+ public AbstractReaderFactory(Lang lang) {
+ this(lang, (Collection<Lang>)null);
+ }
+
+ public AbstractReaderFactory(Lang lang, Lang...altLangs) {
+ this(lang, Arrays.asList(altLangs));
+ }
+
+ public AbstractReaderFactory(Lang lang, Collection<Lang> altLangs) {
+ this.lang = lang;
+ if (altLangs != null)
+ this.alternateLangs = Collections.unmodifiableCollection(altLangs);
+ }
+
+ @Override
+ public final Lang getPrimaryLanguage() {
+ return this.lang;
+ }
+
+ @Override
+ public final Collection<Lang> getAlternativeLanguages() {
+ return this.alternateLangs;
+ }
+
+ @Override
+ public final boolean canReadQuads() {
+ return true;
+ }
+
+ @Override
+ public final boolean canReadTriples() {
+ return true;
+ }
+
+ @Override
+ public abstract RecordReader<LongWritable, QuadWritable> createQuadReader() throws IOException;
+
+ @Override
+ public abstract RecordReader<LongWritable, TripleWritable> createTripleReader() throws IOException;
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractTriplesOnlyReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractTriplesOnlyReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractTriplesOnlyReaderFactory.java
new file mode 100644
index 0000000..7fb8131
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractTriplesOnlyReaderFactory.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.registry.ReaderFactory;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+
+/**
+ * Abstract reader factory for languages that only support triples
+ */
+public abstract class AbstractTriplesOnlyReaderFactory implements ReaderFactory {
+
+ private Lang lang;
+ private Collection<Lang> alternateLangs = Collections.unmodifiableList(Collections.<Lang>emptyList());
+
+ public AbstractTriplesOnlyReaderFactory(Lang lang) {
+ this(lang, (Collection<Lang>)null);
+ }
+
+ public AbstractTriplesOnlyReaderFactory(Lang lang, Lang...altLangs) {
+ this(lang, Arrays.asList(altLangs));
+ }
+
+ public AbstractTriplesOnlyReaderFactory(Lang lang, Collection<Lang> altLangs) {
+ this.lang = lang;
+ if (altLangs != null)
+ this.alternateLangs = Collections.unmodifiableCollection(altLangs);
+ }
+
+ @Override
+ public final Lang getPrimaryLanguage() {
+ return this.lang;
+ }
+
+ @Override
+ public final Collection<Lang> getAlternativeLanguages() {
+ return this.alternateLangs;
+ }
+
+ @Override
+ public final boolean canReadQuads() {
+ return false;
+ }
+
+ @Override
+ public final boolean canReadTriples() {
+ return true;
+ }
+
+ @Override
+ public final RecordReader<LongWritable, QuadWritable> createQuadReader() throws IOException {
+ throw new IOException(this.lang.getName() + " does not support reading quads");
+ }
+
+ @Override
+ public abstract RecordReader<LongWritable, TripleWritable> createTripleReader() throws IOException;
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/JsonLDReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/JsonLDReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/JsonLDReaderFactory.java
new file mode 100644
index 0000000..6b064a4
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/JsonLDReaderFactory.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.input.readers.jsonld.JsonLDQuadReader;
+import org.apache.jena.hadoop.rdf.io.input.readers.jsonld.JsonLDTripleReader;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+
+/**
+ *
+ */
+public class JsonLDReaderFactory extends AbstractReaderFactory {
+
+ public JsonLDReaderFactory() {
+ super(Lang.JSONLD);
+ }
+
+ @Override
+ public RecordReader<LongWritable, QuadWritable> createQuadReader() throws IOException {
+ return new JsonLDQuadReader();
+ }
+
+ @Override
+ public RecordReader<LongWritable, TripleWritable> createTripleReader() throws IOException {
+ return new JsonLDTripleReader();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/NQuadsReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/NQuadsReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/NQuadsReaderFactory.java
new file mode 100644
index 0000000..2296296
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/NQuadsReaderFactory.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.input.readers.nquads.WholeFileNQuadsReader;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.riot.Lang;
+
+/**
+ *
+ */
+public class NQuadsReaderFactory extends AbstractQuadsOnlyReaderFactory {
+
+ public NQuadsReaderFactory() {
+ super(Lang.NQUADS, Lang.NQ);
+ }
+
+ @Override
+ public RecordReader<LongWritable, QuadWritable> createQuadReader() throws IOException {
+ return new WholeFileNQuadsReader();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/NTriplesReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/NTriplesReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/NTriplesReaderFactory.java
new file mode 100644
index 0000000..a98a1ae
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/NTriplesReaderFactory.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.input.readers.ntriples.WholeFileNTriplesReader;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+
+public class NTriplesReaderFactory extends AbstractTriplesOnlyReaderFactory {
+
+ public NTriplesReaderFactory() {
+ super(Lang.NTRIPLES, Lang.NT);
+ }
+
+ @Override
+ public RecordReader<LongWritable, TripleWritable> createTripleReader() throws IOException {
+ return new WholeFileNTriplesReader();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/RdfJsonReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/RdfJsonReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/RdfJsonReaderFactory.java
new file mode 100644
index 0000000..ccf5feb
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/RdfJsonReaderFactory.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.input.readers.rdfjson.RdfJsonReader;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+
+/**
+ *
+ */
+public class RdfJsonReaderFactory extends AbstractTriplesOnlyReaderFactory {
+
+ public RdfJsonReaderFactory() {
+ super(Lang.RDFJSON);
+ }
+
+ @Override
+ public RecordReader<LongWritable, TripleWritable> createTripleReader() throws IOException {
+ return new RdfJsonReader();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/RdfXmlReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/RdfXmlReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/RdfXmlReaderFactory.java
new file mode 100644
index 0000000..1aa88d7
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/RdfXmlReaderFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.input.readers.rdfxml.RdfXmlReader;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+
+public class RdfXmlReaderFactory extends AbstractTriplesOnlyReaderFactory {
+
+ public RdfXmlReaderFactory() {
+ super(Lang.RDFXML);
+ }
+
+ @Override
+ public RecordReader<LongWritable, TripleWritable> createTripleReader() throws IOException {
+ return new RdfXmlReader();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/ThriftReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/ThriftReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/ThriftReaderFactory.java
new file mode 100644
index 0000000..25e8234
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/ThriftReaderFactory.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.input.readers.thrift.ThriftQuadReader;
+import org.apache.jena.hadoop.rdf.io.input.readers.thrift.ThriftTripleReader;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.RDFLanguages;
+
+/**
+ *
+ */
+public class ThriftReaderFactory extends AbstractReaderFactory {
+
+ public ThriftReaderFactory() {
+ super(RDFLanguages.THRIFT);
+ }
+
+ @Override
+ public RecordReader<LongWritable, QuadWritable> createQuadReader() throws IOException {
+ return new ThriftQuadReader();
+ }
+
+ @Override
+ public RecordReader<LongWritable, TripleWritable> createTripleReader() throws IOException {
+ return new ThriftTripleReader();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TriGReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TriGReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TriGReaderFactory.java
new file mode 100644
index 0000000..83ea818
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TriGReaderFactory.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.input.readers.trig.TriGReader;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.riot.Lang;
+
+/**
+ *
+ */
+public class TriGReaderFactory extends AbstractQuadsOnlyReaderFactory {
+
+ public TriGReaderFactory() {
+ super(Lang.TRIG);
+ }
+
+ @Override
+ public RecordReader<LongWritable, QuadWritable> createQuadReader() throws IOException {
+ return new TriGReader();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TriXReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TriXReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TriXReaderFactory.java
new file mode 100644
index 0000000..cb8795c
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TriXReaderFactory.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.input.readers.trix.TriXReader;
+import org.apache.jena.hadoop.rdf.types.QuadWritable;
+import org.apache.jena.riot.Lang;
+
+/**
+ *
+ */
+public class TriXReaderFactory extends AbstractQuadsOnlyReaderFactory {
+
+ public TriXReaderFactory() {
+ super(Lang.TRIX);
+ }
+
+ @Override
+ public RecordReader<LongWritable, QuadWritable> createQuadReader() throws IOException {
+ return new TriXReader();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TurtleReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TurtleReaderFactory.java b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TurtleReaderFactory.java
new file mode 100644
index 0000000..7800376
--- /dev/null
+++ b/jena-hadoop-rdf/jena-elephas-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/TurtleReaderFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.io.registry.readers;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.jena.hadoop.rdf.io.input.readers.turtle.TurtleReader;
+import org.apache.jena.hadoop.rdf.types.TripleWritable;
+import org.apache.jena.riot.Lang;
+
+public class TurtleReaderFactory extends AbstractTriplesOnlyReaderFactory {
+
+ public TurtleReaderFactory() {
+ super(Lang.TURTLE, Lang.TTL, Lang.N3);
+ }
+
+ @Override
+ public RecordReader<LongWritable, TripleWritable> createTripleReader() throws IOException {
+ return new TurtleReader();
+ }
+
+}