// Path: src/main/java/nl/vu/datalayer/hbase/connection/HBaseConnection.java
// public abstract class HBaseConnection {
// 
// 	public static final byte NATIVE_JAVA = 0;
// 	public static final byte REST = 1;
// 	
// 	public static HBaseConnection create(byte connectionType) throws IOException{
// 		switch (connectionType){
// 		case NATIVE_JAVA: {	
// 			return new NativeJavaConnection();
// 		}
// 		case REST:{
// 			return new RESTConnection();
// 		}
// 		default:
// 			throw new RuntimeException("Unknow HBase connection type");
// 		}
// 	}
// 	
// 	public abstract HTableInterface getTable(String tableName) throws IOException;
// 	
// 	public void close() throws IOException{}
// }
// 
// Path: src/main/java/nl/vu/datalayer/hbase/connection/NativeJavaConnection.java
// public class NativeJavaConnection extends HBaseConnection {
// 	
// 	protected HBaseAdmin hbase = null;
// 	protected Configuration conf = null;
// 	private HTablePool tablePool = null;
// 	
// 	public static final int MAX_POOL_SIZE = 20;
// 	
// 	public NativeJavaConnection() throws MasterNotRunningException, ZooKeeperConnectionException{
// 		//add the "hbase-site.xml" file to the classpath to get the bootstrapping Zookeeper nodes
// 		conf = HBaseConfiguration.create();
// 		tablePool = new HTablePool(conf, MAX_POOL_SIZE, PoolMap.PoolType.Reusable);
// 		hbase = new HBaseAdmin(conf);
// 	}
// 	
// 	public void initTables(String []tableNames) throws IOException{
// 		int iterations = MAX_POOL_SIZE/tableNames.length;
// 		HTable [][]tables = new HTable[iterations][];
// 		
// 		//open tables
// 		for (int i = 0; i < iterations; i++) {
// 			tables[i] = new HTable[tableNames.length];
// 			for (int j = 0; j < tableNames.length; j++) {
// 				if (hbase.tableExists(tableNames[j])){
// 					tables[i][j] = (HTable)tablePool.getTable(tableNames[j]);
// 					tables[i][j].prewarmRegionCache(tables[i][j].getRegionsInfo());
// 				}
// 				else{ 
// 					tables[i][j] = null;
// 				}
// 			}
// 		}
// 		
// 		//close tables
// 		for (int i = 0; i < tables.length; i++) {
// 			for (int j = 0; j < tableNames.length; j++) {
// 				if (tables[i][j]!=null){
// 					tables[i][j].close();
// 				}
// 			}
// 		}
// 	}
// 	
// 	public HTableInterface getTable(String tableName) throws IOException{
// 		return tablePool.getTable(tableName);
// 	}
// 	
// 	public HTableInterface getTable(byte [] tableNameBytes) throws IOException{
// 		return tablePool.getTable(tableNameBytes);
// 	}
// 	
// 	public void close() throws IOException{
// 		hbase.close();
// 		tablePool.close();
// 	}
// 	
// 	public HBaseAdmin getAdmin() {
// 		return hbase;
// 	}
// 	
// 	public Configuration getConfiguration() {
// 		return conf;
// 	}
// 
// }


import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import nl.vu.datalayer.hbase.connection.HBaseConnection;
import nl.vu.datalayer.hbase.connection.NativeJavaConnection;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.openrdf.model.Resource;
import org.openrdf.model.Statement;
	    HBaseAdmin hbase = con.getAdmin();
	    if (hbase.tableExists("predicates") == false) {
	    	desc = new HTableDescriptor("predicates");
	    }
	    else {
		     desc = hbase.getTableDescriptor("predicates".getBytes());
	    }
	    
	    HColumnDescriptor c = new HColumnDescriptor("URI".getBytes());
	    desc.addFamily(c);

	    if (hbase.tableExists("predicates") == false) {
	    	hbase.createTable(desc);
	    }
	}
	
	private void createTableStruct(String table, ArrayList<String> columns)  throws IOException {

	    HTableDescriptor desc;
	    HBaseAdmin hbase = con.getAdmin();
	    if (hbase.tableExists(table) == false) {
	    	desc = new HTableDescriptor(table);
	    	HColumnDescriptor literal = new HColumnDescriptor("literal".getBytes());
	    	desc.addFamily(literal);
	    }
	    else {
		     desc = hbase.getTableDescriptor(table.getBytes());
	    }
	    
		for (Iterator<String> iter = columns.iterator(); iter.hasNext();) {
// Path: src/main/java/nl/vu/datalayer/hbase/connection/HBaseConnection.java
// public abstract class HBaseConnection {
// 
// 	public static final byte NATIVE_JAVA = 0;
// 	public static final byte REST = 1;
// 	
// 	public static HBaseConnection create(byte connectionType) throws IOException{
// 		switch (connectionType){
// 		case NATIVE_JAVA: {	
// 			return new NativeJavaConnection();
// 		}
// 		case REST:{
// 			return new RESTConnection();
// 		}
// 		default:
// 			throw new RuntimeException("Unknow HBase connection type");
// 		}
// 	}
// 	
// 	public abstract HTableInterface getTable(String tableName) throws IOException;
// 	
// 	public void close() throws IOException{}
// }
// 
// Path: src/main/java/nl/vu/datalayer/hbase/connection/NativeJavaConnection.java
// public class NativeJavaConnection extends HBaseConnection {
// 	
// 	protected HBaseAdmin hbase = null;
// 	protected Configuration conf = null;
// 	private HTablePool tablePool = null;
// 	
// 	public static final int MAX_POOL_SIZE = 20;
// 	
// 	public NativeJavaConnection() throws MasterNotRunningException, ZooKeeperConnectionException{
// 		//add the "hbase-site.xml" file to the classpath to get the bootstrapping Zookeeper nodes
// 		conf = HBaseConfiguration.create();
// 		tablePool = new HTablePool(conf, MAX_POOL_SIZE, PoolMap.PoolType.Reusable);
// 		hbase = new HBaseAdmin(conf);
// 	}
// 	
// 	public void initTables(String []tableNames) throws IOException{
// 		int iterations = MAX_POOL_SIZE/tableNames.length;
// 		HTable [][]tables = new HTable[iterations][];
// 		
// 		//open tables
// 		for (int i = 0; i < iterations; i++) {
// 			tables[i] = new HTable[tableNames.length];
// 			for (int j = 0; j < tableNames.length; j++) {
// 				if (hbase.tableExists(tableNames[j])){
// 					tables[i][j] = (HTable)tablePool.getTable(tableNames[j]);
// 					tables[i][j].prewarmRegionCache(tables[i][j].getRegionsInfo());
// 				}
// 				else{ 
// 					tables[i][j] = null;
// 				}
// 			}
// 		}
// 		
// 		//close tables
// 		for (int i = 0; i < tables.length; i++) {
// 			for (int j = 0; j < tableNames.length; j++) {
// 				if (tables[i][j]!=null){
// 					tables[i][j].close();
// 				}
// 			}
// 		}
// 	}
// 	
// 	public HTableInterface getTable(String tableName) throws IOException{
// 		return tablePool.getTable(tableName);
// 	}
// 	
// 	public HTableInterface getTable(byte [] tableNameBytes) throws IOException{
// 		return tablePool.getTable(tableNameBytes);
// 	}
// 	
// 	public void close() throws IOException{
// 		hbase.close();
// 		tablePool.close();
// 	}
// 	
// 	public HBaseAdmin getAdmin() {
// 		return hbase;
// 	}
// 	
// 	public Configuration getConfiguration() {
// 		return conf;
// 	}
// 
// }


// Path: src/main/java/nl/vu/datalayer/hbase/schema/HBasePredicateCFSchema.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import nl.vu.datalayer.hbase.connection.HBaseConnection;
import nl.vu.datalayer.hbase.connection.NativeJavaConnection;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.openrdf.model.Resource;
import org.openrdf.model.Statement;

	    HBaseAdmin hbase = con.getAdmin();
	    if (hbase.tableExists("predicates") == false) {
	    	desc = new HTableDescriptor("predicates");
	    }
	    else {
		     desc = hbase.getTableDescriptor("predicates".getBytes());
	    }
	    
	    HColumnDescriptor c = new HColumnDescriptor("URI".getBytes());
	    desc.addFamily(c);

	    if (hbase.tableExists("predicates") == false) {
	    	hbase.createTable(desc);
	    }
	}
	
	private void createTableStruct(String table, ArrayList<String> columns)  throws IOException {

	    HTableDescriptor desc;
	    HBaseAdmin hbase = con.getAdmin();
	    if (hbase.tableExists(table) == false) {
	    	desc = new HTableDescriptor(table);
	    	HColumnDescriptor literal = new HColumnDescriptor("literal".getBytes());
	    	desc.addFamily(literal);
	    }
	    else {
		     desc = hbase.getTableDescriptor(table.getBytes());
	    }
	    
		for (Iterator<String> iter = columns.iterator(); iter.hasNext();) {
			String columnName = iter.next().replaceAll("[^A-Za-z0-9 ]", "");