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 2014/11/12 15:35:31 UTC
[4/6] jena git commit: Add missing license headers
Add missing license headers
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/e57cd528
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/e57cd528
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/e57cd528
Branch: refs/heads/hadoop-rdf
Commit: e57cd52895034d74b5148e1996d595ae496d8c6b
Parents: 7eb0fdc
Author: Rob Vesse <rv...@apache.org>
Authored: Wed Nov 12 11:20:25 2014 +0000
Committer: Rob Vesse <rv...@apache.org>
Committed: Wed Nov 12 11:20:25 2014 +0000
----------------------------------------------------------------------
.../rdf/io/registry/HadoopRdfIORegistry.java | 27 +-
.../hadoop/rdf/io/registry/ReaderFactory.java | 18 +
.../hadoop/rdf/io/registry/WriterFactory.java | 18 +
.../readers/AbstractQuadsOnlyReaderFactory.java | 18 +
.../registry/readers/AbstractReaderFactory.java | 18 +
.../AbstractTriplesOnlyReaderFactory.java | 18 +
.../writers/AbstractQuadsOnlyWriterFactory.java | 18 +
.../AbstractTriplesOnlyWriterFactory.java | 17 +
.../registry/writers/AbstractWriterFactory.java | 18 +
.../AbstractNodeTupleOutputFormatTests.java | 463 ++++++++++---------
10 files changed, 399 insertions(+), 234 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/e57cd528/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 9e1f45f..7b04ef4 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
@@ -1,3 +1,21 @@
+/*
+ * 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;
@@ -20,9 +38,10 @@ 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 a file under
+ * {@link ServiceLoader} mechanism. This will look for files under
* {@code META-INF/services} named
- * {@code org.apache.jena.hadoop.rdf.io.registry.ReaderFactory} . This follows
+ * {@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>
@@ -252,7 +271,7 @@ public class HadoopRdfIORegistry {
if (!f.canWriteQuads())
throw new IOException(lang.getName() + " does not support writeing quads");
- RecordWriter<TKey, QuadWritable> rwriter = f.<TKey>createQuadWriter(writer, config);
+ 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;
@@ -283,7 +302,7 @@ public class HadoopRdfIORegistry {
if (!f.canWriteTriples())
throw new IOException(lang.getName() + " does not support writing triples");
- RecordWriter<TKey, TripleWritable> rwriter = f.<TKey>createTripleWriter(writer, config);
+ 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/e57cd528/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/ReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/ReaderFactory.java b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/ReaderFactory.java
index a925141..e1c98c7 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/ReaderFactory.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/ReaderFactory.java
@@ -1,3 +1,21 @@
+/*
+ * 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;
http://git-wip-us.apache.org/repos/asf/jena/blob/e57cd528/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 61568c1..db5635f 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,3 +1,21 @@
+/*
+ * 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;
http://git-wip-us.apache.org/repos/asf/jena/blob/e57cd528/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractQuadsOnlyReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractQuadsOnlyReaderFactory.java b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractQuadsOnlyReaderFactory.java
index 8902f2e..7fe15a9 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractQuadsOnlyReaderFactory.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractQuadsOnlyReaderFactory.java
@@ -1,3 +1,21 @@
+/*
+ * 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;
http://git-wip-us.apache.org/repos/asf/jena/blob/e57cd528/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractReaderFactory.java b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractReaderFactory.java
index fe00289..60e45af 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractReaderFactory.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractReaderFactory.java
@@ -1,3 +1,21 @@
+/*
+ * 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;
http://git-wip-us.apache.org/repos/asf/jena/blob/e57cd528/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractTriplesOnlyReaderFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractTriplesOnlyReaderFactory.java b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractTriplesOnlyReaderFactory.java
index d802123..7fb8131 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractTriplesOnlyReaderFactory.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/readers/AbstractTriplesOnlyReaderFactory.java
@@ -1,3 +1,21 @@
+/*
+ * 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;
http://git-wip-us.apache.org/repos/asf/jena/blob/e57cd528/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractQuadsOnlyWriterFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractQuadsOnlyWriterFactory.java b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractQuadsOnlyWriterFactory.java
index c685c60..0cf137e 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractQuadsOnlyWriterFactory.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractQuadsOnlyWriterFactory.java
@@ -1,3 +1,21 @@
+/*
+ * 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.writers;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/jena/blob/e57cd528/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractTriplesOnlyWriterFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractTriplesOnlyWriterFactory.java b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractTriplesOnlyWriterFactory.java
index 0cfd0fc..e45c3da 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractTriplesOnlyWriterFactory.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractTriplesOnlyWriterFactory.java
@@ -1,3 +1,20 @@
+/*
+ * 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.writers;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/jena/blob/e57cd528/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractWriterFactory.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractWriterFactory.java b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractWriterFactory.java
index fca0754..669b9c4 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractWriterFactory.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/main/java/org/apache/jena/hadoop/rdf/io/registry/writers/AbstractWriterFactory.java
@@ -1,3 +1,21 @@
+/*
+ * 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.writers;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/jena/blob/e57cd528/jena-hadoop-rdf/hadoop-rdf-io/src/test/java/org/apache/jena/hadoop/rdf/io/output/AbstractNodeTupleOutputFormatTests.java
----------------------------------------------------------------------
diff --git a/jena-hadoop-rdf/hadoop-rdf-io/src/test/java/org/apache/jena/hadoop/rdf/io/output/AbstractNodeTupleOutputFormatTests.java b/jena-hadoop-rdf/hadoop-rdf-io/src/test/java/org/apache/jena/hadoop/rdf/io/output/AbstractNodeTupleOutputFormatTests.java
index adbea48..b5ea2d8 100644
--- a/jena-hadoop-rdf/hadoop-rdf-io/src/test/java/org/apache/jena/hadoop/rdf/io/output/AbstractNodeTupleOutputFormatTests.java
+++ b/jena-hadoop-rdf/hadoop-rdf-io/src/test/java/org/apache/jena/hadoop/rdf/io/output/AbstractNodeTupleOutputFormatTests.java
@@ -16,237 +16,240 @@
* limitations under the License.
*/
-package org.apache.jena.hadoop.rdf.io.output;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Iterator;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.LocatedFileStatus;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.RemoteIterator;
-import org.apache.hadoop.io.NullWritable;
-import org.apache.hadoop.mapreduce.Job;
-import org.apache.hadoop.mapreduce.JobContext;
-import org.apache.hadoop.mapreduce.OutputFormat;
-import org.apache.hadoop.mapreduce.RecordWriter;
-import org.apache.hadoop.mapreduce.TaskAttemptContext;
-import org.apache.hadoop.mapreduce.TaskAttemptID;
-import org.apache.hadoop.mapreduce.TaskType;
-import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
-import org.apache.hadoop.mapreduce.task.JobContextImpl;
-import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
+package org.apache.jena.hadoop.rdf.io.output;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocatedFileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.JobContext;
+import org.apache.hadoop.mapreduce.OutputFormat;
+import org.apache.hadoop.mapreduce.RecordWriter;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.TaskAttemptID;
+import org.apache.hadoop.mapreduce.TaskType;
+import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
+import org.apache.hadoop.mapreduce.task.JobContextImpl;
+import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
import org.apache.jena.hadoop.rdf.types.AbstractNodeTupleWritable;
-import org.apache.jena.riot.Lang;
-import org.apache.jena.riot.RDFDataMgr;
-import org.apache.jena.riot.lang.StreamRDFCounting;
-import org.apache.jena.riot.system.StreamRDFLib;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Abstract node tuple output format tests
- *
- *
- * @param <TValue>
- * Tuple type
- * @param <T>
- * Writable tuple type
- *
- */
-public abstract class AbstractNodeTupleOutputFormatTests<TValue, T extends AbstractNodeTupleWritable<TValue>> {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(AbstractNodeTupleOutputFormatTests.class);
-
- protected static final int EMPTY_SIZE = 0, SMALL_SIZE = 100, LARGE_SIZE = 10000, VERY_LARGE_SIZE = 100000;
-
- /**
- * Temporary folder for the tests
- */
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
-
- /**
- * Prepares a fresh configuration
- *
- * @return Configuration
- */
- protected Configuration prepareConfiguration() {
- Configuration config = new Configuration(true);
- // Nothing else to do
- return config;
- }
-
- /**
- * Gets the extra file extension to add to the filenames
- *
- * @return File extension
- */
- protected abstract String getFileExtension();
-
- /**
- * Generates tuples to be output for testing
- *
- * @param num
- * Number of tuples to generate
- * @return Iterator of tuples
- */
- protected abstract Iterator<T> generateTuples(int num);
-
- /**
- * Counts tuples in the output file
- *
- * @param f
- * Output file
- * @return Tuple count
- */
- protected final long countTuples(File f) {
- StreamRDFCounting counter = StreamRDFLib.count();
- RDFDataMgr.parse(counter, f.getAbsolutePath(), this.getRdfLanguage(), null);
- return counter.count();
- }
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.riot.lang.StreamRDFCounting;
+import org.apache.jena.riot.system.StreamRDFLib;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Abstract node tuple output format tests
+ *
+ *
+ * @param <TValue>
+ * Tuple type
+ * @param <T>
+ * Writable tuple type
+ *
+ */
+public abstract class AbstractNodeTupleOutputFormatTests<TValue, T extends AbstractNodeTupleWritable<TValue>> {
+
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractNodeTupleOutputFormatTests.class);
+
+ protected static final int EMPTY_SIZE = 0, SMALL_SIZE = 100, LARGE_SIZE = 10000, VERY_LARGE_SIZE = 100000;
+
+ /**
+ * Temporary folder for the tests
+ */
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder();
+
+ /**
+ * Prepares a fresh configuration
+ *
+ * @return Configuration
+ */
+ protected Configuration prepareConfiguration() {
+ Configuration config = new Configuration(true);
+ // Nothing else to do
+ return config;
+ }
+
+ /**
+ * Gets the extra file extension to add to the filenames
+ *
+ * @return File extension
+ */
+ protected abstract String getFileExtension();
+
+ /**
+ * Generates tuples to be output for testing
+ *
+ * @param num
+ * Number of tuples to generate
+ * @return Iterator of tuples
+ */
+ protected abstract Iterator<T> generateTuples(int num);
+
+ /**
+ * Counts tuples in the output file
+ *
+ * @param f
+ * Output file
+ * @return Tuple count
+ */
+ protected final long countTuples(File f) {
+ StreamRDFCounting counter = StreamRDFLib.count();
+ RDFDataMgr.parse(counter, f.getAbsolutePath(), this.getRdfLanguage(), null);
+ return counter.count();
+ }
/**
* Checks that tuples are as expected
- * @param f File
- * @param expected Expected number of tuples
- */
- protected void checkTuples(File f, long expected) {
- Assert.assertEquals(expected, this.countTuples(f));
- }
-
- /**
- * Gets the RDF language of the produced output which is used to parse back
- * in the output to validate the correct amount of output was produced
- *
- * @return RDF language
- */
- protected abstract Lang getRdfLanguage();
-
- /**
- * Gets the output format to test
- *
- * @return Output format
- */
- protected abstract OutputFormat<NullWritable, T> getOutputFormat();
-
- /**
- * Adds an output path to the job configuration
- *
- * @param f
- * File
- * @param config
- * Configuration
- * @param job
- * Job
- * @throws IOException
- */
- protected void addOutputPath(File f, Configuration config, Job job) throws IOException {
- FileSystem fs = FileSystem.getLocal(config);
- Path outputPath = fs.makeQualified(new Path(f.getAbsolutePath()));
- FileOutputFormat.setOutputPath(job, outputPath);
- }
-
- protected File findOutputFile(File dir, JobContext context) throws FileNotFoundException, IOException {
- Path outputPath = FileOutputFormat.getOutputPath(context);
- RemoteIterator<LocatedFileStatus> files = outputPath.getFileSystem(context.getConfiguration()).listFiles(outputPath, true);
- while (files.hasNext()) {
- LocatedFileStatus status = files.next();
- if (status.isFile() && !status.getPath().getName().startsWith("_")) {
- return new File(status.getPath().toUri());
- }
- }
- return null;
- }
-
- /**
- * Tests output
- *
- * @param f
- * File to output to
- * @param num
- * Number of tuples to output
- * @throws IOException
- * @throws InterruptedException
- */
- protected final void testOutput(File f, int num) throws IOException, InterruptedException {
- // Prepare configuration
- Configuration config = this.prepareConfiguration();
-
- // Set up fake job
- OutputFormat<NullWritable, T> outputFormat = this.getOutputFormat();
- Job job = Job.getInstance(config);
- job.setOutputFormatClass(outputFormat.getClass());
- this.addOutputPath(f, job.getConfiguration(), job);
- JobContext context = new JobContextImpl(job.getConfiguration(), job.getJobID());
- Assert.assertNotNull(FileOutputFormat.getOutputPath(context));
-
- // Output the data
- TaskAttemptID id = new TaskAttemptID("outputTest", 1, TaskType.MAP, 1, 1);
- TaskAttemptContext taskContext = new TaskAttemptContextImpl(job.getConfiguration(), id);
- RecordWriter<NullWritable, T> writer = outputFormat.getRecordWriter(taskContext);
- Iterator<T> tuples = this.generateTuples(num);
- while (tuples.hasNext()) {
- writer.write(NullWritable.get(), tuples.next());
- }
- writer.close(taskContext);
-
- // Check output
- File outputFile = this.findOutputFile(this.folder.getRoot(), context);
- Assert.assertNotNull(outputFile);
- this.checkTuples(outputFile, num);
- }
-
- /**
- * Basic output tests
- *
- * @throws IOException
- * @throws InterruptedException
- */
- @Test
- public void output_01() throws IOException, InterruptedException {
- this.testOutput(this.folder.getRoot(), EMPTY_SIZE);
- }
-
- /**
- * Basic output tests
- *
- * @throws IOException
- * @throws InterruptedException
- */
- @Test
- public void output_02() throws IOException, InterruptedException {
- this.testOutput(this.folder.getRoot(), SMALL_SIZE);
- }
-
- /**
- * Basic output tests
- *
- * @throws IOException
- * @throws InterruptedException
- */
- @Test
- public void output_03() throws IOException, InterruptedException {
- this.testOutput(this.folder.getRoot(), LARGE_SIZE);
- }
-
- /**
- * Basic output tests
- *
- * @throws IOException
- * @throws InterruptedException
- */
- @Test
- public void output_04() throws IOException, InterruptedException {
- this.testOutput(this.folder.getRoot(), VERY_LARGE_SIZE);
- }
-}
+ *
+ * @param f
+ * File
+ * @param expected
+ * Expected number of tuples
+ */
+ protected void checkTuples(File f, long expected) {
+ Assert.assertEquals(expected, this.countTuples(f));
+ }
+
+ /**
+ * Gets the RDF language of the produced output which is used to parse back
+ * in the output to validate the correct amount of output was produced
+ *
+ * @return RDF language
+ */
+ protected abstract Lang getRdfLanguage();
+
+ /**
+ * Gets the output format to test
+ *
+ * @return Output format
+ */
+ protected abstract OutputFormat<NullWritable, T> getOutputFormat();
+
+ /**
+ * Adds an output path to the job configuration
+ *
+ * @param f
+ * File
+ * @param config
+ * Configuration
+ * @param job
+ * Job
+ * @throws IOException
+ */
+ protected void addOutputPath(File f, Configuration config, Job job) throws IOException {
+ FileSystem fs = FileSystem.getLocal(config);
+ Path outputPath = fs.makeQualified(new Path(f.getAbsolutePath()));
+ FileOutputFormat.setOutputPath(job, outputPath);
+ }
+
+ protected File findOutputFile(File dir, JobContext context) throws FileNotFoundException, IOException {
+ Path outputPath = FileOutputFormat.getOutputPath(context);
+ RemoteIterator<LocatedFileStatus> files = outputPath.getFileSystem(context.getConfiguration()).listFiles(
+ outputPath, true);
+ while (files.hasNext()) {
+ LocatedFileStatus status = files.next();
+ if (status.isFile() && !status.getPath().getName().startsWith("_")) {
+ return new File(status.getPath().toUri());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Tests output
+ *
+ * @param f
+ * File to output to
+ * @param num
+ * Number of tuples to output
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ protected final void testOutput(File f, int num) throws IOException, InterruptedException {
+ // Prepare configuration
+ Configuration config = this.prepareConfiguration();
+
+ // Set up fake job
+ OutputFormat<NullWritable, T> outputFormat = this.getOutputFormat();
+ Job job = Job.getInstance(config);
+ job.setOutputFormatClass(outputFormat.getClass());
+ this.addOutputPath(f, job.getConfiguration(), job);
+ JobContext context = new JobContextImpl(job.getConfiguration(), job.getJobID());
+ Assert.assertNotNull(FileOutputFormat.getOutputPath(context));
+
+ // Output the data
+ TaskAttemptID id = new TaskAttemptID("outputTest", 1, TaskType.MAP, 1, 1);
+ TaskAttemptContext taskContext = new TaskAttemptContextImpl(job.getConfiguration(), id);
+ RecordWriter<NullWritable, T> writer = outputFormat.getRecordWriter(taskContext);
+ Iterator<T> tuples = this.generateTuples(num);
+ while (tuples.hasNext()) {
+ writer.write(NullWritable.get(), tuples.next());
+ }
+ writer.close(taskContext);
+
+ // Check output
+ File outputFile = this.findOutputFile(this.folder.getRoot(), context);
+ Assert.assertNotNull(outputFile);
+ this.checkTuples(outputFile, num);
+ }
+
+ /**
+ * Basic output tests
+ *
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ @Test
+ public void output_01() throws IOException, InterruptedException {
+ this.testOutput(this.folder.getRoot(), EMPTY_SIZE);
+ }
+
+ /**
+ * Basic output tests
+ *
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ @Test
+ public void output_02() throws IOException, InterruptedException {
+ this.testOutput(this.folder.getRoot(), SMALL_SIZE);
+ }
+
+ /**
+ * Basic output tests
+ *
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ @Test
+ public void output_03() throws IOException, InterruptedException {
+ this.testOutput(this.folder.getRoot(), LARGE_SIZE);
+ }
+
+ /**
+ * Basic output tests
+ *
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ @Test
+ public void output_04() throws IOException, InterruptedException {
+ this.testOutput(this.folder.getRoot(), VERY_LARGE_SIZE);
+ }
+}