This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
magik-demo:developer:class:core:queryspecialization [2013/08/22 10:32] alex [getQuerySpecializations] |
magik-demo:developer:class:core:queryspecialization [2017/07/06 15:24] (current) |
||
---|---|---|---|
Line 57: | Line 57: | ||
</code> | </code> | ||
- | Main method of this class, that given an incomplete query computes complete query specializations of that query given that currentTCs are true and schema constraints from currentSchema holds. Based on the constant PROLOG_SELECTION, Magik runs two different prolog engines. | + | Method that manage the query specializations algorithm for SWI Prolog |
- | //Called by:// | ||
- | * it.unibz.inf.magik.core.TCQCReasoner | ||
- | * it.unibz.inf.magik.test.TestQuerySpecialization | ||
**Parameters:** | **Parameters:** | ||
* Query - query that we want to find their specialization versions | * Query - query that we want to find their specialization versions | ||
Line 73: | Line 70: | ||
- | [[magik-demo:developer:class:core:queryspecialization|Back to Top]] | [[magik-demo:start|Back to Home Page]] | + | ---- |
+ | |||
+ | ==== getQuerySpecializationsTuProlog ==== | ||
+ | |||
+ | <code java> | ||
+ | public static Query getQueryGeneralizationsTuProlog (Query query, | ||
+ | java.util.ArrayList<TCStatement> currentTCs, | ||
+ | Schema currentSchema, | ||
+ | int maximal) | ||
+ | throws Exception | ||
+ | </code> | ||
+ | |||
+ | Method that manage the query specializations algorithm for Tu Prolog | ||
+ | |||
+ | **Parameters:** | ||
+ | * Query - query that we want to find their specialization versions | ||
+ | * currentTCs - which data are complete, expressed in TC-statements | ||
+ | * currentSchema - database schema (that contains finite domain constraints and foreign keys) | ||
+ | * maximal - maximal number of atoms that Magik can add for calculating specialization queries | ||
+ | **Returns:** | ||
+ | * Returned specialization are maximal (in query containment sense) | ||
+ | **Throws:** | ||
+ | * Exception | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== generateInput ==== | ||
+ | |||
+ | <code java> | ||
+ | public static java.lang.String generateInput (java.util.ArrayList<TCStatement> currentTCs, | ||
+ | Schema schema, | ||
+ | int maxQSpecSize) | ||
+ | </code> | ||
+ | |||
+ | Method that encodes in Prolog currentSchema and TC-statements | ||
+ | |||
+ | **Parameters:** | ||
+ | * currentTCs - which data are complete, expressed in TC-statements | ||
+ | * schema - database schema (that contains finite domain constraints and foreign keys) | ||
+ | * maxQSpecSize - maximal number of atoms that Magik can add for calculating specialization queries | ||
+ | **Returns:** | ||
+ | * String that contains all the prolog code for the given schema and tc-statements | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== generateInput ==== | ||
+ | |||
+ | <code java> | ||
+ | public static java.lang.String generateInput (java.util.ArrayList<TCStatement> currentTCs, | ||
+ | Schema schema, | ||
+ | int maxQSpecSize) | ||
+ | </code> | ||
+ | |||
+ | Method that encodes in Prolog currentSchema and TC-statements | ||
+ | |||
+ | **Parameters:** | ||
+ | * currentTCs - which data are complete, expressed in TC-statements | ||
+ | * schema - database schema (that contains finite domain constraints and foreign keys) | ||
+ | * maxQSpecSize - maximal number of atoms that Magik can add for calculating specialization queries | ||
+ | **Returns:** | ||
+ | * String that contains all the prolog code for the given schema and tc-statements | ||
+ | |||
+ | ---- | ||
+ | |||
+ | === generatePrologEnfFKs === | ||
+ | |||
+ | <code java> | ||
+ | public static java.util.ArrayList<java.lang.String> generatePrologEnfFKs (java.util.ArrayList<ForeignKey> fks) | ||
+ | </code> | ||
+ | |||
+ | Method that encodes in Prolog Foreign Keys enforced | ||
+ | |||
+ | ---- | ||
+ | |||
+ | === generatePrologRels === | ||
+ | |||
+ | <code java> | ||
+ | public static java.util.ArrayList<java.lang.String> generatePrologRels (Schema schema) | ||
+ | </code> | ||
+ | |||
+ | Method that encodes in Prolog relations of the schema selected | ||
+ | |||
+ | ---- | ||
+ | |||
+ | === generatePrologTCs === | ||
+ | |||
+ | <code java> | ||
+ | public static java.util.ArrayList<java.lang.String> generatePrologEnfTCs (java.util.ArrayList<TCStatement> tcs) | ||
+ | </code> | ||
+ | |||
+ | Method that encodes in Prolog TC-Statements | ||
+ | |||
+ | ---- | ||
+ | |||
+ | === generatePrologFDCs === | ||
+ | |||
+ | <code java> | ||
+ | public static java.util.ArrayList<java.lang.String> generatePrologFDCs (java.util.ArrayList<FiniteDomainContraint> fdcs) | ||
+ | </code> | ||
+ | |||
+ | Method that encodes in Prolog finite domain constraints. For each FDC we call generatePrologFDC. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | === generatePrologFDC === | ||
+ | |||
+ | <code java> | ||
+ | public static java.lang.String generatePrologFDCs (FiniteDomainContraint fdc) | ||
+ | </code> | ||
+ | |||
+ | Method that encodes in Prolog a finite domain constraint. | ||
+ | |||
+ | -------- | ||
+ | |||
+ | === createInputFile === | ||
+ | |||
+ | <code java> | ||
+ | private static java.lang.String createInputFile (java.util.ArrayList<java.lang.String> prologFKsNotEnf, | ||
+ | java.util.ArrayList<java.lang.String> prologFKsEnf, | ||
+ | java.util.ArrayList<java.lang.String> prologRels, | ||
+ | java.util.ArrayList<java.lang.String> prologPKs, | ||
+ | java.util.ArrayList<java.lang.String> prologTCs, | ||
+ | java.lang.String prologFDCs, | ||
+ | java.lang.String prologQuery) | ||
+ | </code> | ||
+ | |||
+ | Method that creates the final Prolog string for the schema, query and tc-statements. | ||
+ | |||
+ | -------- | ||
+ | |||
+ | === createInputGUI === | ||
+ | |||
+ | <code java> | ||
+ | private static java.lang.String createInputGUI (java.util.ArrayList<java.lang.String> prologFKsNotEnf, | ||
+ | java.util.ArrayList<java.lang.String> prologFKsEnf, | ||
+ | java.util.ArrayList<java.lang.String> prologRels, | ||
+ | java.util.ArrayList<java.lang.String> prologPKs, | ||
+ | java.util.ArrayList<java.lang.String> prologTCs, | ||
+ | java.lang.String prologFDCs) | ||
+ | </code> | ||
+ | |||
+ | Method that creates the final Prolog string for the schema and tc-statements that MAGIK will visualize in the GUI. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== readMeta ==== | ||
+ | |||
+ | <code java> | ||
+ | public static java.util.ArrayList<java.lang.String> generatePrologNotEnfFKs (java.util.ArrayList<ForeignKey> fks) | ||
+ | </code> | ||
+ | |||
+ | Method that reads the file with the program that runs the input generated (used in GUI) | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== generateQuery ==== | ||
+ | |||
+ | <code java> | ||
+ | public static java.lang.String generateQuery (Query query)</code> | ||
+ | |||
+ | Method that generate a part of the command used for call specialization algorithm | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== generateCommand ==== | ||
+ | |||
+ | <code java> | ||
+ | public static java.lang.String generateCommand (java.lang.String q4p, | ||
+ | int maximal) | ||
+ | </code> | ||
+ | Method that generate the command used for call specialization algorithm | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== parseQuerySpecializationsTUProlog ==== | ||
+ | |||
+ | <code java> | ||
+ | public static java.util.ArrayList<Query> parseQuerySpecializationsTuProlog (Query query, | ||
+ | Schema schema, | ||
+ | SolveInfo info) | ||
+ | throws ContextException, | ||
+ | NoSolutionException | ||
+ | </code> | ||
+ | |||
+ | Method that analyses the solutions given by Prolog and returns the list of the specialization (if there are) | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== getters and setters methods ==== | ||
+ | |||
+ | <code java> | ||
+ | public static java.lang.String getProlog_enconding() | ||
+ | public static void setProlog_enconding (java.lang.String prolog_enconding) | ||
+ | |||
+ | public static java.lang.String getQueryForProlog() | ||
+ | public static void setQueryForProlog(java.lang.String queryForProlog) | ||
+ | |||
+ | public static java.lang.String getMetaProlog() | ||
+ | public static void setMetaProlog(java.lang.String metaProlog) | ||
+ | |||
+ | public static java.lang.String getCommandQuery() | ||
+ | public static void setCommandQuery(java.lang.String commandQuery) | ||
+ | |||
+ | public static long getExecutionTime() | ||
+ | public static void setExecutionTime(long executionTime) | ||
+ | |||
+ | public static java.lang.String getEncodingGUI() | ||
+ | public static void setEncodingGUI(java.lang.String encodingGUI) | ||
+ | |||
+ | </code> |