// Path: disambiguation-author/disambiguation-author-logic/src/main/java/pl/edu/icm/coansys/disambiguation/model/ContributorWithExtractedFeatures.java
// public class ContributorWithExtractedFeatures implements Serializable{
//     String docKey;
//     String contributorId;
//     Map<String,Collection<Integer>> metadata;
//     Integer surnameInt;
//     String surnameString;
//     boolean surnameNotNull;
// 
//     public ContributorWithExtractedFeatures(String docKey, String contributorId, Map<String, Collection<Integer>> metadata, Integer surnameInt, String surnameString, boolean surnameNotNull) {
//         this.docKey = docKey;
//         this.contributorId = contributorId;
//         this.metadata = metadata;
//         this.surnameInt = surnameInt;
//         this.surnameString = surnameString;
//         this.surnameNotNull = surnameNotNull;
//     }
// 
//     public String getDocKey() {
//         return docKey;
//     }
// 
//     public String getContributorId() {
//         return contributorId;
//     }
// 
//     public Map<String, Collection<Integer>> getMetadata() {
//         return metadata;
//     }
// 
//     public Integer getSurnameInt() {
//         return surnameInt;
//     }
// 
//     public String getSurnameString() {
//         return surnameString;
//     }
// 
//     public boolean isSurnameNotNull() {
//         return surnameNotNull;
//     }
//     
//     public Tuple asTuple(){
//         Object[] to = new Object[] { docKey, contributorId, surnameInt,
// 						hashMapToDataBag(), surnameString, isSurnameNotNull() };
// 		return  TupleFactory.getInstance()
// 						.newTuple(Arrays.asList(to));
//     }
//     
//     private HashMap<Object,DataBag> hashMapToDataBag(){
//         TupleFactory tf=TupleFactory.getInstance();
//         HashMap<Object,DataBag> ret=new HashMap<>();
//         for (Map.Entry<String,Collection<Integer>> entry:metadata.entrySet()){
//            DataBag db = new DefaultDataBag();
//            for (Integer i:entry.getValue()) {
//                db.add(tf.newTuple((Object) i));
//            }
//            ret.put(entry.getKey(), db);
//         }
//         return ret;
//         
//     }
//     
//     
// }


import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.pig.backend.executionengine.ExecException;
import org.apache.pig.data.Tuple;
import org.apache.pig.tools.pigstats.PigStatusReporter;
import org.slf4j.LoggerFactory;
import pl.edu.icm.coansys.commons.java.StackTraceExtractor;
import pl.edu.icm.coansys.disambiguation.model.ContributorWithExtractedFeatures;
    
        
        
        
    }
    
    
    
	@Override
	public Boolean exec(Tuple input) {
		// instance of reporter may change in each exec(...) run
		myreporter = PigStatusReporter.getInstance();
		
		if (input == null || input.size() == 0) {
			reportContrib(REPORTER_CONST.EMPTY);
			return false;
		}

		String cid = null, sname = null;
		Map<String, Object> featuresMap = null;

		try {
			cid = input.get(0).toString();
			sname = input.get(1).toString();
			featuresMap = (Map<String, Object>) input.get(2);
		} catch (ExecException e) {
			// Throwing an exception would cause the task to fail.
			logger.error("Caught exception processing input row:\n"
					+ StackTraceExtractor.getStackTrace(e));
			reportContrib(REPORTER_CONST.EMPTY);
// Path: disambiguation-author/disambiguation-author-logic/src/main/java/pl/edu/icm/coansys/disambiguation/model/ContributorWithExtractedFeatures.java
// public class ContributorWithExtractedFeatures implements Serializable{
//     String docKey;
//     String contributorId;
//     Map<String,Collection<Integer>> metadata;
//     Integer surnameInt;
//     String surnameString;
//     boolean surnameNotNull;
// 
//     public ContributorWithExtractedFeatures(String docKey, String contributorId, Map<String, Collection<Integer>> metadata, Integer surnameInt, String surnameString, boolean surnameNotNull) {
//         this.docKey = docKey;
//         this.contributorId = contributorId;
//         this.metadata = metadata;
//         this.surnameInt = surnameInt;
//         this.surnameString = surnameString;
//         this.surnameNotNull = surnameNotNull;
//     }
// 
//     public String getDocKey() {
//         return docKey;
//     }
// 
//     public String getContributorId() {
//         return contributorId;
//     }
// 
//     public Map<String, Collection<Integer>> getMetadata() {
//         return metadata;
//     }
// 
//     public Integer getSurnameInt() {
//         return surnameInt;
//     }
// 
//     public String getSurnameString() {
//         return surnameString;
//     }
// 
//     public boolean isSurnameNotNull() {
//         return surnameNotNull;
//     }
//     
//     public Tuple asTuple(){
//         Object[] to = new Object[] { docKey, contributorId, surnameInt,
// 						hashMapToDataBag(), surnameString, isSurnameNotNull() };
// 		return  TupleFactory.getInstance()
// 						.newTuple(Arrays.asList(to));
//     }
//     
//     private HashMap<Object,DataBag> hashMapToDataBag(){
//         TupleFactory tf=TupleFactory.getInstance();
//         HashMap<Object,DataBag> ret=new HashMap<>();
//         for (Map.Entry<String,Collection<Integer>> entry:metadata.entrySet()){
//            DataBag db = new DefaultDataBag();
//            for (Integer i:entry.getValue()) {
//                db.add(tf.newTuple((Object) i));
//            }
//            ret.put(entry.getKey(), db);
//         }
//         return ret;
//         
//     }
//     
//     
// }


// Path: disambiguation-author/disambiguation-author-logic/src/main/java/pl/edu/icm/coansys/disambiguation/author/pig/FeaturesCheck.java
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.pig.backend.executionengine.ExecException;
import org.apache.pig.data.Tuple;
import org.apache.pig.tools.pigstats.PigStatusReporter;
import org.slf4j.LoggerFactory;
import pl.edu.icm.coansys.commons.java.StackTraceExtractor;
import pl.edu.icm.coansys.disambiguation.model.ContributorWithExtractedFeatures;

    
        
        
        
    }
    
    
    
	@Override
	public Boolean exec(Tuple input) {
		// instance of reporter may change in each exec(...) run
		myreporter = PigStatusReporter.getInstance();
		
		if (input == null || input.size() == 0) {
			reportContrib(REPORTER_CONST.EMPTY);
			return false;
		}

		String cid = null, sname = null;
		Map<String, Object> featuresMap = null;

		try {
			cid = input.get(0).toString();
			sname = input.get(1).toString();
			featuresMap = (Map<String, Object>) input.get(2);
		} catch (ExecException e) {
			// Throwing an exception would cause the task to fail.
			logger.error("Caught exception processing input row:\n"
					+ StackTraceExtractor.getStackTrace(e));
			reportContrib(REPORTER_CONST.EMPTY);
			return false;