From: <mrp...@us...> - 2012-04-05 08:39:51
|
Revision: 6256 http://bigdata.svn.sourceforge.net/bigdata/?rev=6256&view=rev Author: mrpersonick Date: 2012-04-05 08:39:41 +0000 (Thu, 05 Apr 2012) Log Message: ----------- fixed more materialization problems Modified Paths: -------------- branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/RegexBOp.java branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrBOp.java branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/XsdStrBOp.java branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailEmbeddedFederationWithQuads.java branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java Added Paths: ----------- branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMaterialization.java Removed Paths: ------------- branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestRegex.java Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/RegexBOp.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/RegexBOp.java 2012-04-05 08:37:22 UTC (rev 6255) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/RegexBOp.java 2012-04-05 08:39:41 UTC (rev 6256) @@ -64,25 +64,35 @@ final IValueExpression<? extends IV> pattern, final IValueExpression<? extends IV> flags) { - if (pattern instanceof IConstant && - (flags == null || flags instanceof IConstant)) { + try { - final IV parg = ((IConstant<IV>) pattern).get(); - - final IV farg = flags != null ? - ((IConstant<IV>) flags).get() : null; - - if (parg.hasValue() && (farg == null || farg.hasValue())) { - - final Value pargVal = parg.getValue(); - - final Value fargVal = farg != null ? farg.getValue() : null; - - return NV.asMap( - new NV(Annotations.PATTERN, - getPattern(pargVal, fargVal))); + if (pattern instanceof IConstant && + (flags == null || flags instanceof IConstant)) { - } + final IV parg = ((IConstant<IV>) pattern).get(); + + final IV farg = flags != null ? + ((IConstant<IV>) flags).get() : null; + + if (parg.hasValue() && (farg == null || farg.hasValue())) { + + final Value pargVal = parg.getValue(); + + final Value fargVal = farg != null ? farg.getValue() : null; + + return NV.asMap( + new NV(Annotations.PATTERN, + getPattern(pargVal, fargVal))); + + } + + } + + } catch (Exception ex) { + + if (log.isInfoEnabled()) { + log.info("could not create pattern for: " + pattern + ", " + flags); + } } Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrBOp.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrBOp.java 2012-04-05 08:37:22 UTC (rev 6255) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrBOp.java 2012-04-05 08:39:41 UTC (rev 6256) @@ -27,18 +27,18 @@ import java.util.Map; import org.apache.log4j.Logger; +import org.openrdf.model.Literal; import org.openrdf.model.URI; +import org.openrdf.model.Value; import com.bigdata.bop.BOp; import com.bigdata.bop.IBindingSet; import com.bigdata.bop.IValueExpression; -import com.bigdata.bop.NV; import com.bigdata.rdf.error.SparqlTypeErrorException; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.internal.impl.literal.AbstractLiteralIV; import com.bigdata.rdf.model.BigdataLiteral; import com.bigdata.rdf.model.BigdataValueFactory; -import com.bigdata.rdf.model.BigdataValueFactoryImpl; import com.bigdata.rdf.sparql.ast.GlobalAnnotations; /** @@ -86,27 +86,22 @@ public IV get(final IBindingSet bs) { final IV iv = getAndCheckBound(0, bs); + + if (log.isDebugEnabled()) { + log.debug(iv); + } + + final Value val = asValue(iv); + if (log.isDebugEnabled()) { + log.debug(val); + } + // use to create my simple literals final BigdataValueFactory vf = getValueFactory(); - if (iv.isInline() && !iv.isExtension()) { - if(iv.isLiteral()){ - return super.asIV(vf.createLiteral( - ((AbstractLiteralIV)iv).getLabel()), bs); - }else{ - return super.asIV(vf.createLiteral(iv - .getInlineValue().toString()), bs); - } - } - - if (iv.isURI()) { - // return new simple literal using URI label - final URI uri = (URI) iv.getValue(); - final BigdataLiteral str = vf.createLiteral(uri.toString()); - return super.asIV(str, bs); - } else if (iv.isLiteral()) { - final BigdataLiteral lit = (BigdataLiteral) iv.getValue(); + if (val instanceof Literal) { + final Literal lit = (Literal) val; if (lit.getDatatype() == null && lit.getLanguage() == null) { // if simple literal return it return iv; @@ -116,9 +111,43 @@ final BigdataLiteral str = vf.createLiteral(lit.getLabel()); return super.asIV(str, bs); } + } else if (val instanceof URI) { + // return new simple literal using URI label + final BigdataLiteral str = vf.createLiteral(val.stringValue()); + return super.asIV(str, bs); } else { throw new SparqlTypeErrorException(); } + +// if (iv.isInline() && !iv.isExtension()) { +// if(iv.isLiteral()){ +// return super.asIV(vf.createLiteral( +// ((AbstractLiteralIV)iv).getLabel()), bs); +// }else{ +// return super.asIV(vf.createLiteral(iv +// .getInlineValue().toString()), bs); +// } +// } +// +// if (iv.isURI()) { +// // return new simple literal using URI label +// final URI uri = (URI) iv.getValue(); +// final BigdataLiteral str = vf.createLiteral(uri.toString()); +// return super.asIV(str, bs); +// } else if (iv.isLiteral()) { +// final BigdataLiteral lit = (BigdataLiteral) iv.getValue(); +// if (lit.getDatatype() == null && lit.getLanguage() == null) { +// // if simple literal return it +// return iv; +// } +// else { +// // else return new simple literal using Literal.getLabel +// final BigdataLiteral str = vf.createLiteral(lit.getLabel()); +// return super.asIV(str, bs); +// } +// } else { +// throw new SparqlTypeErrorException(); +// } } Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/XsdStrBOp.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/XsdStrBOp.java 2012-04-05 08:37:22 UTC (rev 6255) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/XsdStrBOp.java 2012-04-05 08:39:41 UTC (rev 6256) @@ -27,7 +27,9 @@ import java.util.Map; import org.apache.log4j.Logger; +import org.openrdf.model.Literal; import org.openrdf.model.URI; +import org.openrdf.model.Value; import com.bigdata.bop.BOp; import com.bigdata.bop.IBindingSet; @@ -86,27 +88,22 @@ public IV get(final IBindingSet bs) { final IV iv = getAndCheckBound(0, bs); + + if (log.isDebugEnabled()) { + log.debug(iv); + } + + final Value val = asValue(iv); + if (log.isDebugEnabled()) { + log.debug(val); + } + // use to create my simple literals final BigdataValueFactory vf = getValueFactory(); - if (iv.isInline() && !iv.isExtension()) { - if(iv.isLiteral()){ - return super.asIV(vf.createLiteral( - ((AbstractLiteralIV)iv).getLabel(), XSD.STRING), bs); - }else{ - return super.asIV(vf.createLiteral(iv - .getInlineValue().toString(), XSD.STRING), bs); - } - } - - if (iv.isURI()) { - // return new xsd:string literal using URI label - final URI uri = (URI) iv.getValue(); - final BigdataLiteral str = vf.createLiteral(uri.toString(), XSD.STRING); - return super.asIV(str, bs); - } else if (iv.isLiteral()) { - final BigdataLiteral lit = (BigdataLiteral) iv.getValue(); + if (val instanceof Literal) { + final Literal lit = (Literal) val; if (lit.getDatatype() != null && lit.getDatatype().equals(XSD.STRING)) { // if xsd:string literal return it return iv; @@ -116,9 +113,48 @@ final BigdataLiteral str = vf.createLiteral(lit.getLabel(), XSD.STRING); return super.asIV(str, bs); } + } else if (val instanceof URI) { + // return new simple literal using URI label + final BigdataLiteral str = vf.createLiteral(val.stringValue(), XSD.STRING); + return super.asIV(str, bs); } else { throw new SparqlTypeErrorException(); } + +// final IV iv = getAndCheckBound(0, bs); +// +// // use to create my simple literals +// final BigdataValueFactory vf = getValueFactory(); +// +// if (iv.isInline() && !iv.isExtension()) { +// if(iv.isLiteral()){ +// return super.asIV(vf.createLiteral( +// ((AbstractLiteralIV)iv).getLabel(), XSD.STRING), bs); +// }else{ +// return super.asIV(vf.createLiteral(iv +// .getInlineValue().toString(), XSD.STRING), bs); +// } +// } +// +// if (iv.isURI()) { +// // return new xsd:string literal using URI label +// final URI uri = (URI) iv.getValue(); +// final BigdataLiteral str = vf.createLiteral(uri.toString(), XSD.STRING); +// return super.asIV(str, bs); +// } else if (iv.isLiteral()) { +// final BigdataLiteral lit = (BigdataLiteral) iv.getValue(); +// if (lit.getDatatype() != null && lit.getDatatype().equals(XSD.STRING)) { +// // if xsd:string literal return it +// return iv; +// } +// else { +// // else return new xsd:string literal using Literal.getLabel +// final BigdataLiteral str = vf.createLiteral(lit.getLabel(), XSD.STRING); +// return super.asIV(str, bs); +// } +// } else { +// throw new SparqlTypeErrorException(); +// } } Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailEmbeddedFederationWithQuads.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailEmbeddedFederationWithQuads.java 2012-04-05 08:37:22 UTC (rev 6255) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailEmbeddedFederationWithQuads.java 2012-04-05 08:39:41 UTC (rev 6256) @@ -113,7 +113,7 @@ suite.addTestSuite(com.bigdata.rdf.sail.DavidsTestBOps.class); suite.addTestSuite(com.bigdata.rdf.sail.TestLexJoinOps.class); - suite.addTestSuite(com.bigdata.rdf.sail.TestRegex.class); + suite.addTestSuite(com.bigdata.rdf.sail.TestMaterialization.class); // The Sesame TCK, including the SPARQL test suite. { Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2012-04-05 08:37:22 UTC (rev 6255) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2012-04-05 08:39:41 UTC (rev 6256) @@ -124,7 +124,7 @@ suite.addTestSuite(com.bigdata.rdf.sail.DavidsTestBOps.class); suite.addTestSuite(com.bigdata.rdf.sail.TestLexJoinOps.class); - suite.addTestSuite(com.bigdata.rdf.sail.TestRegex.class); + suite.addTestSuite(com.bigdata.rdf.sail.TestMaterialization.class); // The Sesame TCK, including the SPARQL test suite. { Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2012-04-05 08:37:22 UTC (rev 6255) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2012-04-05 08:39:41 UTC (rev 6256) @@ -100,7 +100,7 @@ suite.addTestSuite(com.bigdata.rdf.sail.TestTicket422.class); suite.addTestSuite(com.bigdata.rdf.sail.TestLexJoinOps.class); - suite.addTestSuite(com.bigdata.rdf.sail.TestRegex.class); + suite.addTestSuite(com.bigdata.rdf.sail.TestMaterialization.class); return suite; Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java 2012-04-05 08:37:22 UTC (rev 6255) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java 2012-04-05 08:39:41 UTC (rev 6256) @@ -95,7 +95,7 @@ suite.addTestSuite(com.bigdata.rdf.sail.TestTicket473.class); suite.addTestSuite(com.bigdata.rdf.sail.TestLexJoinOps.class); - suite.addTestSuite(com.bigdata.rdf.sail.TestRegex.class); + suite.addTestSuite(com.bigdata.rdf.sail.TestMaterialization.class); return suite; Copied: branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMaterialization.java (from rev 6253, branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestRegex.java) =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMaterialization.java (rev 0) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMaterialization.java 2012-04-05 08:39:41 UTC (rev 6256) @@ -0,0 +1,328 @@ +/** +Copyright (C) SYSTAP, LLC 2006-2007. 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; + +import java.util.Properties; + +import org.apache.log4j.Logger; +import org.openrdf.model.Literal; +import org.openrdf.model.URI; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.vocabulary.RDF; +import org.openrdf.model.vocabulary.RDFS; +import org.openrdf.query.QueryLanguage; +import org.openrdf.query.TupleQueryResult; +import org.openrdf.repository.RepositoryConnection; +import org.openrdf.repository.sail.SailTupleQuery; + +import com.bigdata.rdf.axioms.NoAxioms; +import com.bigdata.rdf.internal.XSD; +import com.bigdata.rdf.sparql.ast.QueryHints; +import com.bigdata.rdf.sparql.ast.QueryOptimizerEnum; +import com.bigdata.rdf.store.BD; +import com.bigdata.rdf.vocab.NoVocabulary; + +public class TestMaterialization extends ProxyBigdataSailTestCase { + + protected static final Logger log = Logger.getLogger(TestMaterialization.class); + + protected static final boolean INFO = log.isInfoEnabled(); + + /** + * + */ + public TestMaterialization() { + } + + /** + * @param arg0 + */ + public TestMaterialization(String arg0) { + super(arg0); + } + + @Override + public Properties getProperties() { + + Properties props = super.getProperties(); + + props.setProperty(BigdataSail.Options.TEXT_INDEX, "true"); + + return props; + + } + + public void testRegex() throws Exception { + + final BigdataSail sail = getSail(); + try { + sail.initialize(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); + + final RepositoryConnection cxn = repo.getConnection(); + + try { + cxn.setAutoCommit(false); + + final ValueFactory vf = sail.getValueFactory(); + + /* + * Create some terms. + */ + final URI X = vf.createURI(BD.NAMESPACE + "X"); + final Literal label = vf.createLiteral("John"); + + /* + * Create some statements. + */ + cxn.add(X, RDF.TYPE, RDFS.RESOURCE); + cxn.add(X, RDFS.LABEL, label); + + /* + * Note: The either flush() or commit() is required to flush the + * statement buffers to the database before executing any operations + * that go around the sail. + */ + cxn.commit(); + + if (log.isInfoEnabled()) { + log.info(sail.getDatabase().dumpStore()); + } + + { + + String query = + "select * where { ?s ?p ?o . FILTER (regex(?o,\"John\",\"i\")) }"; + + final SailTupleQuery tupleQuery = (SailTupleQuery) + cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + tupleQuery.setIncludeInferred(true /* includeInferred */); + + if (log.isInfoEnabled()) { + + log.info(query); + + final TupleQueryResult result = tupleQuery.evaluate(); + while (result.hasNext()) { + log.info(result.next()); + } + + } + +// final Collection<BindingSet> answer = new LinkedList<BindingSet>(); +// answer.add(createBindingSet( +// new BindingImpl("a", paul), +// new BindingImpl("b", mary) +// )); +// answer.add(createBindingSet( +// new BindingImpl("a", brad), +// new BindingImpl("b", john) +// )); +// +// final TupleQueryResult result = tupleQuery.evaluate(); +// compare(result, answer); + + } + + } finally { + cxn.close(); + } + } finally { + if (sail instanceof BigdataSail) + ((BigdataSail)sail).__tearDownUnitTest();//shutDown(); + } + + } + + public void testStr() throws Exception { + + final BigdataSail sail = getSail(); + try { + sail.initialize(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); + + final RepositoryConnection cxn = repo.getConnection(); + + try { + cxn.setAutoCommit(false); + + final ValueFactory vf = sail.getValueFactory(); + + /* + * Create some terms. + */ + final URI X = vf.createURI(BD.NAMESPACE + "X"); + final Literal label = vf.createLiteral("John"); + + /* + * Create some statements. + */ + cxn.add(X, RDF.TYPE, RDFS.RESOURCE); + cxn.add(X, RDFS.LABEL, label); + + /* + * Note: The either flush() or commit() is required to flush the + * statement buffers to the database before executing any operations + * that go around the sail. + */ + cxn.commit(); + + if (log.isInfoEnabled()) { + log.info(sail.getDatabase().dumpStore()); + } + + { + + String query = + "select * where { ?s ?p ?o . FILTER (str(?o) = \""+RDF.PROPERTY+"\") }"; + + final SailTupleQuery tupleQuery = (SailTupleQuery) + cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + tupleQuery.setIncludeInferred(true /* includeInferred */); + + if (log.isInfoEnabled()) { + + log.info(query); + + final TupleQueryResult result = tupleQuery.evaluate(); + if (result.hasNext()) { + while (result.hasNext()) + log.info(result.next()); + } else { + fail("expecting result from the vocab"); + } + + } + +// final Collection<BindingSet> answer = new LinkedList<BindingSet>(); +// answer.add(createBindingSet( +// new BindingImpl("a", paul), +// new BindingImpl("b", mary) +// )); +// answer.add(createBindingSet( +// new BindingImpl("a", brad), +// new BindingImpl("b", john) +// )); + // +// final TupleQueryResult result = tupleQuery.evaluate(); +// compare(result, answer); + + } + + } finally { + cxn.close(); + } + } finally { + if (sail instanceof BigdataSail) + ((BigdataSail)sail).__tearDownUnitTest();//shutDown(); + } + + } + + public void testXsdStr() throws Exception { + + final BigdataSail sail = getSail(); + try { + sail.initialize(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); + + final RepositoryConnection cxn = repo.getConnection(); + + try { + cxn.setAutoCommit(false); + + final ValueFactory vf = sail.getValueFactory(); + + /* + * Create some terms. + */ + final URI X = vf.createURI(BD.NAMESPACE + "X"); + final Literal label = vf.createLiteral("John"); + + /* + * Create some statements. + */ + cxn.add(X, RDF.TYPE, RDFS.RESOURCE); + cxn.add(X, RDFS.LABEL, label); + + /* + * Note: The either flush() or commit() is required to flush the + * statement buffers to the database before executing any operations + * that go around the sail. + */ + cxn.commit(); + + if (log.isInfoEnabled()) { + log.info(sail.getDatabase().dumpStore()); + } + + { + + String query = + "select * where { ?s ?p ?o . FILTER (xsd:string(?o) = \""+RDF.PROPERTY+"\"^^xsd:string) }"; + + final SailTupleQuery tupleQuery = (SailTupleQuery) + cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + tupleQuery.setIncludeInferred(true /* includeInferred */); + + if (log.isInfoEnabled()) { + + log.info(query); + + final TupleQueryResult result = tupleQuery.evaluate(); + if (result.hasNext()) { + while (result.hasNext()) + log.info(result.next()); + } else { + fail("expecting result from the vocab"); + } + + } + +// final Collection<BindingSet> answer = new LinkedList<BindingSet>(); +// answer.add(createBindingSet( +// new BindingImpl("a", paul), +// new BindingImpl("b", mary) +// )); +// answer.add(createBindingSet( +// new BindingImpl("a", brad), +// new BindingImpl("b", john) +// )); + // +// final TupleQueryResult result = tupleQuery.evaluate(); +// compare(result, answer); + + } + + } finally { + cxn.close(); + } + } finally { + if (sail instanceof BigdataSail) + ((BigdataSail)sail).__tearDownUnitTest();//shutDown(); + } + + } + +} Deleted: branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestRegex.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestRegex.java 2012-04-05 08:37:22 UTC (rev 6255) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestRegex.java 2012-04-05 08:39:41 UTC (rev 6256) @@ -1,169 +0,0 @@ -/** -Copyright (C) SYSTAP, LLC 2006-2007. 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; - -import java.util.Properties; - -import org.apache.log4j.Logger; -import org.openrdf.model.Literal; -import org.openrdf.model.URI; -import org.openrdf.model.ValueFactory; -import org.openrdf.model.vocabulary.RDF; -import org.openrdf.model.vocabulary.RDFS; -import org.openrdf.query.QueryLanguage; -import org.openrdf.query.TupleQueryResult; -import org.openrdf.repository.RepositoryConnection; -import org.openrdf.repository.sail.SailTupleQuery; - -import com.bigdata.rdf.axioms.NoAxioms; -import com.bigdata.rdf.internal.XSD; -import com.bigdata.rdf.sparql.ast.QueryHints; -import com.bigdata.rdf.sparql.ast.QueryOptimizerEnum; -import com.bigdata.rdf.store.BD; -import com.bigdata.rdf.vocab.NoVocabulary; - -public class TestRegex extends ProxyBigdataSailTestCase { - - protected static final Logger log = Logger.getLogger(TestRegex.class); - - protected static final boolean INFO = log.isInfoEnabled(); - - /** - * - */ - public TestRegex() { - } - - /** - * @param arg0 - */ - public TestRegex(String arg0) { - super(arg0); - } - - @Override - public Properties getProperties() { - - Properties props = super.getProperties(); - - props.setProperty(BigdataSail.Options.TEXT_INDEX, "true"); - - return props; - - } - - public void testRegex() throws Exception { - - final BigdataSail sail = getSail(); - try { - sail.initialize(); - final BigdataSailRepository repo = new BigdataSailRepository(sail); - - final RepositoryConnection cxn = repo.getConnection(); - - try { - cxn.setAutoCommit(false); - - final ValueFactory vf = sail.getValueFactory(); - - /* - * Create some terms. - */ - final URI X = vf.createURI(BD.NAMESPACE + "X"); - final Literal label = vf.createLiteral("John"); - - /* - * Create some statements. - */ - cxn.add(X, RDF.TYPE, RDFS.RESOURCE); - cxn.add(X, RDFS.LABEL, label); - - /* - * Note: The either flush() or commit() is required to flush the - * statement buffers to the database before executing any operations - * that go around the sail. - */ - cxn.commit(); - - if (log.isInfoEnabled()) { - log.info(sail.getDatabase().dumpStore()); - } - - { - - String query = - "select * where { ?s ?p ?o . FILTER (regex(?o,\"John\",\"i\")) }"; - - final SailTupleQuery tupleQuery = (SailTupleQuery) - cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); - tupleQuery.setIncludeInferred(true /* includeInferred */); - - if (log.isInfoEnabled()) { - - log.info(query); - -// final BigdataSailTupleQuery bdTupleQuery = -// (BigdataSailTupleQuery) tupleQuery; -// final QueryRoot root = (QueryRoot) bdTupleQuery.getTupleExpr(); -// final Projection p = (Projection) root.getArg(); -// final TupleExpr tupleExpr = p.getArg(); -// final SOpTreeBuilder stb = new SOpTreeBuilder(); -// final SOpTree tree = stb.collectSOps(tupleExpr); - -// log.info(tree); -// log.info(query); - - final TupleQueryResult result = tupleQuery.evaluate(); - while (result.hasNext()) { - log.info(result.next()); - } - - } - -// final Collection<BindingSet> answer = new LinkedList<BindingSet>(); -// answer.add(createBindingSet( -// new BindingImpl("a", paul), -// new BindingImpl("b", mary) -// )); -// answer.add(createBindingSet( -// new BindingImpl("a", brad), -// new BindingImpl("b", john) -// )); -// -// final TupleQueryResult result = tupleQuery.evaluate(); -// compare(result, answer); - - } - - } finally { - cxn.close(); - } - } finally { - if (sail instanceof BigdataSail) - ((BigdataSail)sail).__tearDownUnitTest();//shutDown(); - } - - } - -} Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java 2012-04-05 08:37:22 UTC (rev 6255) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java 2012-04-05 08:39:41 UTC (rev 6256) @@ -229,6 +229,7 @@ */ static final Collection<String> testURIs = Arrays.asList(new String[] { +// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-builtin/manifest#dawg-datatype-2" // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/cast/manifest#cast-dT" // 8, 9, 14-19, 23-30 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |