From: <mrp...@us...> - 2014-07-16 16:01:05
|
Revision: 8558 http://sourceforge.net/p/bigdata/code/8558 Author: mrpersonick Date: 2014-07-16 16:01:00 +0000 (Wed, 16 Jul 2014) Log Message: ----------- Ticket #714: Sesame 2.7 migration Modified Paths: -------------- branches/SESAME_2_7/bigdata/src/resources/logging/log4j.properties branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/ConcatBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DatatypeBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DateBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DigestBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/IriBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/IsNumericBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/NumericBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrAfterBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrBeforeBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrdtBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrlangBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/impl/AbstractIV.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/model/BigdataURIImpl.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/turtle/BigdataTurtleParser.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/BindingsClause.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/FunctionRegistry.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/GroupMemberValueExpressionNodeBase.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryBase.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryRoot.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/StaticAnalysis.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdate.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdateContext.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUtility.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTEvalHelper.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTBottomUpOptimizer.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTGraphGroupOptimizer.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTJoinOrderByTypeOptimizer.java branches/SESAME_2_7/bigdata-rdf/src/resources/service-providers/META-INF/services/org.openrdf.query.resultio.TupleQueryResultWriterFactory branches/SESAME_2_7/bigdata-rdf/src/resources/service-providers/META-INF/services/org.openrdf.rio.RDFParserFactory branches/SESAME_2_7/bigdata-rdf/src/resources/service-providers/META-INF/services/org.openrdf.rio.RDFWriterFactory branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailTupleQuery.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailUpdate.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataValueReplacer.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ASTVisitorBase.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/BaseDeclProcessor.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/BigdataExprBuilder.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/BlankNodeVarProcessor.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/GroupGraphPatternBuilder.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/PrefixDeclProcessor.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/UpdateExprBuilder.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ValueExprBuilder.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ast/SyntaxTreeBuilder.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ast/SyntaxTreeBuilderConstants.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ast/SyntaxTreeBuilderTokenManager.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ast/SyntaxTreeBuilderTreeConstants.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ast/SyntaxTreeBuilderVisitor.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ast/sparql.jj branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ast/sparql.jjt branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataComplexSparqlQueryTest.java branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataConnectionTest.java branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSPARQLUpdateConformanceTest.java branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSPARQLUpdateTest.java branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataStoreTest.java branches/SESAME_2_7/bigdata-sails/src/test/org/openrdf/query/parser/sparql/SPARQLUpdateTest.java branches/SESAME_2_7/bigdata-sails/src/test/org/openrdf/query/parser/sparql/manifest/SPARQLQueryTest.java branches/SESAME_2_7/bigdata-sails/src/test/org/openrdf/repository/RepositoryConnectionTest.java branches/SESAME_2_7/bigdata-sails/src/test/org/openrdf/sail/RDFStoreTest.java Added Paths: ----------- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/NowBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/UUIDBOp.java branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTValuesOptimizer.java branches/SESAME_2_7/bigdata-rdf/src/resources/service-providers/META-INF/services/org.openrdf.query.resultio.TupleQueryResultParserFactory branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/rio/Bar.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/rio/Foo.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ast/ASTInlineData.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ast/ASTSTRUUID.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ast/ASTUUID.java branches/SESAME_2_7/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ast/ASTUnparsedQuadDataBlock.java branches/SESAME_2_7/bigdata-sails/src/java/org/openrdf/query/parser/sparql/ branches/SESAME_2_7/bigdata-sails/src/java/org/openrdf/query/parser/sparql/manifest/ branches/SESAME_2_7/bigdata-sails/src/java/org/openrdf/query/parser/sparql/manifest/SPARQL11ManifestTest.java branches/SESAME_2_7/bigdata-sails/src/test/org/openrdf/model/ branches/SESAME_2_7/bigdata-sails/src/test/org/openrdf/model/util/ branches/SESAME_2_7/bigdata-sails/src/test/org/openrdf/model/util/ModelUtil.java branches/SESAME_2_7/bigdata-sails/src/test/org/openrdf/query/parser/sparql/manifest/SPARQLUpdateConformanceTest.java Modified: branches/SESAME_2_7/bigdata/src/resources/logging/log4j.properties =================================================================== --- branches/SESAME_2_7/bigdata/src/resources/logging/log4j.properties 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata/src/resources/logging/log4j.properties 2014-07-16 16:01:00 UTC (rev 8558) @@ -16,7 +16,8 @@ log4j.logger.com.bigdata.rdf.store.DataLoader=INFO log4j.logger.com.bigdata.resources.AsynchronousOverflowTask=INFO -#log4j.logger.com.bigdata.rdf.rio.StatementBuffer=ALL +log4j.logger.com.bigdata.rdf.sparql=ALL +#log4j.logger.com.bigdata.rdf.sail.sparql.BigdataExprBuilder=INFO #log4j.logger.com.bigdata.rdf.sail.TestProvenanceQuery=ALL #log4j.logger.com.bigdata.rdf.sail.TestSids=ALL #log4j.logger.com.bigdata.rdf.sail.ProxyBigdataSailTestCase=ALL Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/ConcatBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/ConcatBOp.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/ConcatBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -31,6 +31,7 @@ import com.bigdata.bop.BOp; import com.bigdata.bop.IBindingSet; import com.bigdata.bop.IValueExpression; +import com.bigdata.rdf.error.SparqlTypeErrorException; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.sparql.ast.GlobalAnnotations; @@ -76,6 +77,11 @@ for (int i = 0; i < arity(); i++) { @SuppressWarnings("rawtypes") final IV v = getAndCheckLiteral(i, bs); + + if (v.isNumeric()) { + throw new SparqlTypeErrorException(); + } + String label = null; if (allSame) { final Literal lit = asLiteral(v); Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DatatypeBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DatatypeBOp.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DatatypeBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -30,6 +30,7 @@ import org.openrdf.model.Literal; import org.openrdf.model.URI; import org.openrdf.model.Value; +import org.openrdf.model.vocabulary.RDF; import com.bigdata.bop.BOp; import com.bigdata.bop.IBindingSet; @@ -121,6 +122,11 @@ // literal with datatype datatype = literal.getDatatype(); + } else if (literal.getLanguage() != null) { + + // language-tag literal + datatype = RDF.LANGSTRING; + } else if (literal.getLanguage() == null) { // simple literal Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DateBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DateBOp.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DateBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -23,10 +23,17 @@ */ package com.bigdata.rdf.internal.constraints; +import java.math.BigDecimal; +import java.math.BigInteger; import java.util.Map; import javax.xml.datatype.XMLGregorianCalendar; +import org.openrdf.model.Literal; +import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException; +import org.openrdf.query.algebra.evaluation.function.datetime.Timezone; +import org.openrdf.query.algebra.evaluation.function.datetime.Tz; + import com.bigdata.bop.BOp; import com.bigdata.bop.IBindingSet; import com.bigdata.bop.IValueExpression; @@ -36,8 +43,12 @@ import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.internal.NotMaterializedException; import com.bigdata.rdf.internal.XSD; -import com.bigdata.rdf.internal.impl.literal.XSDNumericIV; +import com.bigdata.rdf.internal.impl.literal.XSDDecimalIV; +import com.bigdata.rdf.internal.impl.literal.XSDIntegerIV; import com.bigdata.rdf.model.BigdataLiteral; +import com.bigdata.rdf.model.BigdataValueFactory; +import com.bigdata.rdf.sparql.ast.DummyConstantNode; +import com.bigdata.rdf.sparql.ast.FilterNode; import com.bigdata.rdf.sparql.ast.GlobalAnnotations; /** @@ -63,14 +74,14 @@ } public enum DateOp { - YEAR, MONTH, DAY, HOURS, MINUTES, SECONDS, TIMEZONE; + YEAR, MONTH, DAY, HOURS, MINUTES, SECONDS, TZ, TIMEZONE } @Override protected boolean areGlobalsRequired() { - return false; + return true; } @@ -84,9 +95,9 @@ * The annotation specifying the operation to be performed on those operands. */ public DateBOp(final IValueExpression<? extends IV> left, - final DateOp op) { + final DateOp op, final GlobalAnnotations globals) { - this(new BOp[] { left }, NV.asMap(Annotations.OP, op)); + this(new BOp[] { left }, anns(globals, new NV(Annotations.OP, op))); } @@ -140,19 +151,21 @@ XMLGregorianCalendar cal=bl.calendarValue(); switch (op()) { case DAY: - return new XSDNumericIV(cal.getDay()); + return new XSDIntegerIV(BigInteger.valueOf(cal.getDay())); case MONTH: - return new XSDNumericIV(cal.getMonth()); + return new XSDIntegerIV(BigInteger.valueOf(cal.getMonth())); case YEAR: - return new XSDNumericIV(cal.getYear()); + return new XSDIntegerIV(BigInteger.valueOf(cal.getYear())); case HOURS: - return new XSDNumericIV(cal.getHour()); + return new XSDIntegerIV(BigInteger.valueOf(cal.getHour())); case SECONDS: - return new XSDNumericIV(cal.getSecond()); + return new XSDDecimalIV(BigDecimal.valueOf(cal.getSecond())); case MINUTES: - return new XSDNumericIV(cal.getMinute()); + return new XSDIntegerIV(BigInteger.valueOf(cal.getMinute())); + case TZ: + return tz(bl); case TIMEZONE: - return new XSDNumericIV(cal.getTimezone()); + return timezone(bl); default: throw new UnsupportedOperationException(); } @@ -181,5 +194,45 @@ public Requirement getRequirement() { return Requirement.SOMETIMES; } + + protected IV tz(final BigdataLiteral l) { + + final Tz func = new Tz(); + + final BigdataValueFactory vf = super.getValueFactory(); + + try { + + final BigdataLiteral l2 = (BigdataLiteral) func.evaluate(vf, l); + + return DummyConstantNode.toDummyIV(l2); + + } catch (ValueExprEvaluationException e) { + + throw new SparqlTypeErrorException(); + + } + + } + protected IV timezone(final BigdataLiteral l) { + + final Timezone func = new Timezone(); + + final BigdataValueFactory vf = super.getValueFactory(); + + try { + + final BigdataLiteral l2 = (BigdataLiteral) func.evaluate(vf, l); + + return DummyConstantNode.toDummyIV(l2); + + } catch (ValueExprEvaluationException e) { + + throw new SparqlTypeErrorException(); + + } + + } + } Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DigestBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DigestBOp.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/DigestBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -146,8 +146,9 @@ //Recreate since they are not thread safe MessageDigest md = null; final Literal lit = asLiteral(iv); - if (lit.getLanguage() != null || lit.getDatatype() != null - && lit.getDatatype().equals(XSD.STRING)) { + if (lit.getLanguage() == null && + (lit.getDatatype() == null || lit.getDatatype().equals(XSD.STRING))) { + try { String label = lit.getLabel(); switch (op()) { @@ -155,19 +156,19 @@ md = MessageDigest.getInstance("MD5"); break; case SHA1: - md = MessageDigest.getInstance("SHA1"); + md = MessageDigest.getInstance("SHA-1"); break; case SHA224: - md = MessageDigest.getInstance("SHA224"); + md = MessageDigest.getInstance("SHA-224"); break; case SHA256: - md = MessageDigest.getInstance("SHA256"); + md = MessageDigest.getInstance("SHA-256"); break; case SHA384: - md = MessageDigest.getInstance("SHA384"); + md = MessageDigest.getInstance("SHA-384"); break; case SHA512: - md = MessageDigest.getInstance("SHA512"); + md = MessageDigest.getInstance("SHA-512"); break; default: throw new UnsupportedOperationException(); Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/IriBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/IriBOp.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/IriBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -27,10 +27,13 @@ import org.openrdf.model.Literal; import org.openrdf.model.URI; +import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException; import com.bigdata.bop.BOp; import com.bigdata.bop.IBindingSet; import com.bigdata.bop.IValueExpression; +import com.bigdata.bop.ImmutableBOp; +import com.bigdata.bop.NV; import com.bigdata.rdf.error.SparqlTypeErrorException; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.internal.XSD; @@ -49,9 +52,17 @@ private static final long serialVersionUID = -8448763718374010166L; + + public interface Annotations extends ImmutableBOp.Annotations { + + String BASE_URI = (IriBOp.class.getName() + ".baseURI").intern(); + + } + public IriBOp(final IValueExpression<? extends IV> x, - final GlobalAnnotations globals) { - super(x, globals); + final String baseURI, + final GlobalAnnotations globals) { + super(x, globals, new NV(Annotations.BASE_URI, baseURI)); } public IriBOp(BOp[] args, Map<String, Object> anns) { @@ -81,6 +92,8 @@ if (!iv.isLiteral()) throw new SparqlTypeErrorException(); + final String baseURI = getProperty(Annotations.BASE_URI, ""); + final Literal lit = asLiteral(iv); final URI dt = lit.getDatatype(); @@ -88,8 +101,21 @@ if (dt != null && !dt.stringValue().equals(XSD.STRING.stringValue())) throw new SparqlTypeErrorException(); - final BigdataURI uri = getValueFactory().createURI(lit.getLabel()); +// final BigdataURI uri = getValueFactory().createURI(baseURI+lit.getLabel()); + BigdataURI uri = null; + try { + uri = getValueFactory().createURI(lit.getLabel()); + } + catch (IllegalArgumentException e) { + try { + uri = getValueFactory().createURI(baseURI, lit.getLabel()); + } + catch (IllegalArgumentException e1) { + throw new SparqlTypeErrorException(); + } + } + return super.asIV(uri, bs); } Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/IsNumericBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/IsNumericBOp.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/IsNumericBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -76,7 +76,7 @@ if (iv == null) throw new SparqlTypeErrorException.UnboundVarException(); - return iv.isNumeric(); + return iv.isNumeric() && !iv.isExtension(); } Added: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/NowBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/NowBOp.java (rev 0) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/NowBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -0,0 +1,112 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2011. 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.internal.constraints; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Map; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; + +import com.bigdata.bop.BOp; +import com.bigdata.bop.IBindingSet; +import com.bigdata.bop.ImmutableBOp; +import com.bigdata.rdf.internal.IV; +import com.bigdata.rdf.sparql.ast.FilterNode; +import com.bigdata.rdf.sparql.ast.GlobalAnnotations; + +/** + * Implements the now() operator. + */ +public class NowBOp extends IVValueExpression<IV> implements INeedsMaterialization{ + + /** + * + */ + private static final long serialVersionUID = 9136864442064392445L; + + public interface Annotations extends ImmutableBOp.Annotations { + + } + + public NowBOp(final GlobalAnnotations globals) { + + this(BOp.NOARGS, anns(globals)); + + } + + /** + * Required shallow copy constructor. + * + * @param args + * The operands. + * @param op + * The operation. + */ + public NowBOp(final BOp[] args, Map<String, Object> anns) { + + super(args, anns); + + } + + /** + * Constructor required for {@link com.bigdata.bop.BOpUtility#deepCopy(FilterNode)}. + * + * @param op + */ + public NowBOp(final NowBOp op) { + + super(op); + + } + + final public IV get(final IBindingSet bs) { + + final Calendar cal = Calendar.getInstance(); + final Date now = cal.getTime(); + final GregorianCalendar c = new GregorianCalendar(); + c.setTime(now); + try { + final XMLGregorianCalendar date = + DatatypeFactory.newInstance().newXMLGregorianCalendar(c); + return super.asIV(getValueFactory().createLiteral(date), bs); + } catch (DatatypeConfigurationException e) { + throw new RuntimeException(e); + } + } + + public String toString() { + + return "now()"; + + } + + public Requirement getRequirement() { + return Requirement.NEVER; + } + +} Property changes on: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/NowBOp.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/NumericBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/NumericBOp.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/NumericBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -27,6 +27,8 @@ import org.apache.log4j.Logger; import org.openrdf.model.Literal; +import org.openrdf.model.URI; +import org.openrdf.model.vocabulary.XMLSchema; import com.bigdata.bop.BOp; import com.bigdata.bop.IBindingSet; @@ -34,6 +36,7 @@ import com.bigdata.bop.ImmutableBOp; import com.bigdata.bop.NV; import com.bigdata.rdf.internal.IV; +import com.bigdata.rdf.sparql.ast.FilterNode; /** * A math expression involving a left and right IValueExpression operand. The @@ -124,6 +127,17 @@ final Literal lit = super.getAndCheckLiteralValue(0, bs); + final URI dt = lit.getDatatype(); + + final NumericOp op = op(); + + if ((dt.equals(XMLSchema.INT) || dt.equals(XMLSchema.INTEGER)) && + (op == NumericOp.CEIL || op == NumericOp.FLOOR || op == NumericOp.ROUND)) { + + return get(0).get(bs); + + } + if (log.isDebugEnabled()) log.debug(lit); Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrAfterBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrAfterBOp.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrAfterBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -94,7 +94,7 @@ if (s2.isEmpty()) { - return ret(arg1, "", bs); + return ret(arg1, arg1.getLabel(), bs); } @@ -105,7 +105,7 @@ // didn't find it if (i < 0) { - return ret(arg1, "", bs); + return ret(arg1, null, bs); } @@ -124,6 +124,14 @@ private IV ret(final Literal arg1, final String label, final IBindingSet bs) { + if (label == null) { + + final BigdataLiteral str = getValueFactory().createLiteral(""); + + return super.asIV(str, bs); + + } + final String lang = arg1.getLanguage(); if (lang != null) { Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrBeforeBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrBeforeBOp.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrBeforeBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -102,7 +102,7 @@ // didn't find it if (i < 0) { - return ret(arg1, "", bs); + return ret(arg1, null, bs); } @@ -120,7 +120,15 @@ } private IV ret(final Literal arg1, final String label, final IBindingSet bs) { - + + if (label == null) { + + final BigdataLiteral str = getValueFactory().createLiteral(""); + + return super.asIV(str, bs); + + } + final String lang = arg1.getLanguage(); if (lang != null) { Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrdtBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrdtBOp.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrdtBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -78,6 +78,10 @@ final Literal lit = asLiteral(iv); + if (lit.getDatatype() != null || lit.getLanguage() != null) { + throw new SparqlTypeErrorException(); + } + final String label = lit.getLabel(); final BigdataLiteral str = getValueFactory().createLiteral(label, dt); Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrlangBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrlangBOp.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/StrlangBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -67,6 +67,11 @@ public IV get(final IBindingSet bs) throws SparqlTypeErrorException { final Literal lit = getAndCheckLiteralValue(0, bs); + + if (lit.getDatatype() != null || lit.getLanguage() != null) { + throw new SparqlTypeErrorException(); + } + final Literal l = getAndCheckLiteralValue(1, bs); String label = lit.getLabel(); String langLit = l.getLabel(); Added: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/UUIDBOp.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/UUIDBOp.java (rev 0) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/UUIDBOp.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -0,0 +1,133 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2011. 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.internal.constraints; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Map; +import java.util.UUID; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; + +import com.bigdata.bop.BOp; +import com.bigdata.bop.IBindingSet; +import com.bigdata.bop.ImmutableBOp; +import com.bigdata.bop.NV; +import com.bigdata.rdf.internal.IV; +import com.bigdata.rdf.model.BigdataLiteral; +import com.bigdata.rdf.model.BigdataURI; +import com.bigdata.rdf.model.BigdataValueFactory; +import com.bigdata.rdf.sparql.ast.DummyConstantNode; +import com.bigdata.rdf.sparql.ast.FilterNode; +import com.bigdata.rdf.sparql.ast.GlobalAnnotations; + +/** + * Implements the now() operator. + */ +public class UUIDBOp extends IVValueExpression<IV> implements INeedsMaterialization{ + + /** + * + */ + private static final long serialVersionUID = 9136864442064392445L; + + public interface Annotations extends ImmutableBOp.Annotations { + + String STR = UUIDBOp.class.getName() + ".str"; + + } + + public UUIDBOp(final GlobalAnnotations globals, final boolean str) { + + this(BOp.NOARGS, anns(globals, new NV(Annotations.STR, str))); + + } + + /** + * Required shallow copy constructor. + * + * @param args + * The operands. + * @param op + * The operation. + */ + public UUIDBOp(final BOp[] args, Map<String, Object> anns) { + + super(args, anns); + + } + + /** + * Constructor required for {@link com.bigdata.bop.BOpUtility#deepCopy(FilterNode)}. + * + * @param op + */ + public UUIDBOp(final UUIDBOp op) { + + super(op); + + } + + final public IV get(final IBindingSet bs) { + + final BigdataValueFactory vf = super.getValueFactory(); + + final UUID uuid = UUID.randomUUID(); + + if (str()) { + + final BigdataLiteral l = vf.createLiteral(uuid.toString()); + + return DummyConstantNode.toDummyIV(l); + + } else { + + final BigdataURI uri = vf.createURI("urn:uuid:" + uuid.toString()); + + return DummyConstantNode.toDummyIV(uri); + + } + + } + + public boolean str() { + + return (boolean) getProperty(Annotations.STR); + + } + + public String toString() { + + return str() ? "struuid()" : "uuid()"; + + } + + public Requirement getRequirement() { + return Requirement.NEVER; + } + +} Property changes on: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/UUIDBOp.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/impl/AbstractIV.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/impl/AbstractIV.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/internal/impl/AbstractIV.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -527,7 +527,7 @@ return false; } - final public boolean isNumeric() { + public boolean isNumeric() { return isInline() && getDTE().isNumeric(); } Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/model/BigdataURIImpl.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/model/BigdataURIImpl.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/model/BigdataURIImpl.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -176,7 +176,9 @@ && ((BigdataValue)o).isRealIV() && ((BigdataValue) o).getValueFactory() == getValueFactory()) { - return getIV().equals(((BigdataValue) o).getIV()); + final boolean equals = getIV().equals(((BigdataValue) o).getIV()); + + return equals; } Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/turtle/BigdataTurtleParser.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/turtle/BigdataTurtleParser.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/turtle/BigdataTurtleParser.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -15,6 +15,7 @@ import org.openrdf.model.Value; import org.openrdf.rio.RDFHandlerException; import org.openrdf.rio.RDFParseException; +import org.openrdf.rio.helpers.BasicParserSettings; import org.openrdf.rio.turtle.TurtleParser; import org.openrdf.rio.turtle.TurtleUtil; @@ -150,6 +151,28 @@ } /** + * Consumes any white space characters (space, tab, line feed, newline) and + * comments (#-style) from <tt>reader</tt>. After this method has been + * called, the first character that is returned by <tt>reader</tt> is either + * a non-ignorable character, or EOF. For convenience, this character is also + * returned by this method. + * + * @return The next character that will be returned by <tt>reader</tt>. + */ + protected int skipWS() + throws IOException + { + int c = read(); + while (TurtleUtil.isWhitespace(c)) { + c = read(); + } + + unread(c); + + return c; + } + + /** * Parses a blank node ID, e.g. <tt>_:node1</tt>. */ protected BNode parseNodeID() @@ -164,46 +187,39 @@ if (c == -1) { throwEOFException(); } -// modified to allow fully numeric bnode ids -// else if (!TurtleUtil.isNameStartChar(c)) { -// reportError("Expected a letter, found '" + (char)c + "'"); -// } +// modified to allow fully numeric bnode ids +// else if (!TurtleUtil.isNameStartChar(c)) { +// reportError("Expected a letter, found '" + (char)c + "'", BasicParserSettings.PRESERVE_BNODE_IDS); +// } StringBuilder name = new StringBuilder(32); name.append((char)c); // Read all following letter and numbers, they are part of the name c = read(); + + // If we would never go into the loop we must unread now + if (!TurtleUtil.isNameChar(c)) { + unread(c); + } + while (TurtleUtil.isNameChar(c)) { - name.append((char)c); + int previous = c; c = read(); + + if (previous == '.' && (c == -1 || TurtleUtil.isWhitespace(c) || c == '<' || c == '_')) { + unread(c); + unread(previous); + break; + } + name.append((char)previous); + if(!TurtleUtil.isNameChar(c)) + { + unread(c); + } } - unread(c); - return createBNode(name.toString()); } - /** - * Consumes any white space characters (space, tab, line feed, newline) and - * comments (#-style) from <tt>reader</tt>. After this method has been - * called, the first character that is returned by <tt>reader</tt> is either - * a non-ignorable character, or EOF. For convenience, this character is also - * returned by this method. - * - * @return The next character that will be returned by <tt>reader</tt>. - */ - protected int skipWS() - throws IOException - { - int c = read(); - while (TurtleUtil.isWhitespace(c)) { - c = read(); - } - - unread(c); - - return c; - } - } Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/BindingsClause.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/BindingsClause.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/BindingsClause.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -42,7 +42,8 @@ * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ -public class BindingsClause extends ASTBase { +public class BindingsClause extends GroupMemberNodeBase<BindingsClause> + implements IBindingProducerNode { /** * @@ -178,7 +179,7 @@ sb.append(s); - sb.append("BINDINGS"); + sb.append("BindingsClause"); for(IVariable<?> var : declaredVars) { Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/FunctionRegistry.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/FunctionRegistry.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/FunctionRegistry.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -52,6 +52,7 @@ import com.bigdata.rdf.internal.constraints.MathBOp; import com.bigdata.rdf.internal.constraints.MathBOp.MathOp; import com.bigdata.rdf.internal.constraints.NotBOp; +import com.bigdata.rdf.internal.constraints.NowBOp; import com.bigdata.rdf.internal.constraints.NumericBOp; import com.bigdata.rdf.internal.constraints.NumericBOp.NumericOp; import com.bigdata.rdf.internal.constraints.OrBOp; @@ -71,6 +72,7 @@ import com.bigdata.rdf.internal.constraints.StrstartsBOp; import com.bigdata.rdf.internal.constraints.SubstrBOp; import com.bigdata.rdf.internal.constraints.TrueBOp; +import com.bigdata.rdf.internal.constraints.UUIDBOp; import com.bigdata.rdf.internal.constraints.UcaseBOp; import com.bigdata.rdf.internal.constraints.XsdStrBOp; import com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility; @@ -137,14 +139,15 @@ public static final URI IF = new URIImpl(SPARQL_FUNCTIONS+"if"); - public static final URI NOW = new URIImpl(SPARQL_FUNCTIONS+"now"); - public static final URI YEAR = new URIImpl(SPARQL_FUNCTIONS+"year-from-dateTime"); - public static final URI MONTH = new URIImpl(SPARQL_FUNCTIONS+"month-from-dateTime"); - public static final URI DAY = new URIImpl(SPARQL_FUNCTIONS+"day-from-dateTime"); - public static final URI HOURS = new URIImpl(SPARQL_FUNCTIONS+"hours-from-dateTime"); - public static final URI MINUTES = new URIImpl(SPARQL_FUNCTIONS+"minutes-from-dateTime"); - public static final URI SECONDS = new URIImpl(SPARQL_FUNCTIONS+"seconds-from-dateTime"); - public static final URI TIMEZONE = new URIImpl(SPARQL_FUNCTIONS+"tz"); + public static final URI NOW = new URIImpl(XPATH_FUNCTIONS+"now"); + public static final URI YEAR = new URIImpl(XPATH_FUNCTIONS+"year-from-dateTime"); + public static final URI MONTH = new URIImpl(XPATH_FUNCTIONS+"month-from-dateTime"); + public static final URI DAY = new URIImpl(XPATH_FUNCTIONS+"day-from-dateTime"); + public static final URI HOURS = new URIImpl(XPATH_FUNCTIONS+"hours-from-dateTime"); + public static final URI MINUTES = new URIImpl(XPATH_FUNCTIONS+"minutes-from-dateTime"); + public static final URI SECONDS = new URIImpl(XPATH_FUNCTIONS+"seconds-from-dateTime"); + public static final URI TZ = new URIImpl(XPATH_FUNCTIONS+"tz"); + public static final URI TIMEZONE = new URIImpl(XPATH_FUNCTIONS+"timezone-from-dateTime"); public static final URI MD5 = new URIImpl(SPARQL_FUNCTIONS+"md5"); public static final URI SHA1 = new URIImpl(SPARQL_FUNCTIONS+"sha1"); @@ -153,6 +156,9 @@ public static final URI SHA384 = new URIImpl(SPARQL_FUNCTIONS+"sha384"); public static final URI SHA512 = new URIImpl(SPARQL_FUNCTIONS+"sha512"); + public static final URI UUID = new URIImpl(SPARQL_FUNCTIONS+"uuid"); + public static final URI STRUUID = new URIImpl(SPARQL_FUNCTIONS+"struuid"); + public static final URI STR_DT = new URIImpl(SPARQL_FUNCTIONS+"strdt"); public static final URI STR_LANG = new URIImpl(SPARQL_FUNCTIONS+"strlang"); public static final URI LCASE = FN.LOWER_CASE;//new URIImpl(XPATH_FUNCTIONS+"lower-case"); @@ -209,7 +215,7 @@ public static final URI SUBTRACT = new URIImpl(XPATH_FUNCTIONS+"numeric-subtract"); public static final URI MULTIPLY = new URIImpl(XPATH_FUNCTIONS+"numeric-multiply"); public static final URI DIVIDE = new URIImpl(XPATH_FUNCTIONS+"numeric-divide"); - + public static final URI ABS = FN.NUMERIC_ABS;//new URIImpl(XPATH_FUNCTIONS+"numeric-abs"); public static final URI ROUND = FN.NUMERIC_ROUND;//new URIImpl(SPARQL_FUNCTIONS+"numeric-round"); public static final URI CEIL = FN.NUMERIC_CEIL;//new URIImpl(SPARQL_FUNCTIONS+"numeric-ceil"); @@ -709,8 +715,11 @@ // final IValueExpression<? extends IV> var = args[0].getValueExpression(); final IValueExpression ve = AST2BOpUtility.toVE(globals, args[0]); + + final String baseURI = (String) + scalarValues.get(IriBOp.Annotations.BASE_URI); - return new IriBOp(ve, globals); + return new IriBOp(ve, baseURI, globals); } }); @@ -917,6 +926,44 @@ add(TIMEZONE,new DateFactory(DateOp.TIMEZONE)); + add(TZ,new DateFactory(DateOp.TZ)); + + add(NOW,new Factory() { + public IValueExpression<? extends IV> create(final GlobalAnnotations globals, + Map<String, Object> scalarValues, final ValueExpressionNode... args) { + + if (args != null && args.length > 0) + throw new IllegalArgumentException("no args for NOW()"); + + return new NowBOp(globals); + + } + }); + + add(UUID,new Factory() { + public IValueExpression<? extends IV> create(final GlobalAnnotations globals, + Map<String, Object> scalarValues, final ValueExpressionNode... args) { + + if (args != null && args.length > 0) + throw new IllegalArgumentException("no args for UUID()"); + + return new UUIDBOp(globals, false); + + } + }); + + add(STRUUID,new Factory() { + public IValueExpression<? extends IV> create(final GlobalAnnotations globals, + Map<String, Object> scalarValues, final ValueExpressionNode... args) { + + if (args != null && args.length > 0) + throw new IllegalArgumentException("no args for STRUUID()"); + + return new UUIDBOp(globals, true); + + } + }); + add(MD5,new DigestFactory(DigestOp.MD5)); add(SHA1,new DigestFactory(DigestOp.SHA1)); @@ -1314,7 +1361,7 @@ final IValueExpression<? extends IV> left = AST2BOpUtility.toVE(globals, args[0]); - return new DateBOp(left, op); + return new DateBOp(left, op, globals); } Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/GroupMemberValueExpressionNodeBase.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/GroupMemberValueExpressionNodeBase.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/GroupMemberValueExpressionNodeBase.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -74,7 +74,7 @@ } - abstract IValueExpressionNode getValueExpressionNode(); + abstract public IValueExpressionNode getValueExpressionNode(); abstract IValueExpression<? extends IV> getValueExpression(); Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryBase.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryBase.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryBase.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -28,6 +28,7 @@ import com.bigdata.bop.BOp; import com.bigdata.bop.IVariable; +import com.bigdata.rdf.sparql.ast.QueryRoot.Annotations; /** * Contains the projection clause, where clause, and solution modified clauses. @@ -106,6 +107,11 @@ long DEFAULT_TIMEOUT = Long.MAX_VALUE; + /** + * The BINDINGS clause (optional). + */ + String BINDINGS_CLAUSE = "bindingsClause"; + } /** @@ -439,6 +445,26 @@ setProperty(Annotations.TIMEOUT, timeout); } + /** + * Set the BINDINGS. + * + * @param bindings + */ + public void setBindingsClause(final BindingsClause bindings) { + + setProperty(Annotations.BINDINGS_CLAUSE, bindings); + + } + + /** + * Return the BINDINGS. + */ + public BindingsClause getBindingsClause() { + + return (BindingsClause) getProperty(Annotations.BINDINGS_CLAUSE); + + } + public String toString(final int indent) { final String s = indent(indent); @@ -453,6 +479,7 @@ final HavingNode having = getHaving(); final OrderByNode orderBy = getOrderBy(); final SliceNode slice = getSlice(); + final BindingsClause bindings = getBindingsClause(); if (getQueryType() != null) { @@ -522,7 +549,13 @@ sb.append("="); sb.append(getQueryHints().toString()); } + + if (bindings != null) { + sb.append(bindings.toString(indent + 1)); + + } + return sb.toString(); } Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryRoot.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryRoot.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/QueryRoot.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -56,11 +56,6 @@ */ String NAMED_SUBQUERIES = "namedSubqueries"; - /** - * The BINDINGS clause (optional). - */ - String BINDINGS_CLAUSE = "bindingsClause"; - } /** @@ -202,26 +197,6 @@ } - /** - * Set the BINDINGS. - * - * @param bindings - */ - public void setBindingsClause(final BindingsClause bindings) { - - setProperty(Annotations.BINDINGS_CLAUSE, bindings); - - } - - /** - * Return the BINDINGS. - */ - public BindingsClause getBindingsClause() { - - return (BindingsClause) getProperty(Annotations.BINDINGS_CLAUSE); - - } - @Override public String toString(final int indent) { @@ -239,7 +214,7 @@ final DatasetNode dataset = getDataset(); - final BindingsClause bindings = getBindingsClause(); +// final BindingsClause bindings = getBindingsClause(); final NamedSubqueriesNode namedSubqueries = getNamedSubqueries(); @@ -327,12 +302,12 @@ sb.append(super.toString(indent)); - if (bindings != null) { +// if (bindings != null) { +// +// sb.append(bindings.toString(indent + 1)); +// +// } - sb.append(bindings.toString(indent + 1)); - - } - return sb.toString(); } Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/StaticAnalysis.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/StaticAnalysis.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/StaticAnalysis.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -1066,6 +1066,12 @@ // NOP + } else if(node instanceof BindingsClause) { + + final BindingsClause bc = (BindingsClause) node; + + vars.addAll(bc.getDeclaredVariables()); + } else { throw new AssertionError(node.toString()); @@ -1165,6 +1171,10 @@ // NOP + } else if(child instanceof BindingsClause) { + + // NOP + } else { throw new AssertionError(child.toString()); Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdate.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdate.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdate.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -267,7 +267,7 @@ * @see https://sourceforge.net/apps/trac/bigdata/ticket/558 */ op = (Update) new ASTBatchResolveTermsOptimizer().optimize(context, - op/* queryNode */, null/* bindingSets */); + op/* queryNode */, context.getBindings()/* bindingSets */); } @@ -486,6 +486,19 @@ new LinkedHashSet<IVariable<?>>()/* vars */, true/* recursive */); + for (IBindingSet bs : context.getBindings()) { + + @SuppressWarnings("rawtypes") + final Iterator<IVariable> it = bs.vars(); + + while (it.hasNext()) { + + projectedVars.add(it.next()); + + } + + } + final ProjectionNode projection = new ProjectionNode(); for (IVariable<?> var : projectedVars) { @@ -493,7 +506,7 @@ projection.addProjectionVar(new VarNode(var.getName())); } - + queryRoot.setProjection(projection); } @@ -603,7 +616,7 @@ final MutableTupleQueryResult result = new MutableTupleQueryResult( ASTEvalHelper.evaluateTupleQuery( context.conn.getTripleStore(), astContainer, - null/* bindingSets */)); + context.getQueryBindingSet()/* bindingSets */)); boolean nativeDistinct = astContainer.getOptimizedAST().getProperty(ConstructNode.Annotations.NATIVE_DISTINCT, ConstructNode.Annotations.DEFAULT_NATIVE_DISTINCT); @@ -716,7 +729,7 @@ .evaluateTupleQuery2( context.conn.getTripleStore(), astContainer, - null/* bindingSets */, false/* materialize */); + context.getQueryBindingSet()/* bindingSets */, false/* materialize */); try { @@ -861,6 +874,7 @@ } else { + /* * DELETE/INSERT. * @@ -916,7 +930,7 @@ */ final ICloseableIterator<IBindingSet[]> result = ASTEvalHelper .evaluateTupleQuery2(context.conn.getTripleStore(), - astContainer, null/* bindingSets */, false/* materialize */); + astContainer, context.getQueryBindingSet()/* bindingSets */, false/* materialize */); try { @@ -947,7 +961,7 @@ // Set the CONSTRUCT template (quads patterns). queryRoot.setConstruct(template); - + /* * Run as a CONSTRUCT query * @@ -963,8 +977,8 @@ */ final GraphQueryResult result = ASTEvalHelper .evaluateGraphQuery(context.conn.getTripleStore(), - astContainer, null/* bindingSets */); - + astContainer, context.getQueryBindingSet()/* bindingSets */); + try { while (result.hasNext()) { @@ -1149,7 +1163,7 @@ if (!silent) { - assertGraphNotEmpty(context, sourceGraph); +// assertGraphNotEmpty(context, sourceGraph); } @@ -1357,7 +1371,7 @@ /* * Execute the update. */ - executeUpdate(left, null/* bindingSets */, context); + executeUpdate(left, context.getBindings()/* bindingSets */, context); // Return null since pipeline was evaluated. return null; Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdateContext.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdateContext.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUpdateContext.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -29,8 +29,10 @@ import java.util.concurrent.atomic.AtomicLong; +import org.openrdf.query.algebra.evaluation.QueryBindingSet; import org.openrdf.sail.SailException; +import com.bigdata.bop.IBindingSet; import com.bigdata.journal.ITx; import com.bigdata.rdf.internal.IVCache; import com.bigdata.rdf.model.BigdataURI; @@ -55,6 +57,10 @@ public final BigdataSailRepositoryConnection conn; private boolean includeInferred; + + private QueryBindingSet qbs; + + private IBindingSet[] bindingSets; /** * The timestamp associated with the commit point for the update and @@ -145,6 +151,30 @@ } + public IBindingSet[] getBindings() { + + return bindingSets; + + } + + public void setBindings(final IBindingSet[] bindingSets) { + + this.bindingSets = bindingSets; + + } + + public QueryBindingSet getQueryBindingSet() { + + return qbs; + + } + + public void setQueryBindingSet(final QueryBindingSet qbs) { + + this.qbs = qbs; + + } + private BigdataURI nullGraph = null; } Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUtility.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUtility.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUtility.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -92,6 +92,7 @@ import com.bigdata.rdf.internal.constraints.ProjectedConstraint; import com.bigdata.rdf.internal.constraints.SPARQLConstraint; import com.bigdata.rdf.internal.constraints.TryBeforeMaterializationConstraint; +import com.bigdata.rdf.internal.constraints.UUIDBOp; import com.bigdata.rdf.internal.impl.literal.XSDBooleanIV; import com.bigdata.rdf.model.BigdataLiteral; import com.bigdata.rdf.model.BigdataURI; @@ -99,6 +100,7 @@ import com.bigdata.rdf.sparql.ast.ASTUtil; import com.bigdata.rdf.sparql.ast.ArbitraryLengthPathNode; import com.bigdata.rdf.sparql.ast.AssignmentNode; +import com.bigdata.rdf.sparql.ast.BindingsClause; import com.bigdata.rdf.sparql.ast.ComputedMaterializationRequirement; import com.bigdata.rdf.sparql.ast.ConstantNode; import com.bigdata.rdf.sparql.ast.DatasetNode; @@ -2687,6 +2689,11 @@ left = addAssignment(left, (AssignmentNode) child, doneSet, joinGroup.getQueryHints(), ctx, false/* projection */); continue; + } else if (child instanceof BindingsClause) { +// // LET / BIND +// left = addAssignment(left, (AssignmentNode) child, doneSet, +// joinGroup.getQueryHints(), ctx, false/* projection */); + continue; } else { throw new UnsupportedOperationException("child: " + child); } @@ -4575,6 +4582,16 @@ return ve; } + + if (op instanceof UUIDBOp) { + + /* + * We cannot pre-generate these, they need to be unique + * for each call. + */ + return ve; + + } } Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTEvalHelper.java =================================================================== --- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTEvalHelper.java 2014-07-16 15:50:37 UTC (rev 8557) +++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTEvalHelper.java 2014-07-16 16:01:00 UTC (rev 8558) @@ -29,6 +29,7 @@ import info.aduna.iteration.CloseableIteration; +import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; @@ -80,9 +81,14 @@ import com.bigdata.rdf.sparql.... [truncated message content] |