// 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/schema/HBHexastoreSchema.java
// public class HBHexastoreSchema implements IHBaseSchema {
// 	
// 	private static Logger logger = Logger.getLogger("HexastoreLogger");
// 	
// 	public static final String SCHEMA_NAME = "hexastore";
// 	
// 	public static final int TABLE_COUNT = 7;
// 	
// 	public static final String []TABLE_NAMES = {"O-SP", "P-SO", "PO-S", "S-PO",
// 			"SO-P", "SP-O", "SPO" };
// 	   
// 	// the 1 bits in the index have to correspond to the positions which are used as a key in S-P-O
// 	public static final int SPO = 7;
// 	public static final int S_PO = 4;
// 	public static final int P_SO = 2;
// 	public static final int O_SP = 1;
// 	public static final int SP_O = 6;
// 	public static final int SO_P = 5;
// 	public static final int PO_S = 3;
// 	
// 	public static final String COLUMN_FAMILY = "CF";
// 	public static final String COLUMN_NAME = "COL";
// 	
// 	//Encoding details
// 	public static final String TOKEN_DELIMITER = " ";//separates token within a pair
// 													//e.g in a PO cell, separates P from O 
// 	public static final String PAIR_DELIMITER = "\n";//separates pairs e.g. multiple PO pairs 
// 													//within the same cell
// 	
// 	private HBaseConnection con;
// 
// 	public HBHexastoreSchema(HBaseConnection con) {
// 		super();
// 		this.con = con;
// 		PropertyConfigurator.configure(System.getProperty("log4j.configFile"));
// 	}
// 
// 	private void createTable(HBaseAdmin admin, String tableName) throws IOException{
// 		HTableDescriptor desc = new HTableDescriptor(tableName);
// 		
// 		HColumnDescriptor famDesc = new HColumnDescriptor(COLUMN_FAMILY);
// 		desc.addFamily(famDesc);
// 		
// 		if (admin.tableExists(tableName) == false){
// 			logger.info("Creating table: "+tableName);
// 			admin.createTable(desc);
// 		}
// 	}
// 	 
// 	@Override
// 	public void create() throws Exception {
// 		HBaseAdmin admin = ((NativeJavaConnection)con).getAdmin();
// 		
// 		for (int i = 0; i < TABLE_NAMES.length; i++) {
// 			createTable(admin, TABLE_NAMES[i]);
// 		}
// 		logger.debug("Schema created");
// 	}
// 
// }


import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import nl.vu.datalayer.hbase.connection.HBaseConnection;
import nl.vu.datalayer.hbase.schema.HBHexastoreSchema;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.log4j.Logger;
import org.openrdf.model.Statement;
import org.openrdf.model.Value;

		}

		// construct the String value
		byte[] value = getValue(triple, index);

		if (existingValue != null) {
			val = Bytes.add(existingValue, value);
		} else {
			val = value;
		}

		Put p = new Put(key);
		p.setWriteToWAL(false);
		p.add(HBHexastoreSchema.COLUMN_FAMILY.getBytes(), HBHexastoreSchema.COLUMN_NAME.getBytes(), val);
		tables[index].put(p);
		return true;
		// batchPut.add(p);

		// Append append = new Append(key.toByteArray());
	}

	@Override
	public void populateTables(ArrayList<Statement> statements) throws Exception {

		HTable[] tables = new HTable[HBHexastoreSchema.TABLE_COUNT];
		// ArrayList<ArrayList<Put>> batchPuts = new
		// ArrayList<ArrayList<Put>>();
		// initialize connections to all tables
		// for each table initialize a buffer of Put operations
		for (int i = 0; i < tables.length; i++) {

// 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/schema/HBHexastoreSchema.java
// public class HBHexastoreSchema implements IHBaseSchema {
// 	
// 	private static Logger logger = Logger.getLogger("HexastoreLogger");
// 	
// 	public static final String SCHEMA_NAME = "hexastore";
// 	
// 	public static final int TABLE_COUNT = 7;
// 	
// 	public static final String []TABLE_NAMES = {"O-SP", "P-SO", "PO-S", "S-PO",
// 			"SO-P", "SP-O", "SPO" };
// 	   
// 	// the 1 bits in the index have to correspond to the positions which are used as a key in S-P-O
// 	public static final int SPO = 7;
// 	public static final int S_PO = 4;
// 	public static final int P_SO = 2;
// 	public static final int O_SP = 1;
// 	public static final int SP_O = 6;
// 	public static final int SO_P = 5;
// 	public static final int PO_S = 3;
// 	
// 	public static final String COLUMN_FAMILY = "CF";
// 	public static final String COLUMN_NAME = "COL";
// 	
// 	//Encoding details
// 	public static final String TOKEN_DELIMITER = " ";//separates token within a pair
// 													//e.g in a PO cell, separates P from O 
// 	public static final String PAIR_DELIMITER = "\n";//separates pairs e.g. multiple PO pairs 
// 													//within the same cell
// 	
// 	private HBaseConnection con;
// 
// 	public HBHexastoreSchema(HBaseConnection con) {
// 		super();
// 		this.con = con;
// 		PropertyConfigurator.configure(System.getProperty("log4j.configFile"));
// 	}
// 
// 	private void createTable(HBaseAdmin admin, String tableName) throws IOException{
// 		HTableDescriptor desc = new HTableDescriptor(tableName);
// 		
// 		HColumnDescriptor famDesc = new HColumnDescriptor(COLUMN_FAMILY);
// 		desc.addFamily(famDesc);
// 		
// 		if (admin.tableExists(tableName) == false){
// 			logger.info("Creating table: "+tableName);
// 			admin.createTable(desc);
// 		}
// 	}
// 	 
// 	@Override
// 	public void create() throws Exception {
// 		HBaseAdmin admin = ((NativeJavaConnection)con).getAdmin();
// 		
// 		for (int i = 0; i < TABLE_NAMES.length; i++) {
// 			createTable(admin, TABLE_NAMES[i]);
// 		}
// 		logger.debug("Schema created");
// 	}
// 
// }


// Path: src/main/java/nl/vu/datalayer/hbase/operations/HBHexastoreOperationManager.java
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import nl.vu.datalayer.hbase.connection.HBaseConnection;
import nl.vu.datalayer.hbase.schema.HBHexastoreSchema;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.log4j.Logger;
import org.openrdf.model.Statement;
import org.openrdf.model.Value;

		}

		// construct the String value
		byte[] value = getValue(triple, index);

		if (existingValue != null) {
			val = Bytes.add(existingValue, value);
		} else {
			val = value;
		}

		Put p = new Put(key);
		p.setWriteToWAL(false);
		p.add(HBHexastoreSchema.COLUMN_FAMILY.getBytes(), HBHexastoreSchema.COLUMN_NAME.getBytes(), val);
		tables[index].put(p);
		return true;
		// batchPut.add(p);

		// Append append = new Append(key.toByteArray());
	}

	@Override
	public void populateTables(ArrayList<Statement> statements) throws Exception {

		HTable[] tables = new HTable[HBHexastoreSchema.TABLE_COUNT];
		// ArrayList<ArrayList<Put>> batchPuts = new
		// ArrayList<ArrayList<Put>>();
		// initialize connections to all tables
		// for each table initialize a buffer of Put operations
		for (int i = 0; i < tables.length; i++) {

			tables[i] = (HTable) con.getTable(HBHexastoreSchema.TABLE_NAMES[i]);
