README
--------
The code has been written on an Ubuntu 18.04 machine with Java 10 and postgreSQL v9.6

Installation Instructions (with Eclipse):
---------------------------------------
1. Extract the "hydra" folder from the downloaded zip. 
2. File->Import->Projects from Folder or Archive.
3. Select codd-data-gen folder inside hydra folder.
4. Add resources folder, present inside codd-data-gen folder, in the build path. 
5. Add the lib folder, present inside the codd-data-gen folder, in the libraries path if not automatically added.

Note: If there is an exception concerning Z3, you may have to install it separately. (Install Z3 library configured for Java. (https://github.com/Z3Prover/z3).) Ensure the library is in the path.

PostgreSQL Setup:
-----------------
Create the desired database in potgreSQL v9.6.
Open the postresql.conf file in the database location and add the following lines:
	enable_bitmapscan=off
	enable_indexscan=off
	enable_nestloop=off
	enable_sort=off


Running Instructions:
---------------------------------------
1. Open hydra/codd-data-gen/resources/cdgclient/postgres.properties file; update connection string, username, password and dbname to establish database connection.
2. Extract the "test" folder from the downloaded zip in the directory containing the hydra folder.
3. The input to Hydra is given as query plans in JSON format. To run the queries and obtain the plans: (a) Add the input queries as SQL files in the test/sqlqueries folder; (b) list these queries in the test/sqlqueries/index file. A sample of three queries q1.sql,q2.sql,q3.sql is present in the folder, along with the sample index file.
4. The query plans in JSON format are generated automatically in the test/ea folder. List the plans to be given as input in the test/ea/index file. A sample of three plans, q1.json, q2.json, q3.json, is already present in the folder, along with a sample index file.
5. Execute codd-data-gen/src/in/ac/iisc/cds/dsl/cdg/main/Main.java


Note: After successfully running Hydra, the final output, in the form of a database summary, is obtained in the test/databasesummary folder.


Query Assumptions:
--------------------
1. Each query is of the form: SELECT * FROM <tablenames> WHERE <filter-predicates>.
2. All join conditions are between Primary Key-Foreign Key.
3. Filter predicates on Non-Key Columns.

Data Assumptions:
-------------------
No Null values in Foreign Key columns.