jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rve...@apache.org
Subject [2/6] jena git commit: Make WriterFactory interface more generic
Date Wed, 12 Nov 2014 14:35:29 GMT
Make WriterFactory interface more generic

The WriterFactory interface needs to be more generic than the
ReaderFactory interface because writers need to cope with arbitrary keys
(even if they will be ignoring them)


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/e7bec7ba
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/e7bec7ba
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/e7bec7ba

Branch: refs/heads/hadoop-rdf
Commit: e7bec7baefc2df920582bfbb8e183852e8a3ab7f
Parents: c429c8c
Author: Rob Vesse <rvesse@apache.org>
Authored: Tue Nov 11 16:02:24 2014 +0000
Committer: Rob Vesse <rvesse@apache.org>
Committed: Tue Nov 11 16:02:24 2014 +0000

----------------------------------------------------------------------
 .../AbstractStreamRdfNodeTupleOutputFormat.java | 62 +++++++++-----------
 .../io/output/turtle/TurtleOutputFormat.java    |  2 -
 .../rdf/io/registry/HadoopRdfIORegistry.java    |  5 +-
 .../hadoop/rdf/io/registry/WriterFactory.java   | 25 ++++++--
 4 files changed, 50 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/e7bec7ba/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/AbstractStreamRdfNodeTupleOutputFormat.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/AbstractStreamRdfNodeTupleOutputFormat.java
b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/AbstractStreamRdfNodeTupleOutputFormat.java
index 5599694..97027f5 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/AbstractStreamRdfNodeTupleOutputFormat.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/AbstractStreamRdfNodeTupleOutputFormat.java
@@ -29,8 +29,6 @@ import org.apache.jena.riot.system.StreamRDF;
  * Abstract output format for formats that use the RIOT {@link StreamRDF} API to
  * stream the writes
  * 
- * 
- * 
  * @param <TKey>
  *            Key type
  * @param <TTuple>
@@ -39,38 +37,36 @@ import org.apache.jena.riot.system.StreamRDF;
  *            Writable tuple type i.e. the value type
  */
 public abstract class AbstractStreamRdfNodeTupleOutputFormat<TKey, TTuple, TValue extends
AbstractNodeTupleWritable<TTuple>>
-		extends AbstractNodeTupleOutputFormat<TKey, TTuple, TValue> {
+        extends AbstractNodeTupleOutputFormat<TKey, TTuple, TValue> {
 
-	@Override
-	protected RecordWriter<TKey, TValue> getRecordWriter(Writer writer,
-			Configuration config) {
-		return getRecordWriter(getStream(writer, config), writer, config);
-	}
+    @Override
+    protected RecordWriter<TKey, TValue> getRecordWriter(Writer writer, Configuration
config) {
+        return getRecordWriter(getStream(writer, config), writer, config);
+    }
 
-	/**
-	 * Gets a writer which provides a bridge between the {@link RecordWriter}
-	 * and {@link StreamRDF} APIs
-	 * 
-	 * @param stream
-	 *            RDF Stream
-	 * @param writer
-	 *            Writer
-	 * @param config
-	 *            Configuration
-	 * @return Record Writer
-	 */
-	protected abstract RecordWriter<TKey, TValue> getRecordWriter(
-			StreamRDF stream, Writer writer, Configuration config);
+    /**
+     * Gets a writer which provides a bridge between the {@link RecordWriter}
+     * and {@link StreamRDF} APIs
+     * 
+     * @param stream
+     *            RDF Stream
+     * @param writer
+     *            Writer
+     * @param config
+     *            Configuration
+     * @return Record Writer
+     */
+    protected abstract RecordWriter<TKey, TValue> getRecordWriter(StreamRDF stream,
Writer writer, Configuration config);
 
-	/**
-	 * Gets a {@link StreamRDF} to which the tuples to be output should be
-	 * passed
-	 * 
-	 * @param writer
-	 *            Writer
-	 * @param config
-	 *            Configuration
-	 * @return RDF Stream
-	 */
-	protected abstract StreamRDF getStream(Writer writer, Configuration config);
+    /**
+     * Gets a {@link StreamRDF} to which the tuples to be output should be
+     * passed
+     * 
+     * @param writer
+     *            Writer
+     * @param config
+     *            Configuration
+     * @return RDF Stream
+     */
+    protected abstract StreamRDF getStream(Writer writer, Configuration config);
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/e7bec7ba/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/turtle/TurtleOutputFormat.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/turtle/TurtleOutputFormat.java
b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/turtle/TurtleOutputFormat.java
index 577a3db..c0202d8 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/turtle/TurtleOutputFormat.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/output/turtle/TurtleOutputFormat.java
@@ -33,8 +33,6 @@ import com.hp.hpl.jena.graph.Triple;
 /**
  * Turtle output format
  * 
- * 
- * 
  * @param <TKey>
  *            Key type
  */

http://git-wip-us.apache.org/repos/asf/jena/blob/e7bec7ba/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/HadoopRdfIORegistry.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/HadoopRdfIORegistry.java
b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/HadoopRdfIORegistry.java
index af7c486..eb45161 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/HadoopRdfIORegistry.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/HadoopRdfIORegistry.java
@@ -17,10 +17,9 @@ import org.apache.jena.riot.Lang;
  * 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
+ * {@link ServiceLoader} mechanism. This will look for a file 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}. These follow
+ * {@code org.apache.jena.hadoop.rdf.io.registry.ReaderFactory} . This follows
  * the standard {@linkplain ServiceLoader} format of provided one class name per
  * line which implements the relevant interface.
  * </p>

http://git-wip-us.apache.org/repos/asf/jena/blob/e7bec7ba/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/WriterFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/WriterFactory.java
b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/WriterFactory.java
index 9e21eb5..61568c1 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/WriterFactory.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/WriterFactory.java
@@ -1,9 +1,10 @@
 package org.apache.jena.hadoop.rdf.io.registry;
 
 import java.io.IOException;
+import java.io.Writer;
 import java.util.Collection;
 
-import org.apache.hadoop.io.LongWritable;
+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;
@@ -30,10 +31,10 @@ public interface WriterFactory {
     public abstract Collection<Lang> getAlternativeLanguages();
 
     /**
-     * Gets whether this factory can produce writer that are capable of reading
+     * Gets whether this factory can produce writers that are capable of reading
      * quads
      * 
-     * @return True if quads can be written, false if not
+     * @return True if quads can be read, false if not
      */
     public abstract boolean canWriteQuads();
 
@@ -41,25 +42,37 @@ public interface WriterFactory {
      * Gets whether this factory can produce writers that are capable of reading
      * triples
      * 
-     * @return True if triples can be written, false if not
+     * @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 RecordWriter<LongWritable, QuadWritable> createQuadWriter() throws
IOException;
+    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 RecordWriter<LongWritable, TripleWritable> createTripleWriter()
throws IOException;
+    public abstract <TKey> RecordWriter<TKey, TripleWritable> createTripleWriter(Writer
writer, Configuration config)
+            throws IOException;
 }


Mime
View raw message