You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by sa...@apache.org on 2012/11/29 23:43:46 UTC
svn commit: r1415420 [1/3] - in /jena/branches/streaming-update:
jena-arq/Grammar/ jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/
jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/arq/
jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/sparql_10/...
Author: sallen
Date: Thu Nov 29 22:43:42 2012
New Revision: 1415420
URL: http://svn.apache.org/viewvc?rev=1415420&view=rev
Log:
JENA-330 and JENA-309 Add streaming update support
Added:
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/AbstractUpdateSink.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateEngineStreaming.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateProcessorStreamingBase.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateRequestSink.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateSink.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateVisitorSink.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UsingList.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/QuadAccSink.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/QuadDataAccSink.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/update/UpdateProcessorStreaming.java
Modified:
jena/branches/streaming-update/jena-arq/Grammar/arq.jj
jena/branches/streaming-update/jena-arq/Grammar/master.jj
jena/branches/streaming-update/jena-arq/Grammar/sparql_11.jj
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserARQUpdate.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserBase.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserSPARQL11Update.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/SPARQLParserBase.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/UpdateParser.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/arq/ARQParser.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/sparql_10/SPARQLParser10.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/sparql_11/SPARQLParser11.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateEngineBase.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateEngineFactory.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateEngineMain.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateEngineRegistry.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateEngineWorker.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/QuadAcc.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/QuadDataAcc.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateVisitor.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/syntax/ElementPathBlock.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/syntax/ElementTriplesBlock.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/syntax/TripleCollector.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/syntax/TripleCollectorBGP.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/update/UpdateAction.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/update/UpdateExecutionFactory.java
jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/update/UpdateFactory.java
jena/branches/streaming-update/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java
jena/branches/streaming-update/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Update.java
jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/modify/UpdateEngineTDB.java
Modified: jena/branches/streaming-update/jena-arq/Grammar/arq.jj
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-arq/Grammar/arq.jj?rev=1415420&r1=1415419&r2=1415420&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-arq/Grammar/arq.jj (original)
+++ jena/branches/streaming-update/jena-arq/Grammar/arq.jj Thu Nov 29 22:43:42 2012
@@ -357,13 +357,27 @@ void ValuesClause() : { Token t ; }
}
// SPARQL Update + transitional extensions for SPARQL/Update (the W3C submission)
// Update only entry point
-// Optional SEMICOLON
void Update() : { }
{
- Prologue()
- ( Update1() (<SEMICOLON>)* Update())?
+ // Rewrite for no recursion - grammar is not LL(1)
+ Prologue()
+ (
+ Update1()
+ (
+ LOOKAHEAD( <SEMICOLON> Prologue() ( <LOAD> | <CLEAR> | <DROP> | <ADD> |
+ <MOVE> | <COPY> | <CREATE> | <WITH> | <DELETE> | <INSERT> |
+ <USING> | <INSERT_DATA> | <DELETE_DATA> | <DELETE_WHERE> ) )
+ <SEMICOLON>
+ Prologue()
+ Update1()
+ )*
+ (
+ <SEMICOLON>
+ Prologue()
+ )?
+ )?
}
-void Update1() : { Update up ; }
+void Update1() : { Update up = null ; }
{
{ startUpdateOperation() ; }
( up = Load()
@@ -373,13 +387,13 @@ void Update1() : { Update up ; }
| up = Move()
| up = Copy()
| up = Create()
- | up = InsertData()
- | up = DeleteData()
| up = DeleteWhere()
| up = Modify()
+ | InsertData()
+ | DeleteData()
)
{
- emitUpdate(up) ;
+ if (null != up) emitUpdate(up) ;
finishUpdateOperation() ;
}
}
@@ -421,38 +435,41 @@ Update Copy() : { Target src ; Target de
{ return new UpdateCopy(src, dest, silent) ; }
}
// #ifdef ARQ
-// void Meta() : { QuadDataAcc qd = new QuadDataAcc() ; }
+// void Meta() : { QuadDataAccSink qd = new QuadDataAccSink() ; }
// {
// <META>
// QuadData(qd)
// }
// #endif
-Update InsertData() : { QuadDataAcc qd = new QuadDataAcc() ; Token t ; }
+void InsertData() : { QuadDataAccSink qd = getInsertDataSink() ; Token t ; }
{
t = <INSERT_DATA>
- { startDataInsert(qd, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDataInsert(qd, beginLine, beginColumn) ; }
QuadData(qd)
{
- finishDataInsert(qd, t.beginLine, t.beginColumn) ;
- return new UpdateDataInsert(qd) ;
+ finishDataInsert(qd, beginLine, beginColumn) ;
+ qd.close() ;
}
}
-Update DeleteData() : { QuadDataAcc qd = new QuadDataAcc() ; Token t ; }
+void DeleteData() : { QuadDataAccSink qd = getDeleteDataSink() ; Token t ; }
{
t = <DELETE_DATA>
- { startDataDelete(qd, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDataDelete(qd, beginLine, beginColumn) ; }
QuadData(qd)
{
- finishDataDelete(qd, t.beginLine, t.beginColumn) ;
- return new UpdateDataDelete(qd) ;
+ finishDataDelete(qd, beginLine, beginColumn) ;
+ qd.close() ;
}
}
Update DeleteWhere() : { QuadAcc qp = new QuadAcc() ; Token t ; }
{
t = <DELETE_WHERE>
- { startDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDeleteTemplate(qp, beginLine, beginColumn) ; }
QuadPattern(qp)
- { finishDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { finishDeleteTemplate(qp, beginLine, beginColumn) ; }
{ return new UpdateDeleteWhere(qp) ; }
}
Update Modify() : { Element el ; String iri = null ;
@@ -475,17 +492,19 @@ Update Modify() : { Element el ; String
void DeleteClause(UpdateModify up) : { QuadAcc qp = up.getDeleteAcc() ; Token t ;}
{
t = <DELETE>
- { startDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDeleteTemplate(qp, beginLine, beginColumn) ; }
QuadPattern(qp)
- { finishDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { finishDeleteTemplate(qp, beginLine, beginColumn) ; }
{ up.setHasDeleteClause(true) ; }
}
void InsertClause(UpdateModify up) : { QuadAcc qp = up.getInsertAcc() ; Token t ; }
{
t = <INSERT>
- { startInsertTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startInsertTemplate(qp, beginLine, beginColumn) ; }
QuadPattern(qp)
- { finishInsertTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { finishInsertTemplate(qp, beginLine, beginColumn) ; }
{ up.setHasInsertClause(true) ; }
}
void UsingClause(UpdateWithUsing update) : { String iri ; Node n ; }
@@ -526,13 +545,13 @@ void QuadPattern(QuadAcc acc) : { }
<RBRACE>
}
//Ground data : As QuadPattern but don't allow variables.
-void QuadData(QuadDataAcc acc) : { }
+void QuadData(QuadDataAccSink acc) : { }
{
<LBRACE>
Quads(acc)
<RBRACE>
}
-void Quads(QuadAcc acc) : { }
+void Quads(QuadAccSink acc) : { }
{
(TriplesTemplate(acc))?
(
@@ -541,7 +560,7 @@ void Quads(QuadAcc acc) : { }
(TriplesTemplate(acc))?
)*
}
-void QuadsNotTriples(QuadAcc acc) : {Node gn ; Node prev = acc.getGraph() ; }
+void QuadsNotTriples(QuadAccSink acc) : {Node gn ; Node prev = acc.getGraph() ; }
{
<GRAPH> gn = VarOrIri()
{ setAccGraph(acc, gn) ; }
@@ -561,11 +580,12 @@ void TriplesTemplate(TripleCollector acc
Element GroupGraphPattern() : { Element el = null ; Token t ; }
{
t = <LBRACE>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
(
- { startSubSelect(t.beginLine, t.beginColumn) ; }
+ { startSubSelect(beginLine, beginColumn) ; }
SubSelect()
{
- Query q = endSubSelect(t.beginLine, t.beginColumn) ;
+ Query q = endSubSelect(beginLine, beginColumn) ;
el = new ElementSubQuery(q) ;
}
| el = GroupGraphPatternSub()
@@ -674,10 +694,11 @@ Element Bind() : { Var v ; Expr expr ; }
Element InlineData() : { ElementData el ; Token t ; }
{
t = <VALUES>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
{ el = new ElementData() ;
- startInlineData(el.getVars(), el.getRows(), t.beginLine, t.beginColumn) ; }
+ startInlineData(el.getVars(), el.getRows(), beginLine, beginColumn) ; }
DataBlock()
- { finishInlineData(t.beginLine, t.beginColumn) ;
+ { finishInlineData(beginLine, beginColumn) ;
return el ; }
}
void DataBlock() : { }
@@ -698,30 +719,33 @@ void InlineDataOneVar() : { Var v ; Node
)*
t = <RBRACE>
}
-void InlineDataFull() : { Var v ; Node n ; Token t ; }
+void InlineDataFull() : { Var v ; Node n ; Token t ; int beginLine; int beginColumn; }
{
(
<NIL>
|
- t = <LPAREN>
+ <LPAREN>
(v = Var() { emitDataBlockVariable(v) ; })*
- t = <RPAREN>
+ <RPAREN>
)
- t = <LBRACE>
+ <LBRACE>
(
t = <LPAREN>
- { startDataBlockValueRow(t.beginLine, t.beginColumn) ; }
+ { beginLine = t.beginLine; beginColumn = t.beginColumn; t = null; }
+ { startDataBlockValueRow(beginLine, beginColumn) ; }
(n = DataBlockValue()
- { emitDataBlockValue(n, t.beginLine, t.beginColumn) ; }
+ { emitDataBlockValue(n, beginLine, beginColumn) ; }
) *
t = <RPAREN>
- { finishDataBlockValueRow(t.beginLine, t.beginColumn) ; }
+ { beginLine = t.beginLine; beginColumn = t.beginColumn; t = null; }
+ { finishDataBlockValueRow(beginLine, beginColumn) ; }
|
t = <NIL>
- { startDataBlockValueRow(t.beginLine, t.beginColumn) ; }
- { finishDataBlockValueRow(t.beginLine, t.beginColumn) ; }
+ { beginLine = t.beginLine; beginColumn = t.beginColumn; t = null; }
+ { startDataBlockValueRow(beginLine, beginColumn) ; }
+ { finishDataBlockValueRow(beginLine, beginColumn) ; }
)*
- t = <RBRACE>
+ <RBRACE>
}
Node DataBlockValue() : { Node n ; String iri ; }
{
@@ -812,10 +836,11 @@ ExprList ArgList() : { Expr expr ; boole
|
<LPAREN>
(t = <DISTINCT> { distinct = true ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
{
if ( ! allowAggregatesInExpressions )
throwParseException("Aggregate expression not legal at this point",
- t.beginLine, t.beginColumn) ;
+ beginLine, beginColumn) ;
}
)?
expr = Expression() { args.add(expr) ; }
@@ -895,9 +920,8 @@ void ObjectList(Node s, Node p, Path pat
}
void Object(Node s, Node p, Path path, TripleCollector acc): { Node o ; }
{
- { int mark = acc.mark() ; }
o = GraphNode(acc)
- { insert(acc, mark, s, p, path, o) ; }
+ { insert(acc, s, p, path, o) ; }
}
// -------- BGPs with paths.
// -------- Entry point: TriplesSameSubjectPath
@@ -949,9 +973,8 @@ void ObjectListPath(Node s, Node p, Path
}
void ObjectPath(Node s, Node p, Path path, TripleCollector acc): { Node o ; }
{
- { int mark = acc.mark() ; }
o = GraphNodePath(acc)
- { insert(acc, mark, s, p, path, o) ; }
+ { insert(acc, s, p, path, o) ; }
}
// End paths stuff.
// -------- Paths
@@ -1124,20 +1147,20 @@ Node BlankNodePropertyListPath(TripleCol
}
// ------- RDF collections
Node Collection(TripleCollector acc) :
- { Node listHead = nRDFnil ; Node lastCell = null ; int mark ; Node n ; Token t ; }
+ { Node listHead = nRDFnil ; Node lastCell = null ; Node n ; Token t ; }
{
t = <LPAREN>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
(
- { Node cell = createListNode( t.beginLine, t.beginColumn) ;
+ { Node cell = createListNode( beginLine, beginColumn) ;
if ( listHead == nRDFnil )
listHead = cell ;
if ( lastCell != null )
insert(acc, lastCell, nRDFrest, cell) ;
- mark = acc.mark() ;
}
n = GraphNode(acc)
{
- insert(acc, mark, cell, nRDFfirst, n) ;
+ insert(acc, cell, nRDFfirst, n) ;
lastCell = cell ;
}
) +
@@ -1148,20 +1171,20 @@ Node Collection(TripleCollector acc) :
return listHead ; }
}
Node CollectionPath(TripleCollector acc) :
- { Node listHead = nRDFnil ; Node lastCell = null ; int mark ; Node n ; Token t ; }
+ { Node listHead = nRDFnil ; Node lastCell = null ; Node n ; Token t ; }
{
t = <LPAREN>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
(
- { Node cell = createListNode( t.beginLine, t.beginColumn) ;
+ { Node cell = createListNode( beginLine, beginColumn) ;
if ( listHead == nRDFnil )
listHead = cell ;
if ( lastCell != null )
insert(acc, lastCell, nRDFrest, cell) ;
- mark = acc.mark() ;
}
n = GraphNodePath(acc)
{
- insert(acc, mark, cell, nRDFfirst, n) ;
+ insert(acc, cell, nRDFfirst, n) ;
lastCell = cell ;
}
) +
@@ -1343,7 +1366,7 @@ Expr BrackettedExpression() : { Expr exp
<LPAREN> expr = Expression() <RPAREN> { return expr ; }
}
Expr BuiltInCall() : { Expr expr ; Expr expr1 = null ; Expr expr2 = null ;
- Node gn ; Token t ; ExprList a ; }
+ Node gn ; ExprList a ; }
{
expr = Aggregate() { return expr ; }
|
@@ -1430,9 +1453,9 @@ Expr BuiltInCall() : { Expr expr ; Expr
{ return new E_StrDatatype(expr1, expr2) ; }
| <SAME_TERM> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_SameTerm(expr1, expr2) ; }
- | t = <IS_IRI> <LPAREN> expr = Expression() <RPAREN>
+ | <IS_IRI> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsIRI(expr) ; }
- | t = <IS_URI> <LPAREN> expr = Expression() <RPAREN>
+ | <IS_URI> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsURI(expr) ; }
| <IS_BLANK> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsBlank(expr) ; }
Modified: jena/branches/streaming-update/jena-arq/Grammar/master.jj
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-arq/Grammar/master.jj?rev=1415420&r1=1415419&r2=1415420&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-arq/Grammar/master.jj (original)
+++ jena/branches/streaming-update/jena-arq/Grammar/master.jj Thu Nov 29 22:43:42 2012
@@ -444,22 +444,38 @@ void ValuesClause() : { Token t ; }
// Update only entry point
#ifdef ARQ
-// Optional SEMICOLON
void Update() : { }
{
- Prologue()
- ( Update1() (<SEMICOLON>)* Update())?
+ // Rewrite for no recursion - grammar is not LL(1)
+ Prologue()
+ (
+ Update1()
+ (
+ // This syntactic lookahead is necessitated by the optional trailing semicolon and prologue
+ LOOKAHEAD( <SEMICOLON> Prologue() ( <LOAD> | <CLEAR> | <DROP> | <ADD> |
+ <MOVE> | <COPY> | <CREATE> | <WITH> | <DELETE> | <INSERT> |
+ <USING> | <INSERT_DATA> | <DELETE_DATA> | <DELETE_WHERE> ) )
+ <SEMICOLON>
+ Prologue()
+ Update1()
+ )*
+ (
+ <SEMICOLON>
+ Prologue()
+ )?
+ )?
}
#else
// Strict SPARQL 1.1 : mandatory separator, optional terminator.
void Update() : { }
-{
+{
+ // SPARQL - recursion - does not scale for large number of updates in a single request
Prologue()
(Update1() ( <SEMICOLON> Update() )? )?
}
#endif
-void Update1() : { Update up ; }
+void Update1() : { Update up = null ; }
{
{ startUpdateOperation() ; }
( up = Load()
@@ -469,13 +485,13 @@ void Update1() : { Update up ; }
| up = Move()
| up = Copy()
| up = Create()
- | up = InsertData()
- | up = DeleteData()
| up = DeleteWhere()
| up = Modify()
+ | InsertData()
+ | DeleteData()
)
{
- emitUpdate(up) ;
+ if (null != up) emitUpdate(up) ;
finishUpdateOperation() ;
}
}
@@ -525,41 +541,44 @@ Update Copy() : { Target src ; Target de
}
// #ifdef ARQ
-// void Meta() : { QuadDataAcc qd = new QuadDataAcc() ; }
+// void Meta() : { QuadDataAccSink qd = new QuadDataAccSink() ; }
// {
// <META>
// QuadData(qd)
// }
// #endif
-Update InsertData() : { QuadDataAcc qd = new QuadDataAcc() ; Token t ; }
+void InsertData() : { QuadDataAccSink qd = getInsertDataSink() ; Token t ; }
{
t = <INSERT_DATA>
- { startDataInsert(qd, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDataInsert(qd, beginLine, beginColumn) ; }
QuadData(qd)
{
- finishDataInsert(qd, t.beginLine, t.beginColumn) ;
- return new UpdateDataInsert(qd) ;
+ finishDataInsert(qd, beginLine, beginColumn) ;
+ qd.close() ;
}
}
-Update DeleteData() : { QuadDataAcc qd = new QuadDataAcc() ; Token t ; }
+void DeleteData() : { QuadDataAccSink qd = getDeleteDataSink() ; Token t ; }
{
t = <DELETE_DATA>
- { startDataDelete(qd, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDataDelete(qd, beginLine, beginColumn) ; }
QuadData(qd)
{
- finishDataDelete(qd, t.beginLine, t.beginColumn) ;
- return new UpdateDataDelete(qd) ;
+ finishDataDelete(qd, beginLine, beginColumn) ;
+ qd.close() ;
}
}
Update DeleteWhere() : { QuadAcc qp = new QuadAcc() ; Token t ; }
{
- t = <DELETE_WHERE>
- { startDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ t = <DELETE_WHERE>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDeleteTemplate(qp, beginLine, beginColumn) ; }
QuadPattern(qp)
- { finishDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { finishDeleteTemplate(qp, beginLine, beginColumn) ; }
{ return new UpdateDeleteWhere(qp) ; }
}
@@ -584,18 +603,20 @@ Update Modify() : { Element el ; String
void DeleteClause(UpdateModify up) : { QuadAcc qp = up.getDeleteAcc() ; Token t ;}
{
t = <DELETE>
- { startDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDeleteTemplate(qp, beginLine, beginColumn) ; }
QuadPattern(qp)
- { finishDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { finishDeleteTemplate(qp, beginLine, beginColumn) ; }
{ up.setHasDeleteClause(true) ; }
}
void InsertClause(UpdateModify up) : { QuadAcc qp = up.getInsertAcc() ; Token t ; }
{
t = <INSERT>
- { startInsertTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startInsertTemplate(qp, beginLine, beginColumn) ; }
QuadPattern(qp)
- { finishInsertTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { finishInsertTemplate(qp, beginLine, beginColumn) ; }
{ up.setHasInsertClause(true) ; }
}
@@ -642,14 +663,14 @@ void QuadPattern(QuadAcc acc) : { }
}
//Ground data : As QuadPattern but don't allow variables.
-void QuadData(QuadDataAcc acc) : { }
+void QuadData(QuadDataAccSink acc) : { }
{
<LBRACE>
Quads(acc)
<RBRACE>
}
-void Quads(QuadAcc acc) : { }
+void Quads(QuadAccSink acc) : { }
{
(TriplesTemplate(acc))?
(
@@ -659,7 +680,7 @@ void Quads(QuadAcc acc) : { }
)*
}
-void QuadsNotTriples(QuadAcc acc) : {Node gn ; Node prev = acc.getGraph() ; }
+void QuadsNotTriples(QuadAccSink acc) : {Node gn ; Node prev = acc.getGraph() ; }
{
<GRAPH> gn = VarOrIri()
{ setAccGraph(acc, gn) ; }
@@ -692,11 +713,12 @@ void TriplesTemplate(TripleCollector acc
Element GroupGraphPattern() : { Element el = null ; Token t ; }
{
t = <LBRACE>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
(
- { startSubSelect(t.beginLine, t.beginColumn) ; }
+ { startSubSelect(beginLine, beginColumn) ; }
SubSelect()
{
- Query q = endSubSelect(t.beginLine, t.beginColumn) ;
+ Query q = endSubSelect(beginLine, beginColumn) ;
el = new ElementSubQuery(q) ;
}
| el = GroupGraphPatternSub()
@@ -824,10 +846,11 @@ Element Bind() : { Var v ; Expr expr ;
Element InlineData() : { ElementData el ; Token t ; }
{
t = <VALUES>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
{ el = new ElementData() ;
- startInlineData(el.getVars(), el.getRows(), t.beginLine, t.beginColumn) ; }
+ startInlineData(el.getVars(), el.getRows(), beginLine, beginColumn) ; }
DataBlock()
- { finishInlineData(t.beginLine, t.beginColumn) ;
+ { finishInlineData(beginLine, beginColumn) ;
return el ; }
}
@@ -851,30 +874,33 @@ void InlineDataOneVar() : { Var v ; Node
t = <RBRACE>
}
-void InlineDataFull() : { Var v ; Node n ; Token t ; }
+void InlineDataFull() : { Var v ; Node n ; Token t ; int beginLine; int beginColumn; }
{
(
<NIL>
|
- t = <LPAREN>
+ <LPAREN>
(v = Var() { emitDataBlockVariable(v) ; })*
- t = <RPAREN>
+ <RPAREN>
)
- t = <LBRACE>
+ <LBRACE>
(
- t = <LPAREN>
- { startDataBlockValueRow(t.beginLine, t.beginColumn) ; }
+ t = <LPAREN>
+ { beginLine = t.beginLine; beginColumn = t.beginColumn; t = null; }
+ { startDataBlockValueRow(beginLine, beginColumn) ; }
(n = DataBlockValue()
- { emitDataBlockValue(n, t.beginLine, t.beginColumn) ; }
+ { emitDataBlockValue(n, beginLine, beginColumn) ; }
) *
- t = <RPAREN>
- { finishDataBlockValueRow(t.beginLine, t.beginColumn) ; }
+ t = <RPAREN>
+ { beginLine = t.beginLine; beginColumn = t.beginColumn; t = null; }
+ { finishDataBlockValueRow(beginLine, beginColumn) ; }
|
t = <NIL>
- { startDataBlockValueRow(t.beginLine, t.beginColumn) ; }
- { finishDataBlockValueRow(t.beginLine, t.beginColumn) ; }
+ { beginLine = t.beginLine; beginColumn = t.beginColumn; t = null; }
+ { startDataBlockValueRow(beginLine, beginColumn) ; }
+ { finishDataBlockValueRow(beginLine, beginColumn) ; }
)*
- t = <RBRACE>
+ <RBRACE>
}
Node DataBlockValue() : { Node n ; String iri ; }
@@ -992,10 +1018,11 @@ ExprList ArgList() : { Expr expr ; boole
|
<LPAREN>
(t = <DISTINCT> { distinct = true ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
{
if ( ! allowAggregatesInExpressions )
throwParseException("Aggregate expression not legal at this point",
- t.beginLine, t.beginColumn) ;
+ beginLine, beginColumn) ;
}
)?
expr = Expression() { args.add(expr) ; }
@@ -1095,9 +1122,8 @@ void ObjectList(Node s, Node p, Path pa
void Object(Node s, Node p, Path path, TripleCollector acc): { Node o ; }
{
- { int mark = acc.mark() ; }
o = GraphNode(acc)
- { insert(acc, mark, s, p, path, o) ; }
+ { insert(acc, s, p, path, o) ; }
}
// -------- BGPs with paths.
@@ -1163,9 +1189,8 @@ void ObjectListPath(Node s, Node p, Pat
void ObjectPath(Node s, Node p, Path path, TripleCollector acc): { Node o ; }
{
- { int mark = acc.mark() ; }
o = GraphNodePath(acc)
- { insert(acc, mark, s, p, path, o) ; }
+ { insert(acc, s, p, path, o) ; }
}
@@ -1376,24 +1401,21 @@ Node BlankNodePropertyListPath(TripleCol
#if 0
Node Reification(Node id, TripleCollector acc) :
- { Node s , p , o ; int mark ; Token t ; }
+ { Node s , p , o ; Token t ; }
{
// For generality, should be AndNode for s/p/o
// Insert reification triple before the resulting subtriples (if any)
- t = "<<"
+ t = "<<"
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
{ if ( id == null )
- id = createBNode(t.beginLine, t.beginColumn() ;
- mark = acc.mark() ; }
- s = GraphNode(acc)
- { insert(acc, mark, id, nRDFsubject, s) ;
- mark = acc.mark() ;
+ id = createBNode(beginLine, beginColumn() ;
}
+ s = GraphNode(acc)
+ { insert(acc, id, nRDFsubject, s) ; }
p = GraphNode(acc)
- { insert(acc, mark, id, nRDFpredicate, p) ;
- mark = acc.mark() ;
- }
+ { insert(acc, id, nRDFpredicate, p) ; }
o = GraphNode(acc)
- { insert(acc, mark, id, nRDFobject, o) ; }
+ { insert(acc, id, nRDFobject, o) ; }
">>"
{ return id ; }
}
@@ -1402,20 +1424,20 @@ Node Reification(Node id, TripleCollecto
// ------- RDF collections
Node Collection(TripleCollector acc) :
- { Node listHead = nRDFnil ; Node lastCell = null ; int mark ; Node n ; Token t ; }
+ { Node listHead = nRDFnil ; Node lastCell = null ; Node n ; Token t ; }
{
- t = <LPAREN>
+ t = <LPAREN>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
(
- { Node cell = createListNode( t.beginLine, t.beginColumn) ;
+ { Node cell = createListNode( beginLine, beginColumn) ;
if ( listHead == nRDFnil )
listHead = cell ;
if ( lastCell != null )
insert(acc, lastCell, nRDFrest, cell) ;
- mark = acc.mark() ;
}
n = GraphNode(acc)
{
- insert(acc, mark, cell, nRDFfirst, n) ;
+ insert(acc, cell, nRDFfirst, n) ;
lastCell = cell ;
}
) +
@@ -1427,20 +1449,20 @@ Node Collection(TripleCollector acc) :
}
Node CollectionPath(TripleCollector acc) :
- { Node listHead = nRDFnil ; Node lastCell = null ; int mark ; Node n ; Token t ; }
+ { Node listHead = nRDFnil ; Node lastCell = null ; Node n ; Token t ; }
{
- t = <LPAREN>
+ t = <LPAREN>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
(
- { Node cell = createListNode( t.beginLine, t.beginColumn) ;
+ { Node cell = createListNode( beginLine, beginColumn) ;
if ( listHead == nRDFnil )
listHead = cell ;
if ( lastCell != null )
insert(acc, lastCell, nRDFrest, cell) ;
- mark = acc.mark() ;
}
n = GraphNodePath(acc)
{
- insert(acc, mark, cell, nRDFfirst, n) ;
+ insert(acc, cell, nRDFfirst, n) ;
lastCell = cell ;
}
) +
@@ -1647,7 +1669,7 @@ Expr BrackettedExpression() : { Expr exp
}
Expr BuiltInCall() : { Expr expr ; Expr expr1 = null ; Expr expr2 = null ;
- Node gn ; Token t ; ExprList a ; }
+ Node gn ; ExprList a ; }
{
expr = Aggregate() { return expr ; }
|
@@ -1785,10 +1807,10 @@ Expr BuiltInCall() : { Expr expr ; Expr
| <SAME_TERM> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_SameTerm(expr1, expr2) ; }
- | t = <IS_IRI> <LPAREN> expr = Expression() <RPAREN>
+ | <IS_IRI> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsIRI(expr) ; }
- | t = <IS_URI> <LPAREN> expr = Expression() <RPAREN>
+ | <IS_URI> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsURI(expr) ; }
| <IS_BLANK> <LPAREN> expr = Expression() <RPAREN>
Modified: jena/branches/streaming-update/jena-arq/Grammar/sparql_11.jj
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-arq/Grammar/sparql_11.jj?rev=1415420&r1=1415419&r2=1415420&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-arq/Grammar/sparql_11.jj (original)
+++ jena/branches/streaming-update/jena-arq/Grammar/sparql_11.jj Thu Nov 29 22:43:42 2012
@@ -347,10 +347,11 @@ void ValuesClause() : { Token t ; }
// Strict SPARQL 1.1 : mandatory separator, optional terminator.
void Update() : { }
{
+ // SPARQL - recursion - does not scale for large number of updates in a single request
Prologue()
(Update1() ( <SEMICOLON> Update() )? )?
}
-void Update1() : { Update up ; }
+void Update1() : { Update up = null ; }
{
{ startUpdateOperation() ; }
( up = Load()
@@ -360,13 +361,13 @@ void Update1() : { Update up ; }
| up = Move()
| up = Copy()
| up = Create()
- | up = InsertData()
- | up = DeleteData()
| up = DeleteWhere()
| up = Modify()
+ | InsertData()
+ | DeleteData()
)
{
- emitUpdate(up) ;
+ if (null != up) emitUpdate(up) ;
finishUpdateOperation() ;
}
}
@@ -408,38 +409,41 @@ Update Copy() : { Target src ; Target de
{ return new UpdateCopy(src, dest, silent) ; }
}
// #ifdef ARQ
-// void Meta() : { QuadDataAcc qd = new QuadDataAcc() ; }
+// void Meta() : { QuadDataAccSink qd = new QuadDataAccSink() ; }
// {
// <META>
// QuadData(qd)
// }
// #endif
-Update InsertData() : { QuadDataAcc qd = new QuadDataAcc() ; Token t ; }
+void InsertData() : { QuadDataAccSink qd = getInsertDataSink() ; Token t ; }
{
t = <INSERT_DATA>
- { startDataInsert(qd, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDataInsert(qd, beginLine, beginColumn) ; }
QuadData(qd)
{
- finishDataInsert(qd, t.beginLine, t.beginColumn) ;
- return new UpdateDataInsert(qd) ;
+ finishDataInsert(qd, beginLine, beginColumn) ;
+ qd.close() ;
}
}
-Update DeleteData() : { QuadDataAcc qd = new QuadDataAcc() ; Token t ; }
+void DeleteData() : { QuadDataAccSink qd = getDeleteDataSink() ; Token t ; }
{
t = <DELETE_DATA>
- { startDataDelete(qd, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDataDelete(qd, beginLine, beginColumn) ; }
QuadData(qd)
{
- finishDataDelete(qd, t.beginLine, t.beginColumn) ;
- return new UpdateDataDelete(qd) ;
+ finishDataDelete(qd, beginLine, beginColumn) ;
+ qd.close() ;
}
}
Update DeleteWhere() : { QuadAcc qp = new QuadAcc() ; Token t ; }
{
t = <DELETE_WHERE>
- { startDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDeleteTemplate(qp, beginLine, beginColumn) ; }
QuadPattern(qp)
- { finishDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { finishDeleteTemplate(qp, beginLine, beginColumn) ; }
{ return new UpdateDeleteWhere(qp) ; }
}
Update Modify() : { Element el ; String iri = null ;
@@ -462,17 +466,19 @@ Update Modify() : { Element el ; String
void DeleteClause(UpdateModify up) : { QuadAcc qp = up.getDeleteAcc() ; Token t ;}
{
t = <DELETE>
- { startDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startDeleteTemplate(qp, beginLine, beginColumn) ; }
QuadPattern(qp)
- { finishDeleteTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { finishDeleteTemplate(qp, beginLine, beginColumn) ; }
{ up.setHasDeleteClause(true) ; }
}
void InsertClause(UpdateModify up) : { QuadAcc qp = up.getInsertAcc() ; Token t ; }
{
t = <INSERT>
- { startInsertTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
+ { startInsertTemplate(qp, beginLine, beginColumn) ; }
QuadPattern(qp)
- { finishInsertTemplate(qp, t.beginLine, t.beginColumn) ; }
+ { finishInsertTemplate(qp, beginLine, beginColumn) ; }
{ up.setHasInsertClause(true) ; }
}
void UsingClause(UpdateWithUsing update) : { String iri ; Node n ; }
@@ -513,13 +519,13 @@ void QuadPattern(QuadAcc acc) : { }
<RBRACE>
}
//Ground data : As QuadPattern but don't allow variables.
-void QuadData(QuadDataAcc acc) : { }
+void QuadData(QuadDataAccSink acc) : { }
{
<LBRACE>
Quads(acc)
<RBRACE>
}
-void Quads(QuadAcc acc) : { }
+void Quads(QuadAccSink acc) : { }
{
(TriplesTemplate(acc))?
(
@@ -528,7 +534,7 @@ void Quads(QuadAcc acc) : { }
(TriplesTemplate(acc))?
)*
}
-void QuadsNotTriples(QuadAcc acc) : {Node gn ; Node prev = acc.getGraph() ; }
+void QuadsNotTriples(QuadAccSink acc) : {Node gn ; Node prev = acc.getGraph() ; }
{
<GRAPH> gn = VarOrIri()
{ setAccGraph(acc, gn) ; }
@@ -547,11 +553,12 @@ void TriplesTemplate(TripleCollector acc
Element GroupGraphPattern() : { Element el = null ; Token t ; }
{
t = <LBRACE>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
(
- { startSubSelect(t.beginLine, t.beginColumn) ; }
+ { startSubSelect(beginLine, beginColumn) ; }
SubSelect()
{
- Query q = endSubSelect(t.beginLine, t.beginColumn) ;
+ Query q = endSubSelect(beginLine, beginColumn) ;
el = new ElementSubQuery(q) ;
}
| el = GroupGraphPatternSub()
@@ -654,10 +661,11 @@ Element Bind() : { Var v ; Expr expr ; }
Element InlineData() : { ElementData el ; Token t ; }
{
t = <VALUES>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
{ el = new ElementData() ;
- startInlineData(el.getVars(), el.getRows(), t.beginLine, t.beginColumn) ; }
+ startInlineData(el.getVars(), el.getRows(), beginLine, beginColumn) ; }
DataBlock()
- { finishInlineData(t.beginLine, t.beginColumn) ;
+ { finishInlineData(beginLine, beginColumn) ;
return el ; }
}
void DataBlock() : { }
@@ -678,30 +686,33 @@ void InlineDataOneVar() : { Var v ; Node
)*
t = <RBRACE>
}
-void InlineDataFull() : { Var v ; Node n ; Token t ; }
+void InlineDataFull() : { Var v ; Node n ; Token t ; int beginLine; int beginColumn; }
{
(
<NIL>
|
- t = <LPAREN>
+ <LPAREN>
(v = Var() { emitDataBlockVariable(v) ; })*
- t = <RPAREN>
+ <RPAREN>
)
- t = <LBRACE>
+ <LBRACE>
(
t = <LPAREN>
- { startDataBlockValueRow(t.beginLine, t.beginColumn) ; }
+ { beginLine = t.beginLine; beginColumn = t.beginColumn; t = null; }
+ { startDataBlockValueRow(beginLine, beginColumn) ; }
(n = DataBlockValue()
- { emitDataBlockValue(n, t.beginLine, t.beginColumn) ; }
+ { emitDataBlockValue(n, beginLine, beginColumn) ; }
) *
t = <RPAREN>
- { finishDataBlockValueRow(t.beginLine, t.beginColumn) ; }
+ { beginLine = t.beginLine; beginColumn = t.beginColumn; t = null; }
+ { finishDataBlockValueRow(beginLine, beginColumn) ; }
|
t = <NIL>
- { startDataBlockValueRow(t.beginLine, t.beginColumn) ; }
- { finishDataBlockValueRow(t.beginLine, t.beginColumn) ; }
+ { beginLine = t.beginLine; beginColumn = t.beginColumn; t = null; }
+ { startDataBlockValueRow(beginLine, beginColumn) ; }
+ { finishDataBlockValueRow(beginLine, beginColumn) ; }
)*
- t = <RBRACE>
+ <RBRACE>
}
Node DataBlockValue() : { Node n ; String iri ; }
{
@@ -770,10 +781,11 @@ ExprList ArgList() : { Expr expr ; boole
|
<LPAREN>
(t = <DISTINCT> { distinct = true ; }
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
{
if ( ! allowAggregatesInExpressions )
throwParseException("Aggregate expression not legal at this point",
- t.beginLine, t.beginColumn) ;
+ beginLine, beginColumn) ;
}
)?
expr = Expression() { args.add(expr) ; }
@@ -852,9 +864,8 @@ void ObjectList(Node s, Node p, Path pat
}
void Object(Node s, Node p, Path path, TripleCollector acc): { Node o ; }
{
- { int mark = acc.mark() ; }
o = GraphNode(acc)
- { insert(acc, mark, s, p, path, o) ; }
+ { insert(acc, s, p, path, o) ; }
}
// -------- BGPs with paths.
// -------- Entry point: TriplesSameSubjectPath
@@ -906,9 +917,8 @@ void ObjectListPath(Node s, Node p, Path
}
void ObjectPath(Node s, Node p, Path path, TripleCollector acc): { Node o ; }
{
- { int mark = acc.mark() ; }
o = GraphNodePath(acc)
- { insert(acc, mark, s, p, path, o) ; }
+ { insert(acc, s, p, path, o) ; }
}
// End paths stuff.
// -------- Paths
@@ -1032,20 +1042,20 @@ Node BlankNodePropertyListPath(TripleCol
}
// ------- RDF collections
Node Collection(TripleCollector acc) :
- { Node listHead = nRDFnil ; Node lastCell = null ; int mark ; Node n ; Token t ; }
+ { Node listHead = nRDFnil ; Node lastCell = null ; Node n ; Token t ; }
{
t = <LPAREN>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
(
- { Node cell = createListNode( t.beginLine, t.beginColumn) ;
+ { Node cell = createListNode( beginLine, beginColumn) ;
if ( listHead == nRDFnil )
listHead = cell ;
if ( lastCell != null )
insert(acc, lastCell, nRDFrest, cell) ;
- mark = acc.mark() ;
}
n = GraphNode(acc)
{
- insert(acc, mark, cell, nRDFfirst, n) ;
+ insert(acc, cell, nRDFfirst, n) ;
lastCell = cell ;
}
) +
@@ -1056,20 +1066,20 @@ Node Collection(TripleCollector acc) :
return listHead ; }
}
Node CollectionPath(TripleCollector acc) :
- { Node listHead = nRDFnil ; Node lastCell = null ; int mark ; Node n ; Token t ; }
+ { Node listHead = nRDFnil ; Node lastCell = null ; Node n ; Token t ; }
{
t = <LPAREN>
+ { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
(
- { Node cell = createListNode( t.beginLine, t.beginColumn) ;
+ { Node cell = createListNode( beginLine, beginColumn) ;
if ( listHead == nRDFnil )
listHead = cell ;
if ( lastCell != null )
insert(acc, lastCell, nRDFrest, cell) ;
- mark = acc.mark() ;
}
n = GraphNodePath(acc)
{
- insert(acc, mark, cell, nRDFfirst, n) ;
+ insert(acc, cell, nRDFfirst, n) ;
lastCell = cell ;
}
) +
@@ -1247,7 +1257,7 @@ Expr BrackettedExpression() : { Expr exp
<LPAREN> expr = Expression() <RPAREN> { return expr ; }
}
Expr BuiltInCall() : { Expr expr ; Expr expr1 = null ; Expr expr2 = null ;
- Node gn ; Token t ; ExprList a ; }
+ Node gn ; ExprList a ; }
{
expr = Aggregate() { return expr ; }
|
@@ -1322,9 +1332,9 @@ Expr BuiltInCall() : { Expr expr ; Expr
{ return new E_StrDatatype(expr1, expr2) ; }
| <SAME_TERM> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_SameTerm(expr1, expr2) ; }
- | t = <IS_IRI> <LPAREN> expr = Expression() <RPAREN>
+ | <IS_IRI> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsIRI(expr) ; }
- | t = <IS_URI> <LPAREN> expr = Expression() <RPAREN>
+ | <IS_URI> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsURI(expr) ; }
| <IS_BLANK> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsBlank(expr) ; }
Modified: jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserARQUpdate.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserARQUpdate.java?rev=1415420&r1=1415419&r2=1415420&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserARQUpdate.java (original)
+++ jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserARQUpdate.java Thu Nov 29 22:43:42 2012
@@ -23,47 +23,44 @@ import java.io.Reader ;
import java.io.StringReader ;
import org.apache.jena.atlas.io.PeekReader ;
-import org.apache.jena.atlas.logging.Log ;
import org.slf4j.LoggerFactory ;
import com.hp.hpl.jena.query.QueryException ;
import com.hp.hpl.jena.query.QueryParseException ;
import com.hp.hpl.jena.shared.JenaException ;
import com.hp.hpl.jena.sparql.lang.arq.ARQParser ;
-import com.hp.hpl.jena.update.UpdateRequest ;
+import com.hp.hpl.jena.sparql.modify.UpdateSink ;
public class ParserARQUpdate extends UpdateParser
{
@Override
- protected UpdateRequest parse$(UpdateRequest update, String queryString)
+ protected void parse$(UpdateSink sink, String queryString)
{
Reader r = new StringReader(queryString) ;
- return _parse(update, r) ;
+ _parse(sink, r) ;
}
@Override
- protected UpdateRequest parse$(UpdateRequest update, PeekReader pr)
+ protected void parse$(UpdateSink sink, PeekReader pr)
{
- return _parse(update, pr) ;
+ _parse(sink, pr) ;
}
/** Use with care - Reader must be UTF-8 */
- public UpdateRequest parse(UpdateRequest update, Reader r)
+ public void parse(UpdateSink sink, Reader r)
{
if ( r instanceof FileReader )
LoggerFactory.getLogger(this.getClass()).warn("FileReader passed to ParserSPARQLUpdate.parse - use a FileInputStream") ;
- return _parse(update, r) ;
+ _parse(sink, r) ;
}
- private UpdateRequest _parse(UpdateRequest update, Reader r)
+ private void _parse(UpdateSink sink, Reader r)
{
ARQParser parser = null ;
try {
parser = new ARQParser(r) ;
- parser.setUpdateRequest(update) ;
+ parser.setUpdateSink(sink) ;
parser.UpdateUnit() ;
- validateParsedUpdate(update) ;
- return update ;
}
catch (com.hp.hpl.jena.sparql.lang.arq.ParseException ex)
{
@@ -80,16 +77,16 @@ public class ParserARQUpdate extends Upd
catch (QueryException ex) { throw ex ; }
catch (JenaException ex) { throw new QueryException(ex.getMessage(), ex) ; }
- catch (Error err)
- {
- // The token stream can throw errors.
- throw new QueryParseException(err.getMessage(), err, -1, -1) ;
- }
- catch (Throwable th)
- {
- Log.fatal(this, "Unexpected throwable: ",th) ;
- throw new QueryException(th.getMessage(), th) ;
- }
+// catch (Error err)
+// {
+// // The token stream can throw errors.
+// throw new QueryParseException(err.getMessage(), err, -1, -1) ;
+// }
+// catch (Throwable th)
+// {
+// Log.fatal(this, "Unexpected throwable: ",th) ;
+// throw new QueryException(th.getMessage(), th) ;
+// }
}
Modified: jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserBase.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserBase.java?rev=1415420&r1=1415419&r2=1415420&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserBase.java (original)
+++ jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserBase.java Thu Nov 29 22:43:42 2012
@@ -41,7 +41,7 @@ import com.hp.hpl.jena.sparql.expr.E_Exi
import com.hp.hpl.jena.sparql.expr.E_NotExists ;
import com.hp.hpl.jena.sparql.expr.Expr ;
import com.hp.hpl.jena.sparql.graph.NodeConst ;
-import com.hp.hpl.jena.sparql.modify.request.QuadAcc ;
+import com.hp.hpl.jena.sparql.modify.request.QuadAccSink ;
import com.hp.hpl.jena.sparql.path.Path ;
import com.hp.hpl.jena.sparql.syntax.Element ;
import com.hp.hpl.jena.sparql.syntax.ElementGroup ;
@@ -373,7 +373,7 @@ public class ParserBase
return prefix ;
}
- protected void setAccGraph(QuadAcc acc, Node gn)
+ protected void setAccGraph(QuadAccSink acc, Node gn)
{
acc.setGraph(gn) ;
}
@@ -383,11 +383,6 @@ public class ParserBase
acc.addTriple(new Triple(s, p, o)) ;
}
- protected void insert(TripleCollector acc, int index, Node s, Node p, Node o)
- {
- acc.addTriple(index, new Triple(s, p, o)) ;
- }
-
protected void insert(TripleCollector acc, Node s, Node p, Path path, Node o)
{
if ( p == null )
@@ -395,14 +390,6 @@ public class ParserBase
else
acc.addTriple(new Triple(s, p, o)) ;
}
-
- protected void insert(TripleCollector acc, int index, Node s, Node p, Path path, Node o)
- {
- if ( p == null )
- acc.addTriplePath(index, new TriplePath(s, path, o)) ;
- else
- acc.addTriple(index, new Triple(s, p, o)) ;
- }
protected Expr asExpr(Node n)
{
Modified: jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserSPARQL11Update.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserSPARQL11Update.java?rev=1415420&r1=1415419&r2=1415420&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserSPARQL11Update.java (original)
+++ jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/ParserSPARQL11Update.java Thu Nov 29 22:43:42 2012
@@ -31,49 +31,47 @@ import com.hp.hpl.jena.query.QueryExcept
import com.hp.hpl.jena.query.QueryParseException ;
import com.hp.hpl.jena.shared.JenaException ;
import com.hp.hpl.jena.sparql.lang.sparql_11.SPARQLParser11 ;
+import com.hp.hpl.jena.sparql.modify.UpdateSink ;
import com.hp.hpl.jena.update.UpdateException ;
-import com.hp.hpl.jena.update.UpdateRequest ;
import com.hp.hpl.jena.util.FileUtils ;
public class ParserSPARQL11Update extends UpdateParser
{
@Override
- protected UpdateRequest parse$(UpdateRequest update, String updateString)
+ protected void parse$(UpdateSink sink, String updateString)
{
Reader r = new StringReader(updateString) ;
- return _parse(update, r) ;
+ _parse(sink, r) ;
}
@Override
- protected UpdateRequest parse$(UpdateRequest update, PeekReader pr)
+ protected void parse$(UpdateSink sink, PeekReader pr)
{
- return _parse(update, pr) ;
+ _parse(sink, pr) ;
}
@Override
- public UpdateRequest parse(UpdateRequest update, InputStream in)
+ public void parse(UpdateSink sink, InputStream in)
{
Reader r = FileUtils.asBufferedUTF8(in) ;
- return _parse(update, r) ;
+ _parse(sink, r) ;
}
- public UpdateRequest parse(UpdateRequest update, Reader r)
+ public void parse(UpdateSink sink, Reader r)
{
if ( r instanceof FileReader )
LoggerFactory.getLogger(this.getClass()).warn("FileReader passed to ParserSPARQL11Update.parse - use a FileInputStream") ;
- return _parse(update, r) ;
+ _parse(sink, r) ;
}
- private UpdateRequest _parse(UpdateRequest update, Reader r)
+ private void _parse(UpdateSink sink, Reader r)
{
SPARQLParser11 parser = null ;
try {
parser = new SPARQLParser11(r) ;
- parser.setUpdateRequest(update) ;
+ parser.setUpdateSink(sink) ;
parser.UpdateUnit() ;
- validateParsedUpdate(update) ;
- return update ;
}
catch (com.hp.hpl.jena.sparql.lang.sparql_11.ParseException ex)
{
Modified: jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/SPARQLParserBase.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/SPARQLParserBase.java?rev=1415420&r1=1415419&r2=1415420&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/SPARQLParserBase.java (original)
+++ jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/SPARQLParserBase.java Thu Nov 29 22:43:42 2012
@@ -18,7 +18,12 @@
package com.hp.hpl.jena.sparql.lang;
-import java.util.* ;
+import java.util.ArrayDeque ;
+import java.util.ArrayList ;
+import java.util.Deque ;
+import java.util.HashSet ;
+import java.util.List ;
+import java.util.Set ;
import com.hp.hpl.jena.graph.Node ;
import com.hp.hpl.jena.query.Query ;
@@ -28,11 +33,11 @@ import com.hp.hpl.jena.sparql.core.Var ;
import com.hp.hpl.jena.sparql.engine.binding.Binding ;
import com.hp.hpl.jena.sparql.engine.binding.BindingFactory ;
import com.hp.hpl.jena.sparql.engine.binding.BindingMap ;
+import com.hp.hpl.jena.sparql.modify.UpdateSink ;
import com.hp.hpl.jena.sparql.modify.request.QuadAcc ;
-import com.hp.hpl.jena.sparql.modify.request.QuadDataAcc ;
+import com.hp.hpl.jena.sparql.modify.request.QuadDataAccSink ;
import com.hp.hpl.jena.sparql.util.LabelToNodeMap ;
import com.hp.hpl.jena.update.Update ;
-import com.hp.hpl.jena.update.UpdateRequest ;
/** Class that has all the parse event operations and other query/update specific things */
public class SPARQLParserBase extends ParserBase
@@ -65,7 +70,7 @@ public class SPARQLParserBase extends Pa
// }
// SPARQL Update (W3C RECommendation)
- private UpdateRequest request = null ;
+ private UpdateSink sink = null ;
// Places to push settings across points where we reset.
private boolean oldBNodesAreVariables ;
@@ -78,12 +83,12 @@ public class SPARQLParserBase extends Pa
private Deque<Set<String>> stackPreviousLabels = new ArrayDeque<Set<String>>() ;
private Deque<LabelToNodeMap> stackCurrentLabels = new ArrayDeque<LabelToNodeMap>() ;
- protected UpdateRequest getUpdateRequest() { return request ; }
- public void setUpdateRequest(UpdateRequest request)
+// protected UpdateSink getUpdateSink() { return sink ; }
+ public void setUpdateSink(UpdateSink sink)
{
- this.request = request ;
+ this.sink = sink ;
this.query = new Query() ;
- setPrologue(request) ;
+ setPrologue(sink.getPrologue()) ;
}
// Signal start/finish of units
@@ -106,27 +111,27 @@ public class SPARQLParserBase extends Pa
protected void startModifyUpdate() { }
protected void finishModifyUpdate() { }
- protected void startDataInsert(QuadDataAcc qd, int line, int col)
+ protected void startDataInsert(QuadDataAccSink qd, int line, int col)
{
oldBNodesAreVariables = getBNodesAreVariables() ;
setBNodesAreVariables(false) ;
activeLabelMap.clear() ;
}
- protected void finishDataInsert(QuadDataAcc qd, int line, int col)
+ protected void finishDataInsert(QuadDataAccSink qd, int line, int col)
{
previousLabels.addAll(activeLabelMap.getLabels()) ;
activeLabelMap.clear() ;
setBNodesAreVariables(oldBNodesAreVariables) ;
}
- protected void startDataDelete(QuadDataAcc qd,int line, int col)
+ protected void startDataDelete(QuadDataAccSink qd,int line, int col)
{
oldBNodesAreAllowed = getBNodesAreAllowed() ;
setBNodesAreAllowed(false) ;
}
- protected void finishDataDelete(QuadDataAcc qd, int line, int col)
+ protected void finishDataDelete(QuadDataAccSink qd, int line, int col)
{
setBNodesAreAllowed(oldBNodesAreAllowed) ;
}
@@ -182,7 +187,21 @@ public class SPARQLParserBase extends Pa
protected void emitUpdate(Update update)
{
- request.add(update) ;
+ // The parser can send null if it already performed an INSERT_DATA or DELETE_DATA
+ if (null != update)
+ {
+ sink.send(update);
+ }
+ }
+
+ protected QuadDataAccSink getInsertDataSink()
+ {
+ return sink.getInsertDataSink();
+ }
+
+ protected QuadDataAccSink getDeleteDataSink()
+ {
+ return sink.getDeleteDataSink();
}
protected void startSubSelect(int line, int col)
Modified: jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/UpdateParser.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/UpdateParser.java?rev=1415420&r1=1415419&r2=1415420&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/UpdateParser.java (original)
+++ jena/branches/streaming-update/jena-arq/src/main/java/com/hp/hpl/jena/sparql/lang/UpdateParser.java Thu Nov 29 22:43:42 2012
@@ -24,7 +24,7 @@ import org.apache.jena.atlas.io.PeekRead
import com.hp.hpl.jena.query.QueryParseException ;
import com.hp.hpl.jena.query.Syntax ;
-import com.hp.hpl.jena.update.UpdateRequest ;
+import com.hp.hpl.jena.sparql.modify.UpdateSink ;
/** This class provides the root of lower level access to all the parsers.
* Each subclass hides the details of the per-language exception handlers and other
@@ -34,25 +34,25 @@ import com.hp.hpl.jena.update.UpdateRequ
public abstract class UpdateParser
{
- public final UpdateRequest parse(UpdateRequest request, String updateString) throws QueryParseException
+ public final void parse(UpdateSink sink, String updateString) throws QueryParseException
{
// Sort out BOM
if ( updateString.startsWith("\uFEFF") )
updateString = updateString.substring(1) ;
- return parse$(request, updateString) ;
+ parse$(sink, updateString) ;
}
- protected abstract UpdateRequest parse$(UpdateRequest request, String updateString) throws QueryParseException ;
+ protected abstract void parse$(UpdateSink sink, String updateString) throws QueryParseException ;
- public UpdateRequest parse(UpdateRequest request, InputStream input) throws QueryParseException
+ public void parse(UpdateSink sink, InputStream input) throws QueryParseException
{
// :-( Wrap in something that we can use to look for a BOM.
// TODO Move POM processing to grammar and reverse this.
PeekReader pr = PeekReader.makeUTF8(input) ;
- return parse$(request, pr) ;
+ parse$(sink, pr) ;
}
- protected abstract UpdateRequest parse$(UpdateRequest request, PeekReader pr) throws QueryParseException ;
+ protected abstract void parse$(UpdateSink sink, PeekReader pr) throws QueryParseException ;
public static boolean canParse(Syntax syntaxURI)
{
@@ -63,9 +63,4 @@ public abstract class UpdateParser
{
return UpdateParserRegistry.get().createParser(syntaxURI) ;
}
-
- // Do any testing of updates after the construction of the parse tree.
- protected void validateParsedUpdate(UpdateRequest request)
- {
- }
}