concerted-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [1/2] incubator-concerted git commit: Restructure source directory to a more modular hierarchy. Patch by Anand Rathi. Reviewed by Atri Sharma
Date Fri, 23 Oct 2015 18:52:18 GMT
Repository: incubator-concerted
Updated Branches:
  refs/heads/master 5adf3c4e5 -> fa6ba9867


http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/src/ConcSegHashTable.h
----------------------------------------------------------------------
diff --git a/src/ConcSegHashTable.h b/src/ConcSegHashTable.h
deleted file mode 100644
index 764e323..0000000
--- a/src/ConcSegHashTable.h
+++ /dev/null
@@ -1,221 +0,0 @@
-#include "QueueLock.h"
-
-template<class data_val_type> class ConcSegHashTable
-{
-	data_val_type **hash_tables;
-	QueueLock *read_lock_queues;
-	QueueLock *write_lock_queues;
-	int number_of_segments;
-	int number_of_buckets;
-	int last_insert_segment;
-public:
-	ConcSegHashTable(int m,int n)
-	{
-		int i;
-		int j;
-
-		i = 0;
-		j = 0;
-		number_of_segments = n;
-		number_of_buckets = m;
-		last_insert_segment = -1;
-		hash_tables = new data_val_type*[n];
-		for(i = 0;i < n;i++)
-		{
-			*(hash_tables + i) = new data_val_type[m];
-			for(j = 0;j < m;j++)
-			{
-				*(*(hash_tables + i) + j) = 0;
-			}
-
-		}
-
-		read_lock_queues = new QueueLock[m * n];
-		write_lock_queues = new QueueLock[m * n];
-		read_lock_queues->SetTimeOutPeriod(3.0);
-		write_lock_queues->SetTimeOutPeriod(3.0);	
-	}
-
-	int HashVal(data_val_type val)
-	{
-
-		return ((val/3) + 1);
-	}
-
-	int GetReadLock(int seg_index, int pos, char *name1)
-	{
-		QueueLock *current_write = write_lock_queues + (seg_index + pos);
-		QueueLock *current_read = read_lock_queues + (seg_index + pos);
-		const volatile int *p_write_lock_flag = current_write->GetPointerToFlag();
-
-		if(current_write->CheckLockIsAcquired() == 1)
-		{
-			while(*(p_write_lock_flag) != 0)
-			{
-				//Spinning waiting for write lock to release
-			}
-
-		}
-
-		return (current_read->GetLock(name1));
-	}
-
-	int GetWriteLock(int seg_index, int pos, char *name1)
-	{
-		QueueLock *current_write = write_lock_queues + (seg_index + pos);
-		QueueLock *current_read = read_lock_queues + (seg_index + pos);
-		const int *p_read_lock_flag = current_read->GetPointerToFlag();
-
-		if(current_read->CheckLockIsAcquired())
-		{
-			while(*(p_read_lock_flag) != 0)
-			{
-				//Spinning waiting for read lock to release
-			}
-
-		}
-
-		return (current_write->GetLock(name1));
-	}
-
-	void UpgradeLock(int seg_index, int pos, char *name1)
-	{
-		int i;
-
-		QueueLock *current_write = write_lock_queues + (seg_index + pos);
-
-		current_write->ForceLock(name1);   //We need to immediately get a write lock in order to upgrade the lock.
-		ReleaseReadLock(name1);
-	}
-
-	void ReleaseWriteLock(int seg_index, int pos, char *name1)
-	{
-		QueueLock *current_write = write_lock_queues + (seg_index + pos);
-
-		current_write->ReleaseLock(name1);
-		cout<<"Write lock released"<<endl;
-	}
-
-	void ReleaseReadLock(int seg_index, int pos, char *name1)
-	{
-		QueueLock *current_read = read_lock_queues + (seg_index + pos);
-
-		current_read->ReleaseLock(name1);
-	}
-
-	int SegmentInsert(int seg_index, data_val_type val, int pos, bool ReplaceValue, char *name1)
-	{
-		int get_write_lock = 0;
-		int get_read_lock = 0;
-		int check_lock_status = 0;
-
-		check_lock_status = (write_lock_queues + (seg_index + pos))->CheckLockIsAcquired();
-		if(check_lock_status == 1)
-		{
-			cout<<"Lock already taken"<<endl;
-		}
-		else
-		{	
-			get_write_lock = GetWriteLock(seg_index, pos, name1);
-			if(get_write_lock == 0)
-			{
-				cout<<"did not get lock"<<" "<<seg_index<<" "<<pos<<" "<<name1<<endl;
-				return (0);
-			}
-
-			if(*(*(hash_tables + seg_index) + pos) == 0 || ReplaceValue == true)
-			{
-				*(*(hash_tables + seg_index) + pos) = val;
-				ReleaseWriteLock(seg_index, pos, name1);
-
-				return (1);
-			}
-			
-		}
-
-			return (0);
-	}
-
-	int InsertElement(data_val_type val, bool ReplaceValue, char *name1)
-	{
-		int i;
-		int k;
-		int j;
-		int pos = HashVal(val);
-
-		j = 0;
-
-		if(last_insert_segment == -1)
-		{
-			k = 0;
-		}
-		else
-		{
-			k = last_insert_segment;
-		}
-
-		for(i = k;i < number_of_segments;i++)
-		{
-			if(SegmentInsert(i, val, pos, false, name1) == 1)
-			{
-				cout<<"value inserted at"<<" "<<i<<" "<<pos<<endl;
-				last_insert_segment = i;
-				return 1;
-			}
-		
-		}
-
-		for(i = 0;i < k;i++)
-		{
-			if(SegmentInsert(i, val, pos, false, name1) == 1)
-			{
-				cout<<"value inserted at"<<" "<<i<<" "<<pos<<endl;
-				last_insert_segment = i;
-				return 1;
-			}
-
-		}
-
-		for(i = k;i < number_of_segments;i++)
-		{
-			for(j = pos;j < number_of_buckets;j++)
-			{
-				if(SegmentInsert(i, val, j, false, name1) == 1)
-				{
-					cout<<"value inserted open addressing"<<" "<<i<<" "<<j<<endl;
-					return (1);
-				}
-
-			}
-
-		}
-
-		return (0);
-	}
-
-	void PrintValues()
-	{
-		int i;
-		int j;
-
-		i = 0;
-		j = 0;
-
-		for(i = 0;i < number_of_segments;i++)
-		{
-			for(j = 0;j < number_of_buckets;j++)
-			{
-				cout<<i<<" "<<j<<" "<<*(*(hash_tables + i) + j)<<endl;
-			}
-
-		}
-
-	}
-	~ConcSegHashTable()
-	{
-		delete hash_tables[number_of_segments];
-		delete[] read_lock_queues;
-		delete[] write_lock_queues;
-	}
-
-};

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/src/QueueLock.h
----------------------------------------------------------------------
diff --git a/src/QueueLock.h b/src/QueueLock.h
deleted file mode 100644
index e7549b8..0000000
--- a/src/QueueLock.h
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "ConcQueue.h"
-#include <ctime>
-
-#define BILLION 1E9
-
-class QueueLock
-{
-	ConcQueue<int> lock_queue;
-	int lock_taken;
-	int number_of_elements;
-	float timeout_period;
-public:
-	QueueLock():lock_taken(0),number_of_elements(0),timeout_period(3.0)
-	{
-	}
-
-	int GetLock(char *name1)
-	{
-		struct timespec requestStart, requestEnd;
-		if(lock_taken != 0)
-		{
-			const QueueElement<int> *p_add = lock_queue.AddElement(0);
-			++number_of_elements;
-			const volatile int *p_spin = p_add->GetPointerToData();
-
-			clock_gettime(CLOCK_REALTIME, &requestStart);
-
-			while(*(p_spin) != 1)
-			{
-				//Spinning waiting for lock
-				clock_gettime(CLOCK_REALTIME, &requestEnd);
-
-				double accum = ( requestEnd.tv_sec - requestStart.tv_sec )
-  					+ ( requestEnd.tv_nsec - requestStart.tv_nsec )
-  					/ BILLION;
-
-				if(accum >= timeout_period)
-				{
-					break;
-					return (0);
-				}
-
-			}
-
-		}
-
-		lock_taken = 1;
-
-		return (1);
-	}
-
-	void ReleaseLock(char *name1)
-	{
-		QueueElement<int> *p_release = lock_queue.GetElement();
-
-		if(p_release == NULL)
-		{
-			lock_taken = 0;
-		}
-		else
-		{
-			--number_of_elements;
-			p_release->SetData(1);
-		}
-
-	}
-
-	int ForceLock(char *name1)   //Use with EXTREME caution.
-	{
-		const QueueElement<int> *p_add = lock_queue.AddElementInFront(0);
-		const int *p_spin = p_add->GetPointerToData();
-		struct timespec requestStart, requestEnd;
-			
-		if(lock_taken != 0)
-		{
-			clock_gettime(CLOCK_REALTIME, &requestStart);
-
-			while(*(p_spin) != 1)
-			{
-				//Spinning waiting for lock
-				clock_gettime(CLOCK_REALTIME, &requestEnd);
-
-				double accum = ( requestEnd.tv_sec - requestStart.tv_sec )
-  					+ ( requestEnd.tv_nsec - requestStart.tv_nsec )
-  					/ BILLION;
-
-				if(accum >= timeout_period)
-				{
-					break;
-					return (0);
-				}
-
-			}
-
-		}
-
-		lock_taken = 1;
-
-		return (1);
-	}
-
-	 
-	int CheckLockIsAcquired()
-	{
-
-		return (lock_taken);
-	}
-
-	const int* GetPointerToFlag() const
-	{
-
-		return (&lock_taken);
-	}
-
-	void SetTimeOutPeriod(float timeout_period_val)
-	{
-		timeout_period = timeout_period_val;
-	}
-
-};
-
-			

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/src/QueueLock2.h
----------------------------------------------------------------------
diff --git a/src/QueueLock2.h b/src/QueueLock2.h
deleted file mode 100644
index e4ada9e..0000000
--- a/src/QueueLock2.h
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "ConcQueue.h"
-#include <ctime>
-
-#define BILLION 1E9
-
-class QueueLock
-{
-	ConcQueue<int> lock_queue;
-	int lock_taken;
-	int number_of_elements;
-	float timeout_period;
-public:
-	QueueLock():lock_taken(0),number_of_elements(0),timeout_period(3.0)
-	{
-	}
-
-	int GetLock()
-	{
-		struct timespec requestStart, requestEnd;
-		if(lock_taken != 0)
-		{
-			const QueueElement<int> *p_add = lock_queue.AddElement(0);
-			++number_of_elements;
-			const volatile int *p_spin = p_add->GetPointerToData();
-
-			clock_gettime(CLOCK_REALTIME, &requestStart);
-
-			while(*(p_spin) != 1)
-			{
-				//Spinning waiting for lock
-				clock_gettime(CLOCK_REALTIME, &requestEnd);
-
-				double accum = ( requestEnd.tv_sec - requestStart.tv_sec )
-  					+ ( requestEnd.tv_nsec - requestStart.tv_nsec )
-  					/ BILLION;
-
-				if(accum >= timeout_period)
-				{
-					break;
-					return (0);
-				}
-
-			}
-
-		}
-
-		lock_taken = 1;
-
-		return (1);
-	}
-
-	void ReleaseLock()
-	{
-		QueueElement<int> *p_release = lock_queue.GetElement();
-
-		if(p_release == NULL)
-		{
-			lock_taken = 0;
-		}
-		else
-		{
-			--number_of_elements;
-			p_release->SetData(1);
-		}
-
-	}
-
-	int ForceLock()   //Use with EXTREME caution.
-	{
-		const QueueElement<int> *p_add = lock_queue.AddElementInFront(0);
-		const int *p_spin = p_add->GetPointerToData();
-		struct timespec requestStart, requestEnd;
-			
-		if(lock_taken != 0)
-		{
-			clock_gettime(CLOCK_REALTIME, &requestStart);
-
-			while(*(p_spin) != 1)
-			{
-				//Spinning waiting for lock
-				clock_gettime(CLOCK_REALTIME, &requestEnd);
-
-				double accum = ( requestEnd.tv_sec - requestStart.tv_sec )
-  					+ ( requestEnd.tv_nsec - requestStart.tv_nsec )
-  					/ BILLION;
-
-				if(accum >= timeout_period)
-				{
-					break;
-					return (0);
-				}
-
-			}
-
-		}
-
-		lock_taken = 1;
-
-		return (1);
-	}
-
-	 
-	int CheckLockIsAcquired()
-	{
-
-		return (lock_taken);
-	}
-
-	const int* GetPointerToFlag() const
-	{
-
-		return (&lock_taken);
-	}
-
-	void SetTimeOutPeriod(float timeout_period_val)
-	{
-		timeout_period = timeout_period_val;
-	}
-
-};
-
-			

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/src/TransactionManager.h
----------------------------------------------------------------------
diff --git a/src/TransactionManager.h b/src/TransactionManager.h
deleted file mode 100644
index cb7c1ff..0000000
--- a/src/TransactionManager.h
+++ /dev/null
@@ -1,229 +0,0 @@
-#include <iostream>
-#include "QueueLock2.h"
-#include "ConcDef.h"
-using namespace std;
-
-class TransactionManager
-{
-	static int active_transaction_number;
-	int current_transaction_number;
-	static int counter;
-	int lock_counter;
-	int memory_counter;
-	int commit_val_counter;
-	static int active_transactions[10];
-	int delete_val;
-	ConcertedDef* current_val[10];
-	ConcertedDef* copy_val[10];
-	void *mem_allocated_val_array[10];
-	QueueLock *lock_val_array[10];
-public:
-	TransactionManager()
-	{
-		int i = 0;
-
-		for(i = 0;i < 10;i++)
-		{
-			current_val[i] = NULL;
-			copy_val[i] = NULL;
-			active_transactions[i] = 0;
-			lock_val_array[i] = NULL;
-			mem_allocated_val_array[i] = NULL;
-		}
-
-		if (counter == 10)
-		{
-			cout<<"A new transaction number cannot be inserted due to lack of space"<<endl;
-			throw -1;
-		}
-
-		current_transaction_number = ++active_transaction_number;
-		active_transactions[counter] = active_transaction_number;
-		++counter;
-
-		lock_counter = 0;
-		memory_counter = 0;
-		commit_val_counter = 0;
-		delete_val = 1;
-	}
-
-	int add_transaction()
-	{
-
-		if (counter == 10)
-		{
-			cout<<"A new transaction number cannot be inserted due to lack of space"<<endl;
-			return -1;
-		}
-
-		++active_transaction_number;
-		active_transactions[counter] = active_transaction_number;
-		++counter;
-
-		return active_transaction_number;
-	}
-
-	void delete_lock(QueueLock *val)
-	{
-		int i = 0;
-		int j = 0;
-
-		for(i = 0;i < lock_counter;i++)
-		{
-			if (lock_val_array[i] == val)
-			{
-				lock_val_array[i] = NULL;
-				for (j = i;j < lock_counter;j++)
-				{
-					lock_val_array[j] = lock_val_array[j + 1];
-				}
-
-				--lock_counter;
-				break;
-			}
-
-		}
-
-	}
-
-	int add_mem_location(ConcertedDef *mem)
-	{
-		if (memory_counter == 10)
-		{
-			cout<<"new memory location val cannot be added due to lack of element in array"<<endl;
-			throw -1;
-		}
-
-		mem_allocated_val_array[memory_counter] = mem;
-		++memory_counter;
-
-		return 1;
-	}
-
-	void delete_mem_location(ConcertedDef *val)
-	{
-		int i = 0;
-		int j = 0;
-
-		for (i = 0; i < memory_counter;i++)
-		{
-			if (mem_allocated_val_array[i] != NULL)
-			{
-				if (mem_allocated_val_array[i] == val)
-				{
-					mem_allocated_val_array[i] = NULL;
-					for (j = i;j < memory_counter;j++)
-					{
-						mem_allocated_val_array[j] = mem_allocated_val_array[j + 1];
-					}
-
-					--memory_counter;
-					break;
-				}
-
-			}
-
-		}
-
-	}
-
-	void delete_transaction(int val)
-	{
-		int i = 0;
-		int j = 0;
-
-		for (i = 0;i < 10;i++)
-		{
-			if (active_transactions[i] == val)
-			{
-				active_transactions[i] = 0;
-				for (j = i;j < counter;j++)
-				{
-					active_transactions[j] = active_transactions[j + 1];
-				}
-
-				--counter;
-			}
-
-		}
-
-	}
-
-	void add_commit_val(ConcertedDef *val, ConcertedDef *copy_val1)
-	{
-
-		if (commit_val_counter == 10)
-		{
-			cout<<"commit val cannot be added due to lack of element in array"<<endl;
-			throw -1;
-		}
-
-		current_val[commit_val_counter] = val;
-		copy_val[commit_val_counter] = copy_val1;
-		++commit_val_counter;
-	}
-
-	void add_lock(QueueLock *val)
-	{
-
-		if (lock_counter == 10)
-		{
-			cout<<"lock cannot be added due to lack of element in array"<<endl;
-			throw -1;
-		}
-
-		lock_val_array[lock_counter] = val;
-		++lock_counter;
-	}
-
-	void commit_transaction()
-	{
-		int i = 0;
-
-		delete_val = 0;
-		for (i = 0;i < commit_val_counter;i++)
-		{
-			(current_val[i])->copy_pointer_val(copy_val[i]);
-		}
-
-		cout<<"commit"<<endl;
-
-	}
-
-	~TransactionManager()
-	{
-		int i = 0;
-
-		if (delete_val == 1)
-		{
-			cout<<"Rollback"<<endl;
-			for (i = 0;i < lock_counter;i++)
-			{
-				if (lock_val_array[i] != NULL && (lock_val_array[i])->CheckLockIsAcquired())
-				{
-					lock_val_array[i]->ReleaseLock();
-				}
-
-			}
-
-			i = 0;
-
-			for (i = 0;i < memory_counter;i++)
-			{
-				if (mem_allocated_val_array[i] != NULL)
-				{
-					free(mem_allocated_val_array[i]);
-				}
-
-			}
-
-		delete_transaction(current_transaction_number);
-
-		}
-
-	}
-};
-
-int TransactionManager::counter = 0;
-int TransactionManager::active_transaction_number = 0;
-int TransactionManager::active_transactions[10] = {0,0,0,0,0,0,0,0,0,0};

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcDCTConcurrencyTest.cpp
----------------------------------------------------------------------
diff --git a/test/ConcDCTConcurrencyTest.cpp b/test/ConcDCTConcurrencyTest.cpp
new file mode 100644
index 0000000..ed775bb
--- /dev/null
+++ b/test/ConcDCTConcurrencyTest.cpp
@@ -0,0 +1,72 @@
+#include "../ConcDCT.h"
+
+	void *thread_lock_test1(void *arg1)
+	{
+		dct_tree *tree_val = (dct_tree*)arg1;
+		int arr_val[3];
+
+		arr_val[0] = 1;
+		arr_val[1] = 2;
+		arr_val[2] = 3;
+
+		insert_val(arr_val, tree_val);
+	}
+
+	void *thread_lock_test2(void *arg1)
+	{
+		dct_tree *tree_val = (dct_tree*)arg1;
+		int arr_val[3];
+
+		arr_val[0] = 4;
+		arr_val[1] = 5;
+		arr_val[2] = 6;
+
+		insert_val(arr_val, tree_val);
+	}
+
+	void *thread_lock_test3(void *arg1)
+	{
+		dct_tree *tree_val = (dct_tree*)arg1;
+		int arr_val[3];
+
+		arr_val[0] = 1;
+		arr_val[1] = 2;
+		arr_val[2] = 3;
+
+		insert_val(arr_val, tree_val);
+	}
+
+	void *thread_lock_test4(void *arg1)
+	{
+		dct_tree *tree_val = (dct_tree*)arg1;
+		int arr_val[3];
+
+		arr_val[0] = 4;
+		arr_val[1] = 5;
+		arr_val[2] = 6;
+
+		search_val(arr_val, tree_val);
+	}
+		
+	int main()
+	{
+	dct_tree *tree_val = NULL;
+	pthread_t tid1;
+	pthread_t tid2;
+	pthread_t tid3;
+	pthread_t tid4;
+
+	tree_val = new dct_tree(3);
+
+	pthread_create(&tid1,NULL,thread_lock_test1,(void*)tree_val);
+	pthread_create(&tid2,NULL,thread_lock_test2,(void*)tree_val);
+	pthread_create(&tid3,NULL,thread_lock_test3,(void*)tree_val);
+	pthread_create(&tid4,NULL,thread_lock_test4,(void*)tree_val);
+
+	pthread_join(tid1,NULL);
+	pthread_join(tid2,NULL);
+	pthread_join(tid3,NULL);
+	pthread_join(tid4,NULL);
+	}
+
+	

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcDCTFileReader.cpp
----------------------------------------------------------------------
diff --git a/test/ConcDCTFileReader.cpp b/test/ConcDCTFileReader.cpp
new file mode 100644
index 0000000..33ac373
--- /dev/null
+++ b/test/ConcDCTFileReader.cpp
@@ -0,0 +1,53 @@
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <string>
+#include "../include/ConcDCT.h"
+
+using namespace std;
+
+std::string line;
+std::ifstream infile("sat.trn");
+
+int main()
+{
+int count;
+int arr_val[3];
+dct_tree *tree_val = NULL;
+TransactionManager t1;
+		
+tree_val = build_dcttree(3);
+count = 0;
+while (std::getline(infile, line))  // this does the checking!
+{
+  std::istringstream iss(line);
+  char c;
+
+   int value;
+  while (iss >> value)
+  {
+	if (count == 3)
+	{
+		insert_val(arr_val, tree_val, t1);
+		count = 0;
+		cout<<"record"<<endl;
+	}
+
+	arr_val[count] = value;
+	++count;
+  }
+}
+
+arr_val[0] = 91;
+arr_val[1] = 100;
+arr_val[2] = 81;
+
+if ((search_val(arr_val, tree_val)) != NULL)
+		{
+			cout<<"All values found"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found"<<endl;
+		}
+}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcDCTFileReader.cpp~
----------------------------------------------------------------------
diff --git a/test/ConcDCTFileReader.cpp~ b/test/ConcDCTFileReader.cpp~
new file mode 100644
index 0000000..630c35e
--- /dev/null
+++ b/test/ConcDCTFileReader.cpp~
@@ -0,0 +1,53 @@
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <string>
+#include "../ConcDCT.h"
+
+using namespace std;
+
+std::string line;
+std::ifstream infile("sat.trn");
+
+int main()
+{
+int count;
+int arr_val[3];
+dct_tree *tree_val = NULL;
+TransactionManager t1;
+		
+tree_val = build_dcttree(3);
+count = 0;
+while (std::getline(infile, line))  // this does the checking!
+{
+  std::istringstream iss(line);
+  char c;
+
+   int value;
+  while (iss >> value)
+  {
+	if (count == 3)
+	{
+		insert_val(arr_val, tree_val, t1);
+		count = 0;
+		cout<<"record"<<endl;
+	}
+
+	arr_val[count] = value;
+	++count;
+  }
+}
+
+arr_val[0] = 91;
+arr_val[1] = 100;
+arr_val[2] = 81;
+
+if ((search_val(arr_val, tree_val)) != NULL)
+		{
+			cout<<"All values found"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found"<<endl;
+		}
+}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcDCTTest.cpp
----------------------------------------------------------------------
diff --git a/test/ConcDCTTest.cpp b/test/ConcDCTTest.cpp
new file mode 100644
index 0000000..d17b277
--- /dev/null
+++ b/test/ConcDCTTest.cpp
@@ -0,0 +1,62 @@
+#include "../include/ConcDCT.h"
+	int main()
+	{
+		int att_array[3];
+		int i = 0;
+		TransactionManager transact_val1;
+		dct_tree *tree_val = NULL;
+		dct_tree *tree_val2 = NULL;
+		dct_tree *tree_val3 = NULL;
+		dct_node *temp = NULL;
+		tree_val = build_dcttree(3);
+		tree_val3 = build_dcttree(3);
+		att_array[0] = 1;
+		att_array[1] = 2;
+		att_array[2] = 3;
+		try
+		{
+			insert_val(att_array, tree_val, transact_val1);
+			insert_val(att_array, tree_val3, transact_val1);
+			//throw -1;
+			transact_val1.commit_transaction();
+			tree_val2 = copy_val((tree_val->getdummy()), (tree_val->getnumber_of_nodes()));
+		}catch (int e)
+		{
+			cout<<"exception caught"<<" "<<e<<endl;
+			return 1;
+		}
+
+		//att_array[2] = 3;
+		if (search_val(att_array, tree_val))
+		{
+			cout<<"All values found"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found"<<endl;
+		}
+
+		temp = search_val(att_array, tree_val2);
+		if (temp != NULL)
+		{
+			cout<<" All values found copy tree"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found copy tree"<<endl;
+		}
+
+		if (search_val(att_array, tree_val3))
+		{
+			cout<<"All values found3"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found3"<<endl;
+		}
+
+		delete tree_val;
+		delete tree_val2;
+		delete tree_val3;
+		delete temp;
+	}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcDCTTest.cpp~
----------------------------------------------------------------------
diff --git a/test/ConcDCTTest.cpp~ b/test/ConcDCTTest.cpp~
new file mode 100644
index 0000000..303c166
--- /dev/null
+++ b/test/ConcDCTTest.cpp~
@@ -0,0 +1,62 @@
+#include "../ConcDCT.h"	
+	int main()
+	{
+		int att_array[3];
+		int i = 0;
+		TransactionManager transact_val1;
+		dct_tree *tree_val = NULL;
+		dct_tree *tree_val2 = NULL;
+		dct_tree *tree_val3 = NULL;
+		dct_node *temp = NULL;
+		tree_val = build_dcttree(3);
+		tree_val3 = build_dcttree(3);
+		att_array[0] = 1;
+		att_array[1] = 2;
+		att_array[2] = 3;
+		try
+		{
+			insert_val(att_array, tree_val, transact_val1);
+			insert_val(att_array, tree_val3, transact_val1);
+			//throw -1;
+			transact_val1.commit_transaction();
+			tree_val2 = copy_val((tree_val->getdummy()), (tree_val->getnumber_of_nodes()));
+		}catch (int e)
+		{
+			cout<<"exception caught"<<" "<<e<<endl;
+			return 1;
+		}
+
+		//att_array[2] = 3;
+		if (search_val(att_array, tree_val))
+		{
+			cout<<"All values found"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found"<<endl;
+		}
+
+		temp = search_val(att_array, tree_val2);
+		if (temp != NULL)
+		{
+			cout<<" All values found copy tree"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found copy tree"<<endl;
+		}
+
+		if (search_val(att_array, tree_val3))
+		{
+			cout<<"All values found3"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found3"<<endl;
+		}
+
+		delete tree_val;
+		delete tree_val2;
+		delete tree_val3;
+		delete temp;
+	}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcInvertedIndexTest.cpp
----------------------------------------------------------------------
diff --git a/test/ConcInvertedIndexTest.cpp b/test/ConcInvertedIndexTest.cpp
new file mode 100644
index 0000000..35ba9e0
--- /dev/null
+++ b/test/ConcInvertedIndexTest.cpp
@@ -0,0 +1,28 @@
+#include "../include/ConcInvertedIndex.h"
+
+int main()
+	{
+		inv_index<3,0> *index1;
+		int att_values[3];
+		int return_value;
+
+		return_value = 0;
+		index1 = new inv_index<3,0>;
+		att_values[0] = 3;
+		att_values[1] = 4;
+		att_values[2] = 5;
+
+		insert_val(att_values, index1);
+
+		return_value = search_val(&(att_values[0]), index1);
+
+		if (return_value == 1)
+		{
+			cout<<"values found"<<" "<<return_value<<endl;
+		}
+		else
+		{
+			cout<<"values not found"<<" "<<return_value<<endl;
+		}
+
+	}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcInvertedIndexTest.cpp~
----------------------------------------------------------------------
diff --git a/test/ConcInvertedIndexTest.cpp~ b/test/ConcInvertedIndexTest.cpp~
new file mode 100644
index 0000000..424c277
--- /dev/null
+++ b/test/ConcInvertedIndexTest.cpp~
@@ -0,0 +1,28 @@
+#include "../ConcInvertedIndex.h"
+
+int main()
+	{
+		inv_index<3,0> *index1;
+		int att_values[3];
+		int return_value;
+
+		return_value = 0;
+		index1 = new inv_index<3,0>;
+		att_values[0] = 3;
+		att_values[1] = 4;
+		att_values[2] = 5;
+
+		insert_val(att_values, index1);
+
+		return_value = search_val(&(att_values[0]), index1);
+
+		if (return_value == 1)
+		{
+			cout<<"values found"<<" "<<return_value<<endl;
+		}
+		else
+		{
+			cout<<"values not found"<<" "<<return_value<<endl;
+		}
+
+	}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcMATFileReader.cpp
----------------------------------------------------------------------
diff --git a/test/ConcMATFileReader.cpp b/test/ConcMATFileReader.cpp
new file mode 100644
index 0000000..3e924fc
--- /dev/null
+++ b/test/ConcMATFileReader.cpp
@@ -0,0 +1,52 @@
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <string>
+#include "../ConcMAT.h"
+
+using namespace std;
+
+std::string line;
+std::ifstream infile("sat.trn");
+
+int main()
+{
+int count;
+int arr_val[3];
+mat_tree *tree_val = NULL;
+
+tree_val = build_mattree(3);
+count = 0;
+while (std::getline(infile, line))  // this does the checking!
+{
+  std::istringstream iss(line);
+  char c;
+
+   int value;
+  while (iss >> value) 
+  {
+	if (count == 3)
+	{
+		insert_val(arr_val, tree_val);
+		count = 0;
+		cout<<"record"<<endl;
+	}
+
+	arr_val[count] = value;
+	++count;
+  }
+}
+
+arr_val[0] = 91;
+arr_val[1] = 100;
+arr_val[2] = 81;
+
+if ((search_val(arr_val, tree_val)) != NULL)
+		{
+			cout<<"All values found"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found"<<endl;
+		}
+}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcMATTest.cpp
----------------------------------------------------------------------
diff --git a/test/ConcMATTest.cpp b/test/ConcMATTest.cpp
new file mode 100644
index 0000000..555c033
--- /dev/null
+++ b/test/ConcMATTest.cpp
@@ -0,0 +1,24 @@
+#include "../include/ConcMAT.h"
+
+	int main()
+	{
+		int att_array[3];
+		int i = 0;
+		mat_tree *tree_val = NULL;
+		tree_val = build_mattree(3);
+		att_array[0] = 1;
+		att_array[1] = 2;
+		att_array[2] = 3;
+		insert_val(att_array, tree_val);
+		if (search_val(att_array, tree_val))
+		{
+			cout<<"All values found"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found"<<endl;
+		}
+
+		delete tree_val;
+	}
+

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcMATTest.cpp~
----------------------------------------------------------------------
diff --git a/test/ConcMATTest.cpp~ b/test/ConcMATTest.cpp~
new file mode 100644
index 0000000..459cdcc
--- /dev/null
+++ b/test/ConcMATTest.cpp~
@@ -0,0 +1,24 @@
+#include "../ConcMAT.h"	
+
+	int main()
+	{
+		int att_array[3];
+		int i = 0;
+		mat_tree *tree_val = NULL;
+		tree_val = build_mattree(3);
+		att_array[0] = 1;
+		att_array[1] = 2;
+		att_array[2] = 3;
+		insert_val(att_array, tree_val);
+		if (search_val(att_array, tree_val))
+		{
+			cout<<"All values found"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found"<<endl;
+		}
+
+		delete tree_val;
+	}
+

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcSegHashTableTest.cpp
----------------------------------------------------------------------
diff --git a/test/ConcSegHashTableTest.cpp b/test/ConcSegHashTableTest.cpp
new file mode 100644
index 0000000..92b8ce5
--- /dev/null
+++ b/test/ConcSegHashTableTest.cpp
@@ -0,0 +1,87 @@
+#include "../include/ConcSegHashTable.h"
+
+ConcSegHashTable<int> tab1(10,2);
+void *thread_lock_test(void *arg1)
+{
+	//tab1.GetWriteLock(0,2,(char*)arg1);
+	//tab1.InsertElement(5, false, (char*)arg1);
+	if((tab1.InsertElement(5, false,(char*)arg1)) == 0)
+	{
+		cout<<"Value not inserted"<<" "<<(char*)arg1<<" "<<5<<endl;
+		sleep(1);
+	}
+
+	tab1.InsertElement(6, false,(char*)arg1);
+	//tab1.InsertElement(5, false,(char*)arg1);
+	//tab1.InsertElement(5, false,(char*)arg1);
+	//cout<<"read lock with"<<" "<<(char*)arg1<<endl;
+	//sleep(1);
+	//tab1.ReleaseWriteLock(0,2,(char*)arg1);
+	//cout<<"read lock released by"<<" "<<(char*)arg1<<endl;
+}
+
+void *thread_lock_test2(void *arg1)
+{
+	//tab1.GetWriteLock(0,2, (char*)arg1);
+	//cout<<"write lock with"<<" "<<(char*)arg1<<endl;
+	//tab1.ReleaseWriteLock(0,2, (char*)arg1);
+	//cout<<"write lock released by"<<" "<<(char*)arg1<<endl;
+	if((tab1.InsertElement(5, false, (char*)arg1)) == 0)
+	{
+		cout<<"Value not inserted"<<" "<<(char*)arg1<<" "<<5<<endl;
+		sleep(1);
+	}
+
+	if((tab1.InsertElement(6, false, (char*)arg1)) == 0)
+	{
+		cout<<"Value not inserted"<<" "<<(char*)arg1<<" "<<6<<endl;
+		sleep(1);
+	}
+}
+
+void *thread_lock_test3(void *arg1)
+{
+	/*tab1.GetReadLock(0,2, (char*)arg1);
+	cout<<"read lock with"<<" "<<(char*)arg1<<endl;
+	tab1.ReleaseReadLock(0,2, (char*)arg1);
+	cout<<"read lock released by"<<" "<<(char*)arg1<<endl;*/
+	if((tab1.InsertElement(6, false, (char*)arg1)) == 0)
+	{
+		cout<<"Value not inserted"<<" "<<(char*)arg1<<" "<<6<<endl;
+	}
+
+	//tab1.InsertElement(6, false, (char*)arg1);
+}
+
+void *thread_lock_test4(void *arg1)
+{
+	tab1.InsertElement(6,false,(char*)arg1);
+	tab1.InsertElement(9,false,(char*)arg1);
+}
+
+int main()
+{
+	pthread_t tid1;
+	pthread_t tid2;
+	pthread_t tid3;
+	pthread_t tid4;
+	char name1[] = "thread1";
+	char name2[] = "thread2";
+	char name3[] = "thread3";
+	char name4[] = "thread4";
+
+	pthread_create(&tid1,NULL,thread_lock_test,(void*)name1);
+	pthread_create(&tid2,NULL,thread_lock_test2,(void*)name2);
+	pthread_create(&tid3,NULL,thread_lock_test3,(void*)name3);
+	pthread_create(&tid4,NULL,thread_lock_test4,(void*)name4);
+
+	pthread_join(tid1,NULL);
+	pthread_join(tid2,NULL);
+	pthread_join(tid3,NULL);
+	pthread_join(tid4,NULL);
+
+	tab1.PrintValues();
+
+	//tab1.GetWriteLock(2,3);
+	//tab1.ReleaseWriteLock(2,3);
+}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcSegHashTableTest.cpp~
----------------------------------------------------------------------
diff --git a/test/ConcSegHashTableTest.cpp~ b/test/ConcSegHashTableTest.cpp~
new file mode 100644
index 0000000..6a61a1a
--- /dev/null
+++ b/test/ConcSegHashTableTest.cpp~
@@ -0,0 +1,87 @@
+#include "../ConcSegHashTable.h"
+
+ConcSegHashTable<int> tab1(10,2);
+void *thread_lock_test(void *arg1)
+{
+	//tab1.GetWriteLock(0,2,(char*)arg1);
+	//tab1.InsertElement(5, false, (char*)arg1);
+	if((tab1.InsertElement(5, false,(char*)arg1)) == 0)
+	{
+		cout<<"Value not inserted"<<" "<<(char*)arg1<<" "<<5<<endl;
+		sleep(1);
+	}
+
+	tab1.InsertElement(6, false,(char*)arg1);
+	//tab1.InsertElement(5, false,(char*)arg1);
+	//tab1.InsertElement(5, false,(char*)arg1);
+	//cout<<"read lock with"<<" "<<(char*)arg1<<endl;
+	//sleep(1);
+	//tab1.ReleaseWriteLock(0,2,(char*)arg1);
+	//cout<<"read lock released by"<<" "<<(char*)arg1<<endl;
+}
+
+void *thread_lock_test2(void *arg1)
+{
+	//tab1.GetWriteLock(0,2, (char*)arg1);
+	//cout<<"write lock with"<<" "<<(char*)arg1<<endl;
+	//tab1.ReleaseWriteLock(0,2, (char*)arg1);
+	//cout<<"write lock released by"<<" "<<(char*)arg1<<endl;
+	if((tab1.InsertElement(5, false, (char*)arg1)) == 0)
+	{
+		cout<<"Value not inserted"<<" "<<(char*)arg1<<" "<<5<<endl;
+		sleep(1);
+	}
+
+	if((tab1.InsertElement(6, false, (char*)arg1)) == 0)
+	{
+		cout<<"Value not inserted"<<" "<<(char*)arg1<<" "<<6<<endl;
+		sleep(1);
+	}
+}
+
+void *thread_lock_test3(void *arg1)
+{
+	/*tab1.GetReadLock(0,2, (char*)arg1);
+	cout<<"read lock with"<<" "<<(char*)arg1<<endl;
+	tab1.ReleaseReadLock(0,2, (char*)arg1);
+	cout<<"read lock released by"<<" "<<(char*)arg1<<endl;*/
+	if((tab1.InsertElement(6, false, (char*)arg1)) == 0)
+	{
+		cout<<"Value not inserted"<<" "<<(char*)arg1<<" "<<6<<endl;
+	}
+
+	//tab1.InsertElement(6, false, (char*)arg1);
+}
+
+void *thread_lock_test4(void *arg1)
+{
+	tab1.InsertElement(6,false,(char*)arg1);
+	tab1.InsertElement(9,false,(char*)arg1);
+}
+
+int main()
+{
+	pthread_t tid1;
+	pthread_t tid2;
+	pthread_t tid3;
+	pthread_t tid4;
+	char name1[] = "thread1";
+	char name2[] = "thread2";
+	char name3[] = "thread3";
+	char name4[] = "thread4";
+
+	pthread_create(&tid1,NULL,thread_lock_test,(void*)name1);
+	pthread_create(&tid2,NULL,thread_lock_test2,(void*)name2);
+	pthread_create(&tid3,NULL,thread_lock_test3,(void*)name3);
+	pthread_create(&tid4,NULL,thread_lock_test4,(void*)name4);
+
+	pthread_join(tid1,NULL);
+	pthread_join(tid2,NULL);
+	pthread_join(tid3,NULL);
+	pthread_join(tid4,NULL);
+
+	tab1.PrintValues();
+
+	//tab1.GetWriteLock(2,3);
+	//tab1.ReleaseWriteLock(2,3);
+}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcSkipListTest.cpp
----------------------------------------------------------------------
diff --git a/test/ConcSkipListTest.cpp b/test/ConcSkipListTest.cpp
new file mode 100644
index 0000000..95552ff
--- /dev/null
+++ b/test/ConcSkipListTest.cpp
@@ -0,0 +1,294 @@
+#include "../include/QueueLock.h"
+
+class linked_list
+{
+	int val;
+	linked_list *next;
+public:
+	linked_list()
+	{
+		val = 0;
+		next = NULL;
+	}
+	int getval()
+	{
+		return val;
+	}
+
+	void setval(int a)
+	{
+		val = a;
+	}
+
+	linked_list* getnext()
+	{
+		return next;
+	}
+
+	void setnext(linked_list *val)
+	{
+		next = val;
+	}
+};
+
+class skip_list_master
+{
+	int curr_level;
+	int max_level;
+	float probability_val;
+	linked_list **list_array;
+public:
+	skip_list_master()
+	{
+		curr_level = 0;
+		max_level = 5;
+		list_array = NULL;
+		probability_val = 0.25;
+	}
+
+	void insert_val(int location, int index, linked_list *temp)
+	{
+		linked_list *traverse = NULL;
+		int i = 0;
+
+		if (list_array == NULL)
+		{
+			list_array = (linked_list**)malloc(sizeof(linked_list*));
+			list_array[0] = temp;
+			curr_level = 1;
+
+			cout<<"Inserted condition 1"<<" "<<list_array[0]->getval()<<endl;
+
+			return;
+		}
+
+		i = index;
+		traverse = list_array[location];
+
+		/*while((traverse->getnext()) != NULL && (traverse->getval()) < a && ((traverse->getnext())->getval()) < a)
+		{
+			cout<<"In loop"<<endl;
+			traverse = traverse->getnext();
+		}*/
+
+		while (i > 0)
+		{
+			traverse = traverse->getnext();
+			--i;
+		}
+
+		if ((traverse->getnext()) == NULL)
+		{
+			traverse->setnext(temp);
+			return;
+		}
+		/*else if ((traverse->getval()) >= a)
+		{
+			temp->setnext(traverse);
+			return;
+		}*/
+
+		temp->setnext(traverse->getnext());
+		traverse->setnext(temp);
+
+	}
+
+	void insert_skip(int a)
+	{
+		linked_list **traverse_skip = NULL;
+		linked_list *traverse_list = NULL;
+		linked_list *previous_pointer = NULL;
+		linked_list *temp = NULL;
+		int i = 0;
+		int j = 0;
+		int level = 0;
+		int iteration_value = 0;
+
+		level = level_generate();
+		i = level - 1;
+
+		if (level > max_level)
+		{
+			iteration_value = max_level;
+		}
+		else
+		{
+			iteration_value = level;
+		}
+
+		temp = (linked_list*)malloc(sizeof(linked_list));
+
+		temp->setval(a);
+
+		if (!list_array)
+		{
+			insert_val(a, 0, temp);
+			return;
+		}
+		else
+		{
+			traverse_skip = (linked_list**)malloc(sizeof(linked_list*) * max_level);
+		}
+
+		traverse_list = list_array[level - 1];
+
+		for (i = (level - 1);i >= 0;i--)
+		{
+			previous_pointer = NULL;
+
+			if (j > 0)
+			{
+				while (j > 0)
+				{
+					traverse_list = traverse_list->getnext();
+					--j;
+				}
+			}
+
+			if (traverse_list == NULL)
+			{
+				cout<<"traverse_list is NULL"<<endl;
+			}
+			else
+			{
+				cout<<"traverse_list is not NULL"<<endl;
+			}
+
+			while (traverse_list != NULL && (traverse_list->getval()) < a)
+			{
+				cout<<"In loop 2"<<" "<<(traverse_list->getval())<<endl;
+				++j;
+				previous_pointer = traverse_list;
+				traverse_list = traverse_list->getnext();
+			}
+
+			traverse_skip[i] = previous_pointer;
+
+			traverse_list = list_array[i];
+		}
+
+		insert_val(0, j, temp);
+		/*for (i = 1;i <= (level - 1);i++)
+		{*/
+			
+	}
+
+
+	void print_val()
+	{
+		linked_list *traverse = NULL;
+
+		if (list_array)
+		{
+			traverse = list_array[0];
+		}
+
+		while (traverse != NULL)
+		{
+			cout<<"val is"<<" "<<traverse->getval()<<endl;
+			traverse = traverse->getnext();
+		}
+	}
+
+	int level_generate()
+	{
+		double rand_val = static_cast<double>(rand()) / RAND_MAX;
+		int level = 0;
+
+		while (rand_val > probability_val && level < max_level)
+		{
+			++level;
+			rand_val = static_cast<double>(rand()) / RAND_MAX;
+		}
+
+		return level;
+	}
+
+	int search_val(int key)
+	{
+		linked_list **traverse_skip = NULL;
+		linked_list *traverse_list = NULL;
+		int i = 0;
+		int j = 0;
+
+		i = curr_level;
+
+		if (!list_array)
+		{
+			return 0;
+		}
+		else
+		{
+			traverse_skip = (linked_list**)malloc(sizeof(linked_list*) * max_level);
+		}
+
+		traverse_list = list_array[curr_level - 1];
+
+		for (i = (curr_level - 1);i >= 0;i--)
+		{
+			if (j > 0)
+			{
+				while (j > 0)
+				{
+					traverse_list = traverse_list->getnext();
+					--j;
+				}
+			}
+
+			while (traverse_list != NULL && (traverse_list->getval()) != key)
+			{
+				cout<<"In loop 2"<<" "<<(traverse_list->getval())<<endl;
+				++j;
+				traverse_list = traverse_list->getnext();
+			}
+
+			if (traverse_list != NULL)
+			{
+				return 1;
+			}
+
+			traverse_list = list_array[i];
+		}
+
+		return -1;
+	}	
+};
+
+int main()
+{
+	srand(time(0));
+	int low = 0;
+	int high = 1;
+	int result_search = 0;
+	double dUniform = static_cast<double>(rand()) / RAND_MAX;
+	skip_list_master list1;
+	int val1 = list1.level_generate();
+
+	//list1.insert_val(1,0);
+	//list1.insert_val(2,0);
+	//list1.insert_val(4,0);
+	//list1.insert_val(7,0);
+	//list1.insert_val(6,0);
+
+	list1.insert_skip(1);
+	//list1.insert_skip(2);
+	//list1.insert_skip(3);
+	//list1.insert_skip(4);
+	//list1.insert_skip(5);
+
+
+	//list1.print_val();
+
+	result_search = list1.search_val(1);
+
+	cout<<"search result"<<" "<<result_search<<endl;
+
+	if (dUniform > 5)
+	{
+		cout<<"insertion"<<dUniform<<" "<<val1<<endl;
+	}
+	else
+	{
+		cout<<"no insertion"<<dUniform<<" "<<val1<<endl;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/ConcSkipListTest.cpp~
----------------------------------------------------------------------
diff --git a/test/ConcSkipListTest.cpp~ b/test/ConcSkipListTest.cpp~
new file mode 100644
index 0000000..95552ff
--- /dev/null
+++ b/test/ConcSkipListTest.cpp~
@@ -0,0 +1,294 @@
+#include "../include/QueueLock.h"
+
+class linked_list
+{
+	int val;
+	linked_list *next;
+public:
+	linked_list()
+	{
+		val = 0;
+		next = NULL;
+	}
+	int getval()
+	{
+		return val;
+	}
+
+	void setval(int a)
+	{
+		val = a;
+	}
+
+	linked_list* getnext()
+	{
+		return next;
+	}
+
+	void setnext(linked_list *val)
+	{
+		next = val;
+	}
+};
+
+class skip_list_master
+{
+	int curr_level;
+	int max_level;
+	float probability_val;
+	linked_list **list_array;
+public:
+	skip_list_master()
+	{
+		curr_level = 0;
+		max_level = 5;
+		list_array = NULL;
+		probability_val = 0.25;
+	}
+
+	void insert_val(int location, int index, linked_list *temp)
+	{
+		linked_list *traverse = NULL;
+		int i = 0;
+
+		if (list_array == NULL)
+		{
+			list_array = (linked_list**)malloc(sizeof(linked_list*));
+			list_array[0] = temp;
+			curr_level = 1;
+
+			cout<<"Inserted condition 1"<<" "<<list_array[0]->getval()<<endl;
+
+			return;
+		}
+
+		i = index;
+		traverse = list_array[location];
+
+		/*while((traverse->getnext()) != NULL && (traverse->getval()) < a && ((traverse->getnext())->getval()) < a)
+		{
+			cout<<"In loop"<<endl;
+			traverse = traverse->getnext();
+		}*/
+
+		while (i > 0)
+		{
+			traverse = traverse->getnext();
+			--i;
+		}
+
+		if ((traverse->getnext()) == NULL)
+		{
+			traverse->setnext(temp);
+			return;
+		}
+		/*else if ((traverse->getval()) >= a)
+		{
+			temp->setnext(traverse);
+			return;
+		}*/
+
+		temp->setnext(traverse->getnext());
+		traverse->setnext(temp);
+
+	}
+
+	void insert_skip(int a)
+	{
+		linked_list **traverse_skip = NULL;
+		linked_list *traverse_list = NULL;
+		linked_list *previous_pointer = NULL;
+		linked_list *temp = NULL;
+		int i = 0;
+		int j = 0;
+		int level = 0;
+		int iteration_value = 0;
+
+		level = level_generate();
+		i = level - 1;
+
+		if (level > max_level)
+		{
+			iteration_value = max_level;
+		}
+		else
+		{
+			iteration_value = level;
+		}
+
+		temp = (linked_list*)malloc(sizeof(linked_list));
+
+		temp->setval(a);
+
+		if (!list_array)
+		{
+			insert_val(a, 0, temp);
+			return;
+		}
+		else
+		{
+			traverse_skip = (linked_list**)malloc(sizeof(linked_list*) * max_level);
+		}
+
+		traverse_list = list_array[level - 1];
+
+		for (i = (level - 1);i >= 0;i--)
+		{
+			previous_pointer = NULL;
+
+			if (j > 0)
+			{
+				while (j > 0)
+				{
+					traverse_list = traverse_list->getnext();
+					--j;
+				}
+			}
+
+			if (traverse_list == NULL)
+			{
+				cout<<"traverse_list is NULL"<<endl;
+			}
+			else
+			{
+				cout<<"traverse_list is not NULL"<<endl;
+			}
+
+			while (traverse_list != NULL && (traverse_list->getval()) < a)
+			{
+				cout<<"In loop 2"<<" "<<(traverse_list->getval())<<endl;
+				++j;
+				previous_pointer = traverse_list;
+				traverse_list = traverse_list->getnext();
+			}
+
+			traverse_skip[i] = previous_pointer;
+
+			traverse_list = list_array[i];
+		}
+
+		insert_val(0, j, temp);
+		/*for (i = 1;i <= (level - 1);i++)
+		{*/
+			
+	}
+
+
+	void print_val()
+	{
+		linked_list *traverse = NULL;
+
+		if (list_array)
+		{
+			traverse = list_array[0];
+		}
+
+		while (traverse != NULL)
+		{
+			cout<<"val is"<<" "<<traverse->getval()<<endl;
+			traverse = traverse->getnext();
+		}
+	}
+
+	int level_generate()
+	{
+		double rand_val = static_cast<double>(rand()) / RAND_MAX;
+		int level = 0;
+
+		while (rand_val > probability_val && level < max_level)
+		{
+			++level;
+			rand_val = static_cast<double>(rand()) / RAND_MAX;
+		}
+
+		return level;
+	}
+
+	int search_val(int key)
+	{
+		linked_list **traverse_skip = NULL;
+		linked_list *traverse_list = NULL;
+		int i = 0;
+		int j = 0;
+
+		i = curr_level;
+
+		if (!list_array)
+		{
+			return 0;
+		}
+		else
+		{
+			traverse_skip = (linked_list**)malloc(sizeof(linked_list*) * max_level);
+		}
+
+		traverse_list = list_array[curr_level - 1];
+
+		for (i = (curr_level - 1);i >= 0;i--)
+		{
+			if (j > 0)
+			{
+				while (j > 0)
+				{
+					traverse_list = traverse_list->getnext();
+					--j;
+				}
+			}
+
+			while (traverse_list != NULL && (traverse_list->getval()) != key)
+			{
+				cout<<"In loop 2"<<" "<<(traverse_list->getval())<<endl;
+				++j;
+				traverse_list = traverse_list->getnext();
+			}
+
+			if (traverse_list != NULL)
+			{
+				return 1;
+			}
+
+			traverse_list = list_array[i];
+		}
+
+		return -1;
+	}	
+};
+
+int main()
+{
+	srand(time(0));
+	int low = 0;
+	int high = 1;
+	int result_search = 0;
+	double dUniform = static_cast<double>(rand()) / RAND_MAX;
+	skip_list_master list1;
+	int val1 = list1.level_generate();
+
+	//list1.insert_val(1,0);
+	//list1.insert_val(2,0);
+	//list1.insert_val(4,0);
+	//list1.insert_val(7,0);
+	//list1.insert_val(6,0);
+
+	list1.insert_skip(1);
+	//list1.insert_skip(2);
+	//list1.insert_skip(3);
+	//list1.insert_skip(4);
+	//list1.insert_skip(5);
+
+
+	//list1.print_val();
+
+	result_search = list1.search_val(1);
+
+	cout<<"search result"<<" "<<result_search<<endl;
+
+	if (dUniform > 5)
+	{
+		cout<<"insertion"<<dUniform<<" "<<val1<<endl;
+	}
+	else
+	{
+		cout<<"no insertion"<<dUniform<<" "<<val1<<endl;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/FileReader.cpp
----------------------------------------------------------------------
diff --git a/test/FileReader.cpp b/test/FileReader.cpp
new file mode 100644
index 0000000..e87cd19
--- /dev/null
+++ b/test/FileReader.cpp
@@ -0,0 +1,52 @@
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <string>
+#include "../include/ConcMAT.h"
+
+using namespace std;
+
+std::string line;
+std::ifstream infile("sat.trn");
+
+int main()
+{
+int count;
+int arr_val[3];
+mat_tree *tree_val = NULL;
+
+tree_val = build_mattree(3);
+count = 0;
+while (std::getline(infile, line))  // this does the checking!
+{
+  std::istringstream iss(line);
+  char c;
+
+   int value;
+  while (iss >> value)
+  {
+	if (count == 3)
+	{
+		insert_val(arr_val, tree_val);
+		count = 0;
+		cout<<"record"<<endl;
+	}
+
+	arr_val[count] = value;
+	++count;
+  }
+}
+
+arr_val[0] = 91;
+arr_val[1] = 100;
+arr_val[2] = 81;
+
+if ((search_val(arr_val, tree_val)) != NULL)
+		{
+			cout<<"All values found"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found"<<endl;
+		}
+}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/FileReader.cpp~
----------------------------------------------------------------------
diff --git a/test/FileReader.cpp~ b/test/FileReader.cpp~
new file mode 100644
index 0000000..3e924fc
--- /dev/null
+++ b/test/FileReader.cpp~
@@ -0,0 +1,52 @@
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <string>
+#include "../ConcMAT.h"
+
+using namespace std;
+
+std::string line;
+std::ifstream infile("sat.trn");
+
+int main()
+{
+int count;
+int arr_val[3];
+mat_tree *tree_val = NULL;
+
+tree_val = build_mattree(3);
+count = 0;
+while (std::getline(infile, line))  // this does the checking!
+{
+  std::istringstream iss(line);
+  char c;
+
+   int value;
+  while (iss >> value) 
+  {
+	if (count == 3)
+	{
+		insert_val(arr_val, tree_val);
+		count = 0;
+		cout<<"record"<<endl;
+	}
+
+	arr_val[count] = value;
+	++count;
+  }
+}
+
+arr_val[0] = 91;
+arr_val[1] = 100;
+arr_val[2] = 81;
+
+if ((search_val(arr_val, tree_val)) != NULL)
+		{
+			cout<<"All values found"<<endl;
+		}
+		else
+		{
+			cout<<"All values not found"<<endl;
+		}
+}

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/QueueLockTest.cpp
----------------------------------------------------------------------
diff --git a/test/QueueLockTest.cpp b/test/QueueLockTest.cpp
new file mode 100644
index 0000000..1b28d40
--- /dev/null
+++ b/test/QueueLockTest.cpp
@@ -0,0 +1,43 @@
+#include<unistd.h>
+#include "../include/QueueLock.h"
+
+QueueLock GlobalQueueLock;
+void *thread_getlock_start(void *arg1)
+{
+	GlobalQueueLock.GetLock();
+	cout<<"Lock acquired by"<<" "<<(char*)arg1<<endl;
+	usleep(1);
+	GlobalQueueLock.ReleaseLock();
+}
+
+int main()
+{
+	int data_value = 5;
+	QueueLock lock1;
+	pthread_t tid1;
+	pthread_t tid2;
+	pthread_t tid3;
+	pthread_t tid4;
+	pthread_t tid5;
+	pthread_t tid6;
+	pthread_t tid7;
+	char name1[] = "thread1";
+	char name2[] = "thread2";
+	char name3[] = "thread3";
+	char name4[] = "thread4";
+	char name5[] = "thread5";
+
+	pthread_create(&tid1,NULL,thread_getlock_start,(void*)(name1));
+	pthread_create(&tid2,NULL,thread_getlock_start,(void*)(name2));
+	pthread_create(&tid3,NULL,thread_getlock_start,(void*)(name3));
+	pthread_create(&tid4,NULL,thread_getlock_start,(void*)(name4));
+	pthread_create(&tid5,NULL,thread_getlock_start,(void*)(name5));
+
+	pthread_join(tid1,NULL);
+	pthread_join(tid2,NULL);
+	pthread_join(tid3,NULL);
+	pthread_join(tid4,NULL);
+	pthread_join(tid5,NULL);
+}
+	
+

http://git-wip-us.apache.org/repos/asf/incubator-concerted/blob/fa6ba986/test/QueueLockTest.cpp~
----------------------------------------------------------------------
diff --git a/test/QueueLockTest.cpp~ b/test/QueueLockTest.cpp~
new file mode 100644
index 0000000..2e48f69
--- /dev/null
+++ b/test/QueueLockTest.cpp~
@@ -0,0 +1,43 @@
+#include<unistd.h>
+#include "../QueueLock.h"
+
+QueueLock GlobalQueueLock;
+void *thread_getlock_start(void *arg1)
+{
+	GlobalQueueLock.GetLock();
+	cout<<"Lock acquired by"<<" "<<(char*)arg1<<endl;
+	usleep(1);
+	GlobalQueueLock.ReleaseLock();
+}
+
+int main()
+{
+	int data_value = 5;
+	QueueLock lock1;
+	pthread_t tid1;
+	pthread_t tid2;
+	pthread_t tid3;
+	pthread_t tid4;
+	pthread_t tid5;
+	pthread_t tid6;
+	pthread_t tid7;
+	char name1[] = "thread1";
+	char name2[] = "thread2";
+	char name3[] = "thread3";
+	char name4[] = "thread4";
+	char name5[] = "thread5";
+
+	pthread_create(&tid1,NULL,thread_getlock_start,(void*)(name1));
+	pthread_create(&tid2,NULL,thread_getlock_start,(void*)(name2));
+	pthread_create(&tid3,NULL,thread_getlock_start,(void*)(name3));
+	pthread_create(&tid4,NULL,thread_getlock_start,(void*)(name4));
+	pthread_create(&tid5,NULL,thread_getlock_start,(void*)(name5));
+
+	pthread_join(tid1,NULL);
+	pthread_join(tid2,NULL);
+	pthread_join(tid3,NULL);
+	pthread_join(tid4,NULL);
+	pthread_join(tid5,NULL);
+}
+	
+



Mime
View raw message