^(ASP_SELECT [$asp_stmt.start, actions.castExprs($asp_stmt::exprs), $expr::ctype, $asp_stmt::strings, $asp_stmt::append, true]))"> ^(ASP_SELECT [$asp_stmt.start, actions.castExprs($asp_stmt::exprs), $expr::ctype, $asp_stmt::strings, $asp_stmt::append, true]))">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

ASPJ YLOG +SQL Integration of SQL functionality into ASPJylog++ Russell Beavers Srijith Prabhu Venkat Yerramsetti.

Similar presentations


Presentation on theme: "ASPJ YLOG +SQL Integration of SQL functionality into ASPJylog++ Russell Beavers Srijith Prabhu Venkat Yerramsetti."— Presentation transcript:

1 ASPJ YLOG +SQL Integration of SQL functionality into ASPJylog++ Russell Beavers Srijith Prabhu Venkat Yerramsetti

2 Regular fact: Ex1: married(mrAstor, mrsAstor). Ex2: data(0, 30, 60). Group fact: Ex: male(mrAstor;mrBlake;mrCrane;mrDavis). Two types of facts:

3 Grammar for setting options for SELECT FORMAT: ASP_SELECT [fact_type] [fact_name] From Python.g: (ASP_SELECT (REG_FACT{$asp_stmt::strings.add("reg_fact");} | GROUP_FACT{$asp_stmt::strings.add("group_fact");}) NAME{$asp_stmt::strings.add($NAME.text);} -> ^(ASP_SELECT [$asp_stmt.start, actions.castExprs($asp_stmt::exprs), $expr::ctype, $asp_stmt::strings, $asp_stmt::append, true]))

4 Tokens added to support the grammar for options //*******lexer rules for asp*************** ASP: 'ASP'; ASPBLANKQ:'?-.'; ASPPRINTDB : 'PRINT'; ASPLC:'!{'; ASPDOTDOT:'..'; REG_FACT:'?<<'; GROUP_FACT:'?@@'; ASP_SELECT:'ASP_SELECT'; //*******end of lexer rules for asp********

5 This code determines if the fact is a regular fact or a group fact, and gets the name to be given to the fact From PyTuple.java: else if (as_attr[0].equals("reg_fact")){ asp_select = true; fact_type = as_attr[0]; fact_name = as_attr[1]; } else if (as_attr[0].equals("group_fact")){ asp_select = true; fact_type = as_attr[0]; fact_name = as_attr[1]; } Code added to process the options for ASP SELECT

6 Code from Homework 5 Here, we modify the tuples returned by SELECT from a remote database public PyTuple(PyType subtype, PyObject[] elements, String sqlstrings, String server, String uname, String pword, String ctype) { ArrayList rows = new ArrayList (); if(ctype.equals("remote")) { System.out.println(sqlstmt); Statement stmt = conn.createStatement(); if (statement instanceof Select) { try{ OracleResultSet rs = (OracleResultSet) stmt.executeQuery(sqlstmt); ResultSetMetaData rd=rs.getMetaData();

7 if ( fact_type.equals("reg_fact")){ asp_fact += ((PyString)temp[0]).toString(); for (int i=1 ; i < temp.length ; i++){ asp_fact += "," + ((PyString)temp[i]).toString(); } else { if (first_item){ asp_fact += ((PyString)temp[0]).toString(); first_item = false; } else { asp_fact += ";" + ((PyString)temp[0]).toString(); } Code to modify the tuples obtained from a Remote database

8 if ( fact_type.equals("reg_fact")){ asp_fact += ")."; f.write(asp_fact); f.write("\n"); asp_fact = fact_name + "("; } if ( fact_type.equals("group_fact")){ asp_fact += ")."; f.write(asp_fact); f.write("\n"); } if(asp_select) { asp_select = false; fact_type = ""; fact_name = ""; } Code to modify the tuples obtained from a Remote database (continued)

9 The tuples obtained from a local database are modified in the convertToRDF method public ArrayList convertToRDF(net.sf.jsqlparser.statement.Statement statement, OracleConnection conn) {

10 if ( fact_type.equals("reg_fact")){ fact_element = ((PyString)temp[0]).toString(); slash_index = fact_element.lastIndexOf("/"); asp_fact += fact_element.substring(slash_index + 1); for (int i=1 ; i < temp.length ; i++){ fact_element = ((PyString)temp[i]).toString(); slash_index = fact_element.lastIndexOf("/"); asp_fact += "," + fact_element.substring(slash_index + 1); } } else { fact_element = ((PyString)temp[0]).toString(); slash_index = fact_element.lastIndexOf("/"); if (first_item){ asp_fact += fact_element.substring(slash_index + 1); first_item = false; } else { asp_fact += ";" + fact_element.substring(slash_index + 1); } Code to modify the tuples obtained from a local database

11 if ( fact_type.equals("reg_fact")){ asp_fact += ")."; f.write(asp_fact); f.write("\n"); asp_fact = fact_name + "("; } if ( fact_type.equals("group_fact")){ asp_fact += ")."; f.write(asp_fact); f.write("\n"); } if(asp_select) { asp_select = false; fact_type = ""; fact_name = ""; } Code to modify the tuples obtained from a local database (continued)

12 Example Queries For Facts ASP_SELECT ?<< male SELECT NAME FROM DINERS WHERE GENDER = ‘Male’; - gives male(mrA;mrB;mrC). ASP_SELECT ?@@ married SELECT NAME, SPOUSE FROM DINERS; - gives married(mrA,mrsA).

13 Concepts Covered Tokens ASP Prolog SQL RDF


Download ppt "ASPJ YLOG +SQL Integration of SQL functionality into ASPJylog++ Russell Beavers Srijith Prabhu Venkat Yerramsetti."

Similar presentations


Ads by Google