a sparqly jython++ an asp/sparql enhanced jython

9
A SParqly Jython++ A SParqly Jython++ an ASP/SPARQL enhanced Jython Cliff Cheng Carlos Urrutia Francisco Garcia

Upload: jaden-valenzuela

Post on 02-Jan-2016

44 views

Category:

Documents


1 download

DESCRIPTION

A SParqly Jython++ an ASP/SPARQL enhanced Jython. Cliff Cheng Carlos Urrutia Francisco Garcia. Summary. Improving ASPJython++ by incorporating homeworks. (SPARQL not fully supported, joins, update, delete, etc,.) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: A SParqly Jython++ an ASP/SPARQL enhanced Jython

A SParqly Jython++A SParqly Jython++an ASP/SPARQL enhanced Jython

Cliff Cheng Carlos Urrutia

Francisco Garcia

Page 2: A SParqly Jython++ an ASP/SPARQL enhanced Jython

Summary

Improving ASPJython++ by incorporating homeworks. (SPARQL not fully supported, joins, update, delete, etc,.)

Added syntax to be allow conversion of a RDF database into ASP/Prolog facts by returning a Tuple.

Added syntax to be able to create RDF table from SQL table, using the Tuple as the return type.

Use of Oracle Sequence as a GUID.

Page 3: A SParqly Jython++ an ASP/SPARQL enhanced Jython

Phyton.gThese tokens behave like the regular SELECT.

The grammar will check for syntax correctness.

Since the format of ASPSELECT and RDFSELECT is similar as SELECT, we just treated them as SQL grammar, which implies no need to build a node of type Tuple (Tuple.java) because SQL node were already created by Frank, and so the conversion of the nodes into python objects(CodeCompiler.java).

......

| (ASPSELECT sqlquery SEMI {$sql_stmt::strings.add($sql_stmt::temp); }| (ASPSELECT sqlquery SEMI {$sql_stmt::strings.add($sql_stmt::temp); }

-> ^(ASPSELECT<Tuple>[$sql_stmt.start, actions.castExprs($sql_stmt::exprs), $expr::ctype,-> ^(ASPSELECT<Tuple>[$sql_stmt.start, actions.castExprs($sql_stmt::exprs), $expr::ctype,$sql_stmt::strings, $connection::url, $connection::uname, $connection::pword]))$sql_stmt::strings, $connection::url, $connection::uname, $connection::pword]))

| (RDFSELECT sqlquery SEMI {$sql_stmt::strings.add($sql_stmt::temp); }| (RDFSELECT sqlquery SEMI {$sql_stmt::strings.add($sql_stmt::temp); }

-> ^(RDFSELECT<Tuple>[$sql_stmt.start, actions.castExprs($sql_stmt::exprs), $expr::ctype,-> ^(RDFSELECT<Tuple>[$sql_stmt.start, actions.castExprs($sql_stmt::exprs), $expr::ctype,$sql_stmt::strings, $connection::url, $connection::uname, $connection::pword]))$sql_stmt::strings, $connection::url, $connection::uname, $connection::pword]))

……

//new Tokens to help get ASP/Prolog facts //new Tokens to help get ASP/Prolog facts

ASPSELECT :ASPSELECT : 'ASPSELECT';'ASPSELECT';

RDFSELECT :RDFSELECT : 'RDFSELECT';'RDFSELECT';

Page 4: A SParqly Jython++ an ASP/SPARQL enhanced Jython

PyTuple.java Here is where Tuples get evaluated.

The use of ASPSELECT is to indicate weather we return the RDF “triple” parsed into (SUB, PRED, OBJ) without the RDF format, to be used by end users to create ASP/Prolog facts.

RDFSELECT is used to create an RDF table from a SQL table.

But this new created syntax are best used with *, because ASPSELECT uses an RDF database, so you probably want to get the whole tuple as (SUB, PRED, OBJ)

Note: This does not mean it only works with *.

Sample syntax:

ASPSELECT * FROM SOMETABLE;ASPSELECT * FROM SOMETABLE;

RDFSELECT * FROM SOMETABLE;RDFSELECT * FROM SOMETABLE;

Page 5: A SParqly Jython++ an ASP/SPARQL enhanced Jython

PyTuple.java (some code)

PyTuple.java

Page 6: A SParqly Jython++ an ASP/SPARQL enhanced Jython

Oracle Sequence

In order for ASPSELECTASPSELECT to work properly, the way the guid was implemented for the INSERT statements had to be modified.

Before: every separate session's INSERTINSERT to the same RDF table would reset the guid to 1, since there will not be prior records of the last guid used.

Now: Oracle sequence: What is an Oracle sequence? A sequence is an object in Oracle to generate a number sequence. Useful to act as a primary key, here for our guid.

Page 7: A SParqly Jython++ an ASP/SPARQL enhanced Jython

Oracle Sequnce Syntax

CREATE SEQUENCE sequence_name

MINVALUE value

MAXVALUE value

START WITH value

INCREMENT BY value

CACHE value;

Way implemented: //Create sequence

stmt.executeQuery("CREATE SEQUENCE stmt.executeQuery("CREATE SEQUENCE "+caststmt.getTable()+"_RDF_DATA_sqnc "+caststmt.getTable()+"_RDF_DATA_sqnc MINVALUE 1 START WITH 1 INCREMENT BY MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE");1 NOCACHE");

//Drop sequence

stmt.executeQuery("DROP SEQUENCE stmt.executeQuery("DROP SEQUENCE "+caststmt.getName()+"_RDF_DATA_sqnc");"+caststmt.getName()+"_RDF_DATA_sqnc");

//To get next value in sequence

OracleResultSet rs2 = OracleResultSet rs2 = (OracleResultSet)stmt.executeQuery("SELECT (OracleResultSet)stmt.executeQuery("SELECT " + tableName + "_RDF_DATA_sqnc.nextval " + tableName + "_RDF_DATA_sqnc.nextval FROM dual");FROM dual");

Page 8: A SParqly Jython++ an ASP/SPARQL enhanced Jython

Concepts

Tokens Terminal Non-terminal Context-Free grammar Abstract Syntax Tree

ASP/Prolog facts and rules

SQL SPARQL RDF Concepts

Page 9: A SParqly Jython++ an ASP/SPARQL enhanced Jython

Improvements

Keep working on fully supporting SPARQL (joins,delete,update) Make ASP/Prolog more dynamic Keep integrating more languages(Lisp, Haskell,

etc) :-)