From: <jer...@us...> - 2014-01-24 23:39:46
|
Revision: 7828 http://bigdata.svn.sourceforge.net/bigdata/?rev=7828&view=rev Author: jeremy_carroll Date: 2014-01-24 23:39:36 +0000 (Fri, 24 Jan 2014) Log Message: ----------- Tests and preparation for fixing of trac 807 concerning native distinct filter of insert/delete quads Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryBase.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdate.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTConstructIterator.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTConstructOptimizer.java branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlServerWithProxyIndexManager.java Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractNamedGraphUpdateTest.java branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/HashDistinctNamedGraphUpdateTest.java branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/NativeDistinctNamedGraphUpdateTest.java Removed Paths: ------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/NamedGraphUpdateTest.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryBase.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryBase.java 2014-01-24 18:42:02 UTC (rev 7827) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryBase.java 2014-01-24 23:39:36 UTC (rev 7828) @@ -178,6 +178,7 @@ public void setConstruct(final ConstructNode construct) { setProperty(Annotations.CONSTRUCT, construct); + setQueryType(QueryType.CONSTRUCT); } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdate.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdate.java 2014-01-24 18:42:02 UTC (rev 7827) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdate.java 2014-01-24 23:39:36 UTC (rev 7828) @@ -595,10 +595,18 @@ * associated with the SailConnection in case the view is * isolated by a transaction. */ + + // If the query contains a nativeDistinctSPO query hint then + // the line below unfortunately isolates the query so that the hint does + // not impact any other execution, this is hacked by putting a property on the query root. + final MutableTupleQueryResult result = new MutableTupleQueryResult( ASTEvalHelper.evaluateTupleQuery( context.conn.getTripleStore(), astContainer, null/* bindingSets */)); + + boolean nativeDistinct = astContainer.getOptimizedAST().getProperty(ConstructNode.Annotations.NATIVE_DISTINCT, + ConstructNode.Annotations.DEFAULT_NATIVE_DISTINCT); try { @@ -745,6 +753,10 @@ .getQuadData().flatten(new ConstructNode(context)); template.setDistinctQuads(true); + + if (nativeDistinct) { + template.setNativeDistinct(true); + } final ASTConstructIterator itr = new ASTConstructIterator( context.conn.getTripleStore(), template, @@ -816,6 +828,10 @@ .getQuadData().flatten(new ConstructNode(context)); template.setDistinctQuads(true); + + if (nativeDistinct) { + template.setNativeDistinct(true); + } final ASTConstructIterator itr = new ASTConstructIterator( context.conn.getTripleStore(), template, Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTConstructIterator.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTConstructIterator.java 2014-01-24 18:42:02 UTC (rev 7827) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTConstructIterator.java 2014-01-24 23:39:36 UTC (rev 7828) @@ -188,13 +188,15 @@ private boolean open = true; /** - * <code>true</code> until we get the first solution for the WHERE clause. + * <code>false</code> until we get the first solution for the WHERE clause. * We do not output ground triples in the template until we see that first * solution. It is Ok if it is empty, but we need to know that the WHERE * clause succeeded before we can output the ground triples. */ - private boolean haveFirstSolution = false; + private boolean haveFirstSolution = false; + public static boolean flagToCheckNativeDistinctQuadsInvocationForJUnitTesting = false; + /** * * @param tripleStore @@ -283,7 +285,7 @@ } - IFilterTest createDistinctFilter(final AbstractTripleStore tripleStore, final ConstructNode construct, + private IFilterTest createDistinctFilter(final AbstractTripleStore tripleStore, final ConstructNode construct, final GraphPatternGroup<?> whereClause) { /* * Setup the DISTINCT SPO filter. @@ -296,6 +298,13 @@ * graph is large. */ + final boolean distinctQuads = construct.isDistinctQuads() && tripleStore.isQuads() && hasMixedQuadData(templates); + final boolean nativeDistinct = construct.isNativeDistinct(); + + if (nativeDistinct && construct.isDistinctQuads()) { + flagToCheckNativeDistinctQuadsInvocationForJUnitTesting = true; + } + final boolean isObviouslyDistinct = isObviouslyDistinct(tripleStore.isQuads(), templates, whereClause); if (isObviouslyDistinct) { @@ -307,20 +316,33 @@ } - - final boolean distinctQuads = construct.isDistinctQuads() && tripleStore.isQuads() && hasMixedQuadData(templates); - if (distinctQuads) { - return createDistinctQuadsFilter(construct); + if (nativeDistinct) { + return createNativeDistinctQuadsFilter(construct); + } else { + return createHashDistinctQuadsFilter(construct); + } + + } else { + + if (nativeDistinct) { + return createNativeDistinctTripleFilter(construct); + } else { + // JVM Based DISTINCT filter. + return new DistinctFilter.DistinctFilterImpl(construct); + } } - - return createDistinctTriplesFilter(construct); } + private IFilterTest createNativeDistinctQuadsFilter(ConstructNode construct) { + // TODO This method needs to be written. It should scale, whereas the current implementation does not. + return createHashDistinctQuadsFilter(construct); + } + @SuppressWarnings("serial") - private IFilterTest createDistinctQuadsFilter(final ConstructNode construct) { + private IFilterTest createHashDistinctQuadsFilter(final ConstructNode construct) { return new DistinctFilter.DistinctFilterImpl(construct){ @Override public boolean isValid(Object o){ @@ -352,67 +374,55 @@ return a == b || ( a != null && a.equals(b)); } - IFilterTest createDistinctTriplesFilter(final ConstructNode construct) { - - final boolean nativeDistinct = construct.isNativeDistinct(); + private IFilterTest createNativeDistinctTripleFilter(final ConstructNode construct) { + /* + * Construct a predicate for the first triple template. We will + * use that as the bias for the scalable DISTINCT SPO filter. + */ + @SuppressWarnings("rawtypes") + final IPredicate pred; + { - if (nativeDistinct) { + final StatementPatternNode sp = templates.get(0/* index */); - /* - * Construct a predicate for the first triple template. We will - * use that as the bias for the scalable DISTINCT SPO filter. - */ - @SuppressWarnings("rawtypes") - final IPredicate pred; - { + @SuppressWarnings("rawtypes") + final IVariableOrConstant<IV> s = sp.s() + .getValueExpression(); - final StatementPatternNode sp = templates.get(0/* index */); + @SuppressWarnings("rawtypes") + final IVariableOrConstant<IV> p = sp.p() + .getValueExpression(); + + @SuppressWarnings("rawtypes") + final IVariableOrConstant<IV> o = sp.o() + .getValueExpression(); - @SuppressWarnings("rawtypes") - final IVariableOrConstant<IV> s = sp.s() - .getValueExpression(); + // // The graph term/variable iff specified by the query. + // final TermNode cvar = sp.c(); + // final IVariableOrConstant<IV> c = cvar == null ? null : + // cvar + // .getValueExpression(); - @SuppressWarnings("rawtypes") - final IVariableOrConstant<IV> p = sp.p() - .getValueExpression(); - - @SuppressWarnings("rawtypes") - final IVariableOrConstant<IV> o = sp.o() - .getValueExpression(); + final BOp[] vars = new BOp[] { s, p, o /* , c */}; - // // The graph term/variable iff specified by the query. - // final TermNode cvar = sp.c(); - // final IVariableOrConstant<IV> c = cvar == null ? null : - // cvar - // .getValueExpression(); + pred = new SPOPredicate(vars, BOp.NOANNS); - final BOp[] vars = new BOp[] { s, p, o /* , c */}; + } - pred = new SPOPredicate(vars, BOp.NOANNS); + /* + * The index that will be used to read on the B+Tree access + * path. + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + final SPOKeyOrder indexKeyOrder = SPOKeyOrder.getKeyOrder( + (IPredicate) pred, 3/* keyArity */); - } + construct.setProperty( + NativeDistinctFilter.Annotations.KEY_ORDER, + indexKeyOrder); - /* - * The index that will be used to read on the B+Tree access - * path. - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - final SPOKeyOrder indexKeyOrder = SPOKeyOrder.getKeyOrder( - (IPredicate) pred, 3/* keyArity */); - - construct.setProperty( - NativeDistinctFilter.Annotations.KEY_ORDER, - indexKeyOrder); - - // Native memory based DISTINCT filter. - return new NativeDistinctFilter.DistinctFilterImpl(construct); - - } else { - - // JVM Based DISTINCT filter. - return new DistinctFilter.DistinctFilterImpl(construct); - - } + // Native memory based DISTINCT filter. + return new NativeDistinctFilter.DistinctFilterImpl(construct); } /** Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTConstructOptimizer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTConstructOptimizer.java 2014-01-24 18:42:02 UTC (rev 7827) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTConstructOptimizer.java 2014-01-24 23:39:36 UTC (rev 7828) @@ -42,6 +42,7 @@ import com.bigdata.rdf.sparql.ast.SliceNode; import com.bigdata.rdf.sparql.ast.SubqueryRoot; import com.bigdata.rdf.sparql.ast.VarNode; +import com.bigdata.rdf.sparql.ast.ConstructNode.Annotations; import com.bigdata.rdf.sparql.ast.eval.AST2BOpContext; /** @@ -73,6 +74,9 @@ case CONSTRUCT: break; default: + if (context.nativeDistinctSPO) { + queryRoot.setProperty(Annotations.NATIVE_DISTINCT, true); + } return queryRoot; } Copied: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractNamedGraphUpdateTest.java (from rev 7827, branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/NamedGraphUpdateTest.java) =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractNamedGraphUpdateTest.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractNamedGraphUpdateTest.java 2014-01-24 23:39:36 UTC (rev 7828) @@ -0,0 +1,296 @@ +/** +Copyright (C) SYSTAP, LLC 2014. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package com.bigdata.rdf.sail.webapp; + +import java.io.IOException; + +import com.bigdata.rdf.sparql.ast.eval.ASTConstructIterator; + + + +/** + * This class is concernign the issues raised in trac 804 + * https://sourceforge.net/apps/trac/bigdata/ticket/804 + * @author jeremycarroll + * + */ +public class AbstractNamedGraphUpdateTest extends AbstractProtocolTest { + + private static String distinctHintFalse = " hint:Query hint:nativeDistinctSPO false . \n"; + private static String distinctHintTrue = " hint:Query hint:nativeDistinctSPO true . \n"; + private final boolean nativeDistinct; + + + + public AbstractNamedGraphUpdateTest(boolean nativeDistinct, String name) { + super(name); + this.nativeDistinct = nativeDistinct; + } + + + private String atomicMoveNamedGraph() { + // Atomic update of uploaded graph - moving eg:tmp to eg:a (deleting old contents of eg:a) + return + "DELETE {\n" + + " GRAPH <eg:a> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + " GRAPH <eg:tmp> {\n" + + " ?news ?newp ?newo\n" + + " }\n" + + "}\n" + + "INSERT {\n" + + " GRAPH <eg:a> {\n" + + " ?news ?newp ?newo\n" + + " }\n" + + "}\n" + + "WHERE {\n" + + distinctHintFalse + + " {\n" + + " GRAPH <eg:a> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + " } UNION {\n" + + " GRAPH <eg:tmp> {\n" + + " ?news ?newp ?newo\n" + + " }\n" + + " }\n" + + "}"; + } + + private String insertData = + "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + + "INSERT DATA\n" + + "{ \n" + + " GRAPH <eg:a> {\n" + + " [ a \"Blank\" ] .\n" + + " <eg:b> rdf:type <eg:c> ; rdf:value [] .\n" + + " [ rdf:value [] ]\n" + + " }\n" + + " GRAPH <eg:tmp> {\n" + + " [ a \"Blankx\" ] .\n" + + " <eg:B> rdf:type <eg:C> ; rdf:value [] .\n" + + " [ rdf:value [] ]\n" + + " }\n" + + "}\n"; + + + private void makeUpdate(String update) throws IOException { + boolean hasHint = update.contains(distinctHintFalse); + if (hasHint) { + ASTConstructIterator.flagToCheckNativeDistinctQuadsInvocationForJUnitTesting = false; + if (nativeDistinct) { + update = update.replace(distinctHintFalse, distinctHintTrue); + } + } + setMethodisPostUrlEncodedData(); + serviceRequest("update", update); + if (hasHint) { + assertEquals(nativeDistinct, ASTConstructIterator.flagToCheckNativeDistinctQuadsInvocationForJUnitTesting ); + } + } + + private void assertQuad(String graph, String triple) throws IOException { + assertQuad("true", graph, triple); + } + + private void assertNotQuad(String graph, String triple) throws IOException { + assertQuad("false", graph, triple); + } + + void assertQuad(String expected, String graph, String triple) throws IOException { + String result = serviceRequest("query", "ASK { GRAPH " + graph + " { " + triple + "} }" ); + assertTrue(result.contains(expected)); + } + + private void updateAFewTimes(int numberOfUpdatesPerTime) throws IOException { + final int numberOfTimes = 5; + for (int i=0; i<numberOfTimes; i++) { + for (int j=0; j<numberOfUpdatesPerTime;j++) { + makeUpdate(insertData); + } + makeUpdate( atomicMoveNamedGraph() ); + assertNotQuad("<eg:tmp>", " ?s ?p ?o "); + } + } + + public void test_t_1() throws IOException { + updateAFewTimes(1); + } + public void test_t_2() throws IOException { + updateAFewTimes(2); + } + public void test_t_3() throws IOException { + updateAFewTimes(3); + } + public void test_t_5() throws IOException { + updateAFewTimes(5); + } + public void test_double_triple_delete() throws IOException { + setMethodisPostUrlEncodedData(); + makeUpdate("prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + + "INSERT DATA\n" + + "{ \n" + + " GRAPH <eg:a> {\n" + + " <eg:b> rdf:type <eg:c> \n" + + " }\n" + + " GRAPH <eg:tmp> {\n" + + " <eg:b> rdf:type <eg:c> \n" + + " }\n" + + "}\n"); + makeUpdate( "DELETE {\n" + + " GRAPH <eg:a> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + " GRAPH <eg:tmp> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}\n" + + "WHERE {\n" + + distinctHintFalse + + " GRAPH <eg:a> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}"); + assertNotQuad("?g","?s ?p ?o"); + + } + + public void test_double_triple_insert() throws IOException { + makeUpdate( "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + + "INSERT DATA\n" + + "{ \n" + + " GRAPH <eg:tmp> {\n" + + " <eg:b> rdf:type <eg:c> .\n" + + " <eg:x> rdf:type _:foo \n" + + " }\n" + + "}\n"); + makeUpdate( "INSERT {\n" + + " GRAPH <eg:A> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + " GRAPH <eg:B> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}\n" + + "WHERE {\n" + + distinctHintFalse + + " GRAPH <eg:tmp> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}"); + assertQuad("<eg:A>","<eg:b> rdf:type <eg:c> "); + assertQuad("<eg:B>","<eg:b> rdf:type <eg:c> "); + assertQuad("<eg:A>","<eg:x> rdf:type ?x"); + assertQuad("<eg:B>","<eg:x> rdf:type ?x "); + } + public void test_double_triple_delete_insert() throws IOException { + makeUpdate( "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + + "INSERT DATA\n" + + "{ \n" + + " GRAPH <eg:tmp> {\n" + + " <eg:A> <eg:moveTo> <eg:AA> .\n" + + " <eg:B> <eg:moveTo> <eg:BB> \n" + + " }\n" + + "}\n"); + makeUpdate( "INSERT {\n" + + " GRAPH <eg:A> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}\n" + + "WHERE {\n" + + " GRAPH <eg:tmp> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}"); + makeUpdate( "INSERT {\n" + + " GRAPH <eg:B> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}\n" + + "WHERE {\n" + + " GRAPH <eg:tmp> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}"); + assertQuad("<eg:A>","<eg:A> <eg:moveTo> <eg:AA> "); + assertQuad("<eg:B>","<eg:A> <eg:moveTo> <eg:AA> "); + assertQuad("<eg:A>","<eg:B> <eg:moveTo> <eg:BB>"); + assertQuad("<eg:B>","<eg:B> <eg:moveTo> <eg:BB> "); + makeUpdate( + "DELETE {\n" + + " GRAPH ?oldg {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}\n" + + "INSERT {\n" + + " GRAPH ?newg {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}\n" + + "WHERE {\n" + + distinctHintFalse + + " GRAPH <eg:tmp> {\n" + + " ?oldg <eg:moveTo> ?newg\n" + + " }\n" + + " GRAPH ?oldg {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}"); + assertNotQuad("<eg:A>","<eg:A> <eg:moveTo> <eg:AA> "); + assertNotQuad("<eg:B>","<eg:A> <eg:moveTo> <eg:AA> "); + assertNotQuad("<eg:A>","<eg:B> <eg:moveTo> <eg:BB>"); + assertNotQuad("<eg:B>","<eg:B> <eg:moveTo> <eg:BB> "); + assertQuad("<eg:AA>","<eg:A> <eg:moveTo> <eg:AA> "); + assertQuad("<eg:BB>","<eg:A> <eg:moveTo> <eg:AA> "); + assertQuad("<eg:AA>","<eg:B> <eg:moveTo> <eg:BB>"); + assertQuad("<eg:BB>","<eg:B> <eg:moveTo> <eg:BB> "); + } + public void test_triple_template_and_fixed_insert() throws IOException { + makeUpdate( "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + + "INSERT DATA\n" + + "{ \n" + + " GRAPH <eg:tmp> {\n" + + " <eg:b> rdf:type <eg:c> .\n" + + " }\n" + + "}\n"); + makeUpdate( "INSERT {\n" + + " GRAPH <eg:A> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + " GRAPH <eg:B> {\n" + + " <eg:b> rdf:type <eg:c> .\n" + + " }\n" + + "}\n" + + "WHERE {\n" + + distinctHintFalse + + " GRAPH <eg:tmp> {\n" + + " ?olds ?oldp ?oldo\n" + + " }\n" + + "}"); + assertQuad("<eg:A>","<eg:b> rdf:type <eg:c> "); + assertQuad("<eg:B>","<eg:b> rdf:type <eg:c> "); + } + +} Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/HashDistinctNamedGraphUpdateTest.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/HashDistinctNamedGraphUpdateTest.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/HashDistinctNamedGraphUpdateTest.java 2014-01-24 23:39:36 UTC (rev 7828) @@ -0,0 +1,36 @@ +/** +Copyright (C) SYSTAP, LLC 2014. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.rdf.sail.webapp; + +import junit.framework.Test; + +public class HashDistinctNamedGraphUpdateTest extends AbstractNamedGraphUpdateTest { + + static public Test suite() { + return ProxySuiteHelper.suiteWhenStandalone(HashDistinctNamedGraphUpdateTest.class,"test.*", TestMode.quads); + } + public HashDistinctNamedGraphUpdateTest(String name) { + super(false, name); + } + +} Deleted: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/NamedGraphUpdateTest.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/NamedGraphUpdateTest.java 2014-01-24 18:42:02 UTC (rev 7827) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/NamedGraphUpdateTest.java 2014-01-24 23:39:36 UTC (rev 7828) @@ -1,289 +0,0 @@ -/** -Copyright (C) SYSTAP, LLC 2014. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package com.bigdata.rdf.sail.webapp; - -import java.io.IOException; - -import junit.framework.Test; - - -/** - * This class is concernign the issues raised in trac 804 - * https://sourceforge.net/apps/trac/bigdata/ticket/804 - * @author jeremycarroll - * - */ -public class NamedGraphUpdateTest extends AbstractProtocolTest { - - - public NamedGraphUpdateTest(String name) { - super(name); - } - - - private String atomicMoveNamedGraph(boolean useHint) { - // Atomic update of uploaded graph - moving eg:tmp to eg:a (deleting old contents of eg:a) - return - "DELETE {\n" + - " GRAPH <eg:a> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - " GRAPH <eg:tmp> {\n" + - " ?news ?newp ?newo\n" + - " }\n" + - "}\n" + - "INSERT {\n" + - " GRAPH <eg:a> {\n" + - " ?news ?newp ?newo\n" + - " }\n" + - "}\n" + - "WHERE {\n" + - (useHint?" hint:Query hint:chunkSize 2 .\n":"") + - " {\n" + - " GRAPH <eg:a> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - " } UNION {\n" + - " GRAPH <eg:tmp> {\n" + - " ?news ?newp ?newo\n" + - " }\n" + - " }\n" + - "}"; - } - - private String insertData = - "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + - "INSERT DATA\n" + - "{ \n" + - " GRAPH <eg:a> {\n" + - " [ a \"Blank\" ] .\n" + - " <eg:b> rdf:type <eg:c> ; rdf:value [] .\n" + - " [ rdf:value [] ]\n" + - " }\n" + - " GRAPH <eg:tmp> {\n" + - " [ a \"Blankx\" ] .\n" + - " <eg:B> rdf:type <eg:C> ; rdf:value [] .\n" + - " [ rdf:value [] ]\n" + - " }\n" + - "}\n"; - - - private void makeUpdate(String update) throws IOException { - setMethodisPostUrlEncodedData(); - serviceRequest("update", update); - } - - private void assertQuad(String graph, String triple) throws IOException { - assertQuad("true", graph, triple); - } - - private void assertNotQuad(String graph, String triple) throws IOException { - assertQuad("false", graph, triple); - } - - void assertQuad(String expected, String graph, String triple) throws IOException { - String result = serviceRequest("query", "ASK { GRAPH " + graph + " { " + triple + "} }" ); - assertTrue(result.contains(expected)); - } - - private void updateAFewTimes(boolean useHint, int numberOfUpdatesPerTime) throws IOException { - final int numberOfTimes = 5; - for (int i=0; i<numberOfTimes; i++) { - for (int j=0; j<numberOfUpdatesPerTime;j++) { - makeUpdate(insertData); - } - makeUpdate( atomicMoveNamedGraph(useHint) ); - assertNotQuad("<eg:tmp>", " ?s ?p ?o "); - } - } - - public void test_t_1() throws IOException { - updateAFewTimes(true, 1); - } - public void test_t_2() throws IOException { - updateAFewTimes(true, 2); - } - public void test_t_3() throws IOException { - updateAFewTimes(true, 3); - } - public void test_t_5() throws IOException { - updateAFewTimes(true, 5); - } - public void test_f_1() throws IOException { - updateAFewTimes(false, 1); - } - public void test_f_2() throws IOException { - updateAFewTimes(false, 2); - } - public void test_f_3() throws IOException { - updateAFewTimes(false, 3); - } - public void test_f_5() throws IOException { - updateAFewTimes(false, 5); - } - public void test_double_triple_delete() throws IOException { - setMethodisPostUrlEncodedData(); - makeUpdate("prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + - "INSERT DATA\n" + - "{ \n" + - " GRAPH <eg:a> {\n" + - " <eg:b> rdf:type <eg:c> \n" + - " }\n" + - " GRAPH <eg:tmp> {\n" + - " <eg:b> rdf:type <eg:c> \n" + - " }\n" + - "}\n"); - makeUpdate( "DELETE {\n" + - " GRAPH <eg:a> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - " GRAPH <eg:tmp> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}\n" + - "WHERE {\n" + - " GRAPH <eg:a> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}"); - assertNotQuad("?g","?s ?p ?o"); - - } - - public void test_double_triple_insert() throws IOException { - makeUpdate( "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + - "INSERT DATA\n" + - "{ \n" + - " GRAPH <eg:tmp> {\n" + - " <eg:b> rdf:type <eg:c> .\n" + - " <eg:x> rdf:type _:foo \n" + - " }\n" + - "}\n"); - makeUpdate( "INSERT {\n" + - " GRAPH <eg:A> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - " GRAPH <eg:B> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}\n" + - "WHERE {\n" + - " GRAPH <eg:tmp> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}"); - assertQuad("<eg:A>","<eg:b> rdf:type <eg:c> "); - assertQuad("<eg:B>","<eg:b> rdf:type <eg:c> "); - assertQuad("<eg:A>","<eg:x> rdf:type ?x"); - assertQuad("<eg:B>","<eg:x> rdf:type ?x "); - } - public void test_double_triple_delete_insert() throws IOException { - makeUpdate( "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + - "INSERT DATA\n" + - "{ \n" + - " GRAPH <eg:tmp> {\n" + - " <eg:A> <eg:moveTo> <eg:AA> .\n" + - " <eg:B> <eg:moveTo> <eg:BB> \n" + - " }\n" + - "}\n"); - makeUpdate( "INSERT {\n" + - " GRAPH <eg:A> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}\n" + - "WHERE {\n" + - " GRAPH <eg:tmp> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}"); - makeUpdate( "INSERT {\n" + - " GRAPH <eg:B> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}\n" + - "WHERE {\n" + - " GRAPH <eg:tmp> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}"); - assertQuad("<eg:A>","<eg:A> <eg:moveTo> <eg:AA> "); - assertQuad("<eg:B>","<eg:A> <eg:moveTo> <eg:AA> "); - assertQuad("<eg:A>","<eg:B> <eg:moveTo> <eg:BB>"); - assertQuad("<eg:B>","<eg:B> <eg:moveTo> <eg:BB> "); - makeUpdate( "DELETE {\n" + - " GRAPH ?oldg {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}\n" + - "INSERT {\n" + - " GRAPH ?newg {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}\n" + - "WHERE {\n" + - " GRAPH <eg:tmp> {\n" + - " ?oldg <eg:moveTo> ?newg\n" + - " }\n" + - " GRAPH ?oldg {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}"); - assertNotQuad("<eg:A>","<eg:A> <eg:moveTo> <eg:AA> "); - assertNotQuad("<eg:B>","<eg:A> <eg:moveTo> <eg:AA> "); - assertNotQuad("<eg:A>","<eg:B> <eg:moveTo> <eg:BB>"); - assertNotQuad("<eg:B>","<eg:B> <eg:moveTo> <eg:BB> "); - assertQuad("<eg:AA>","<eg:A> <eg:moveTo> <eg:AA> "); - assertQuad("<eg:BB>","<eg:A> <eg:moveTo> <eg:AA> "); - assertQuad("<eg:AA>","<eg:B> <eg:moveTo> <eg:BB>"); - assertQuad("<eg:BB>","<eg:B> <eg:moveTo> <eg:BB> "); - } - public void test_triple_template_and_fixed_insert() throws IOException { - makeUpdate( "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + - "INSERT DATA\n" + - "{ \n" + - " GRAPH <eg:tmp> {\n" + - " <eg:b> rdf:type <eg:c> .\n" + - " }\n" + - "}\n"); - makeUpdate( "INSERT {\n" + - " GRAPH <eg:A> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - " GRAPH <eg:B> {\n" + - " <eg:b> rdf:type <eg:c> .\n" + - " }\n" + - "}\n" + - "WHERE {\n" + - " GRAPH <eg:tmp> {\n" + - " ?olds ?oldp ?oldo\n" + - " }\n" + - "}"); - assertQuad("<eg:A>","<eg:b> rdf:type <eg:c> "); - assertQuad("<eg:B>","<eg:b> rdf:type <eg:c> "); - } - static public Test suite() { - return ProxySuiteHelper.suiteWhenStandalone(NamedGraphUpdateTest.class,"test.*", TestMode.quads); - } - -} Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/NativeDistinctNamedGraphUpdateTest.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/NativeDistinctNamedGraphUpdateTest.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/NativeDistinctNamedGraphUpdateTest.java 2014-01-24 23:39:36 UTC (rev 7828) @@ -0,0 +1,36 @@ +/** +Copyright (C) SYSTAP, LLC 2014. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.rdf.sail.webapp; + +import junit.framework.Test; + +public class NativeDistinctNamedGraphUpdateTest extends AbstractNamedGraphUpdateTest { + + static public Test suite() { + return ProxySuiteHelper.suiteWhenStandalone(NativeDistinctNamedGraphUpdateTest.class,"test.*", TestMode.quads); + } + public NativeDistinctNamedGraphUpdateTest(String name) { + super(true, name); + } + +} Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlServerWithProxyIndexManager.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlServerWithProxyIndexManager.java 2014-01-24 18:42:02 UTC (rev 7827) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlServerWithProxyIndexManager.java 2014-01-24 23:39:36 UTC (rev 7828) @@ -247,6 +247,8 @@ case quads: // QUADS mode UPDATE test suite. suite.addTestSuite(TestSparqlUpdate.class); + suite.addTestSuite( NativeDistinctNamedGraphUpdateTest.class ); + suite.addTestSuite( HashDistinctNamedGraphUpdateTest.class ); break; default: throw new UnsupportedOperationException(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |