Transcript jASP_Bell

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,.)
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.
Phyton.g
These 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<Tuple>[$sql_stmt.start, actions.castExprs($sql_stmt::exprs),
$expr::ctype,$sql_stmt::strings, $connection::url, $connection::uname,
$connection::pword]))
| (RDFSELECT sqlquery SEMI {$sql_stmt::strings.add($sql_stmt::temp); }
-> ^(RDFSELECT<Tuple>[$sql_stmt.start, actions.castExprs($sql_stmt::exprs),
$expr::ctype,$sql_stmt::strings, $connection::url, $connection::uname,
$connection::pword]))
…
//new Tokens to help get ASP/Prolog facts
ASPSELECT : 'ASPSELECT';
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;

RDFSELECT * FROM SOMETABLE;
PyTuple.java (some code)

PyTuple.java
Oracle Sequence



In order for ASPSELECT to work properly, the way
the guid was implemented for the INSERT
statements had to be modified.
Before: every separate session's INSERT 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.
Oracle Sequnce Syntax

CREATE SEQUENCE
sequence_name
Way implemented:

MINVALUE value
//Create sequence

MAXVALUE value

START WITH value

INCREMENT BY value
stmt.executeQuery("CREATE SEQUENCE
"+caststmt.getTable()+"_RDF_DATA_sqnc
MINVALUE 1 START WITH 1 INCREMENT BY
1 NOCACHE");

CACHE value;
//Drop sequence
stmt.executeQuery("DROP SEQUENCE
"+caststmt.getName()+"_RDF_DATA_sqnc");
//To get next value in sequence
OracleResultSet rs2 =
(OracleResultSet)stmt.executeQuery("SELECT
" + tableName + "_RDF_DATA_sqnc.nextval
FROM dual");
Concepts

Tokens

Terminal
ASP/Prolog facts and
rules

Non-terminal
SQL

Context-Free grammar
SPARQL

Abstract Syntax Tree
RDF Concepts
Improvements

Keep working on fully supporting SPARQL

(joins,delete,update)

Make ASP/Prolog more dynamic

Keep integrating more languages(Lisp, Haskell, etc)
:-)