// Path: src/main/java/org/apache/jena/grande/Constants.java
// public class Constants {
// 
// 	public static final String RUN_ID = "runId";
// 
// 	public static final String OPTION_USE_COMPRESSION = "useCompression";
// 	public static final boolean OPTION_USE_COMPRESSION_DEFAULT = false;
// 
// 	public static final String OPTION_OVERWRITE_OUTPUT = "overwriteOutput";
// 	public static final boolean OPTION_OVERWRITE_OUTPUT_DEFAULT = false;
// 
// 	public static final String OPTION_RUN_LOCAL = "runLocal";
// 	public static final boolean OPTION_RUN_LOCAL_DEFAULT = false;
// 
// 	public static final String OPTION_NUM_REDUCERS = "numReducers";
// 	public static final int OPTION_NUM_REDUCERS_DEFAULT = 20;
// 	
// 	public static final String RDF_2_ADJACENCY_LIST = "rdf2adjacencylist";
// 
// 
// 	public static final PrefixMap defaultPrefixMap = new PrefixMap();
// 	static {
// 		defaultPrefixMap.add("rdf", RDF.getURI());
// 		defaultPrefixMap.add("rdfs", RDFS.getURI());
// 		defaultPrefixMap.add("owl", OWL.getURI());
// 		defaultPrefixMap.add("xsd", XSD.getURI());
// 		defaultPrefixMap.add("foaf", FOAF.getURI());
// 		defaultPrefixMap.add("dc", DC.getURI());
// 		defaultPrefixMap.add("dcterms", DCTerms.getURI());
// 		defaultPrefixMap.add("dctypes", DCTypes.getURI());
// 	}
// 
// 	// MapReduce counters
// 	
// 	public static final String JENA_GRANDE_COUNTER_GROUPNAME = "TDBLoader4 Counters";
// 	public static final String JENA_GRANDE_COUNTER_MALFORMED = "Malformed";
// 	public static final String JENA_GRANDE_COUNTER_QUADS = "Quads (including duplicates)";
// 	public static final String JENA_GRANDE_COUNTER_TRIPLES = "Triples (including duplicates)";
// 	public static final String JENA_GRANDE_COUNTER_DUPLICATES = "Duplicates (quads or triples)";
// 	public static final String JENA_GRANDE_COUNTER_RDFNODES = "RDF nodes";
// 	public static final String JENA_GRANDE_COUNTER_RECORDS = "Index records";
// 	
// 	// Event types
// 	
// 	public static EventType eventQuad = new EventType("quad");
// 	public static EventType eventTriple = new EventType("triple");
// 	public static EventType eventDuplicate = new EventType("duplicate");
// 	public static EventType eventMalformed = new EventType("malformed");
// 	public static EventType eventRdfNode = new EventType("RDF node");
// 	public static EventType eventRecord = new EventType("record");
// 	public static EventType eventTick = new EventType("tick");
// 	
// }
// 
// Path: src/main/java/cmd/rdf2adjacencylist.java
// public class rdf2adjacencylist extends Configured implements Tool {
//     
// 	@Override
// 	public int run(String[] args) throws Exception {
// 		if ( args.length != 2 ) {
// 			System.err.printf("Usage: %s [generic options] <input> <output>\n", getClass().getName());
// 			ToolRunner.printGenericCommandUsage(System.err);
// 			return -1;
// 		}
// 		
// 		Configuration configuration = getConf();
//         boolean overrideOutput = configuration.getBoolean(Constants.OPTION_OVERWRITE_OUTPUT, Constants.OPTION_OVERWRITE_OUTPUT_DEFAULT);
//         
//         FileSystem fs = FileSystem.get(new Path(args[1]).toUri(), configuration);
//         if ( overrideOutput ) {
//             fs.delete(new Path(args[1]), true);
//         }
// 		
//         Tool tool = new Rdf2AdjacencyListDriver(configuration);
//         tool.run(new String[] { args[0], args[1] });
// 
// 		return 0;
// 	}
// 	
// 	public static void main(String[] args) throws Exception {
// 		int exitCode = ToolRunner.run(new rdf2adjacencylist(), args);
// 		System.exit(exitCode);
// 	}
// 	
// }


import com.hp.hpl.jena.graph.Graph;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.FileManager;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.apache.hadoop.util.ToolRunner;
import org.apache.jena.grande.Constants;
import org.junit.Test;
import org.openjena.atlas.io.IO;
import org.openjena.riot.Lang;
import org.openjena.riot.RiotLoader;
import cmd.rdf2adjacencylist;
/*
 * 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.grande.mapreduce;





public class TestRdf2AdjacencyList {

	private static String output = "target/output" ;
	
    @Test public void test() throws Exception {
        String input = "src/test/resources/data2.nt" ;
        String[] args = new String[] {
                "-D", Constants.OPTION_OVERWRITE_OUTPUT + "=true", 
        		"-D", Constants.OPTION_RUN_LOCAL + "=true",
                input, 
                output
        };
        assertEquals ( 0, ToolRunner.run(new rdf2adjacencylist(), args) );

        FileManager fm = FileManager.get();
        Model m1 = fm.loadModel(input);
        Model m2 = null;
        String outputfile = output + "/part-r-00000";
        if ( Rdf2AdjacencyListReducer.useDefaultPrefixes ) {
        	StringBuilder sb = new StringBuilder();
// Path: src/main/java/org/apache/jena/grande/Constants.java
// public class Constants {
// 
// 	public static final String RUN_ID = "runId";
// 
// 	public static final String OPTION_USE_COMPRESSION = "useCompression";
// 	public static final boolean OPTION_USE_COMPRESSION_DEFAULT = false;
// 
// 	public static final String OPTION_OVERWRITE_OUTPUT = "overwriteOutput";
// 	public static final boolean OPTION_OVERWRITE_OUTPUT_DEFAULT = false;
// 
// 	public static final String OPTION_RUN_LOCAL = "runLocal";
// 	public static final boolean OPTION_RUN_LOCAL_DEFAULT = false;
// 
// 	public static final String OPTION_NUM_REDUCERS = "numReducers";
// 	public static final int OPTION_NUM_REDUCERS_DEFAULT = 20;
// 	
// 	public static final String RDF_2_ADJACENCY_LIST = "rdf2adjacencylist";
// 
// 
// 	public static final PrefixMap defaultPrefixMap = new PrefixMap();
// 	static {
// 		defaultPrefixMap.add("rdf", RDF.getURI());
// 		defaultPrefixMap.add("rdfs", RDFS.getURI());
// 		defaultPrefixMap.add("owl", OWL.getURI());
// 		defaultPrefixMap.add("xsd", XSD.getURI());
// 		defaultPrefixMap.add("foaf", FOAF.getURI());
// 		defaultPrefixMap.add("dc", DC.getURI());
// 		defaultPrefixMap.add("dcterms", DCTerms.getURI());
// 		defaultPrefixMap.add("dctypes", DCTypes.getURI());
// 	}
// 
// 	// MapReduce counters
// 	
// 	public static final String JENA_GRANDE_COUNTER_GROUPNAME = "TDBLoader4 Counters";
// 	public static final String JENA_GRANDE_COUNTER_MALFORMED = "Malformed";
// 	public static final String JENA_GRANDE_COUNTER_QUADS = "Quads (including duplicates)";
// 	public static final String JENA_GRANDE_COUNTER_TRIPLES = "Triples (including duplicates)";
// 	public static final String JENA_GRANDE_COUNTER_DUPLICATES = "Duplicates (quads or triples)";
// 	public static final String JENA_GRANDE_COUNTER_RDFNODES = "RDF nodes";
// 	public static final String JENA_GRANDE_COUNTER_RECORDS = "Index records";
// 	
// 	// Event types
// 	
// 	public static EventType eventQuad = new EventType("quad");
// 	public static EventType eventTriple = new EventType("triple");
// 	public static EventType eventDuplicate = new EventType("duplicate");
// 	public static EventType eventMalformed = new EventType("malformed");
// 	public static EventType eventRdfNode = new EventType("RDF node");
// 	public static EventType eventRecord = new EventType("record");
// 	public static EventType eventTick = new EventType("tick");
// 	
// }
// 
// Path: src/main/java/cmd/rdf2adjacencylist.java
// public class rdf2adjacencylist extends Configured implements Tool {
//     
// 	@Override
// 	public int run(String[] args) throws Exception {
// 		if ( args.length != 2 ) {
// 			System.err.printf("Usage: %s [generic options] <input> <output>\n", getClass().getName());
// 			ToolRunner.printGenericCommandUsage(System.err);
// 			return -1;
// 		}
// 		
// 		Configuration configuration = getConf();
//         boolean overrideOutput = configuration.getBoolean(Constants.OPTION_OVERWRITE_OUTPUT, Constants.OPTION_OVERWRITE_OUTPUT_DEFAULT);
//         
//         FileSystem fs = FileSystem.get(new Path(args[1]).toUri(), configuration);
//         if ( overrideOutput ) {
//             fs.delete(new Path(args[1]), true);
//         }
// 		
//         Tool tool = new Rdf2AdjacencyListDriver(configuration);
//         tool.run(new String[] { args[0], args[1] });
// 
// 		return 0;
// 	}
// 	
// 	public static void main(String[] args) throws Exception {
// 		int exitCode = ToolRunner.run(new rdf2adjacencylist(), args);
// 		System.exit(exitCode);
// 	}
// 	
// }


// Path: src/test/java/org/apache/jena/grande/mapreduce/TestRdf2AdjacencyList.java
import com.hp.hpl.jena.graph.Graph;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.FileManager;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.apache.hadoop.util.ToolRunner;
import org.apache.jena.grande.Constants;
import org.junit.Test;
import org.openjena.atlas.io.IO;
import org.openjena.riot.Lang;
import org.openjena.riot.RiotLoader;
import cmd.rdf2adjacencylist;

/*
 * 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.grande.mapreduce;





public class TestRdf2AdjacencyList {

	private static String output = "target/output" ;
	
    @Test public void test() throws Exception {
        String input = "src/test/resources/data2.nt" ;
        String[] args = new String[] {
                "-D", Constants.OPTION_OVERWRITE_OUTPUT + "=true", 
        		"-D", Constants.OPTION_RUN_LOCAL + "=true",
                input, 
                output
        };
        assertEquals ( 0, ToolRunner.run(new rdf2adjacencylist(), args) );

        FileManager fm = FileManager.get();
        Model m1 = fm.loadModel(input);
        Model m2 = null;
        String outputfile = output + "/part-r-00000";
        if ( Rdf2AdjacencyListReducer.useDefaultPrefixes ) {
        	StringBuilder sb = new StringBuilder();
        	for ( String prefix : Constants.defaultPrefixMap.getMapping().keySet() ) {