/** * Do deferred resolution of IVs, which were left unresolved while preparing * the query * * @param store * - triple store, which will be used for values resolution * @param ast * - AST model of the query, which should be resolved * @throws MalformedQueryException */ public static DeferredResolutionResult resolveQuery(final AbstractTripleStore store, final ASTContainer ast) throws MalformedQueryException { return resolveQuery(store, ast, null, null, null /* context unknown */); }
/** * Do deferred resolution of IVs, which were left unresolved while preparing the update * @param store - triple store, which will be used for values resolution * @param ast - AST model of the update, which should be resolved * @throws MalformedQueryException */ public static DeferredResolutionResult resolveUpdate(final AbstractTripleStore store, final ASTContainer ast) throws MalformedQueryException { return resolveUpdate(store, ast, null, null); }
/** * Do deferred resolution of IVs, which were left unresolved after execution of each Update in UpdateRoot * @param store - triple store, which will be used for values resolution * @param ast - AST model of the update, which should be resolved * @param bs - binding set, which should be resolved * @param dataset * @return * @throws MalformedQueryException */ public static DeferredResolutionResult resolveUpdate(final AbstractTripleStore store, final Update update, final BindingSet bs, final Dataset dataset) throws MalformedQueryException { final ASTDeferredIVResolution termsResolver = new ASTDeferredIVResolution(store); // process provided binding set BindingSet resolvedBindingSet = termsResolver.handleBindingSet(store, bs); // process provided dataset final Dataset resolvedDataset = termsResolver.handleDataset(store, dataset); // final long beginNanos = System.nanoTime(); termsResolver.resolve(store, update, null/*datasetClauseLists*/, bs); // ast.setResolveValuesTime(System.nanoTime() - beginNanos); return new DeferredResolutionResult(resolvedBindingSet, resolvedDataset); }
fillInIV(store, ((QueryRoot)queryNode).getDataset()); fillInIV(store, updateRoot); fillInIV(store, update); fillInIV(store, projection); fillInIV(store, constructClause); fillInIV(store, whereClause); fillInIV(store, groupBy); fillInIV(store, having); if (bc!=null) { for (final IBindingSet bs: bc.getBindingSets()) { handleBindingSet(store, bs); prepare(store, namedSubquery);
defer((BigdataURI) astIri.getRDFValue(), new Handler() { deferRunnable(new Runnable(){ public void run() { if (!defaultGraphs.isEmpty() || !namedGraphs.isEmpty()) {
defer(value, new Handler(){ @Override public void handle(final IV newIV) { final int fk = k; if (v instanceof BigdataValue) { defer((BigdataValue)v, new Handler(){ @Override public void handle(final IV newIV) { defer(((TermId)v).getValue(), new Handler(){ @Override public void handle(final IV newIV) { fillInIV(store,pathBop); fillInIV(store,((AbstractOneGraphManagement)bop).getTargetGraph()); fillInIV(store, ((AbstractFromToGraphManagement)bop).getSourceGraph()); fillInIV(store, ((AbstractFromToGraphManagement)bop).getTargetGraph()); fillInIV(store, ((DeleteInsertGraph)bop).getDataset()); fillInIV(store, ((DeleteInsertGraph)bop).getDeleteClause()); fillInIV(store, ((DeleteInsertGraph)bop).getInsertClause()); fillInIV(store, ((DeleteInsertGraph)bop).getWhereClause()); fillInIV(store, ((QuadsDataOrNamedSolutionSet)bop).getQuadData()); } else if (bop instanceof DatasetNode) { final DatasetNode dataset = ((DatasetNode) bop);
private void handleBindingSet(final AbstractTripleStore store, final IBindingSet s) { final Iterator<Entry<IVariable, IConstant>> itr = s.iterator(); while (itr.hasNext()) { final Entry<IVariable, IConstant> entry = itr.next(); final Object value = entry.getValue().get(); if (value instanceof BigdataValue) { defer((BigdataValue)value, new Handler(){ @Override public void handle(final IV newIV) { entry.setValue(new Constant(newIV)); } }); } else if (value instanceof AbstractIV) { // See BLZG-1788 (Typed literals in VALUES clause not matching data) // Changed from TermId to AbstractIV, as there are other types of IVs, // which could require resolution against the store // (for ex. FullyInlineTypedLiteralIV which represents typed literal) defer(((AbstractIV)value).getValue(), new Handler(){ @Override public void handle(final IV newIV) { entry.setValue(new Constant(newIV)); } }); } } }
defer(value, new Handler(){ @Override public void handle(final IV newIV) { final int fk = k; if (v instanceof BigdataValue) { defer((BigdataValue)v, new Handler(){ @Override public void handle(final IV newIV) { defer(((TermId)v).getValue(), new Handler(){ @Override public void handle(final IV newIV) { fillInIV(store,pathBop); fillInIV(store,((AbstractOneGraphManagement)bop).getTargetGraph()); fillInIV(store, ((AbstractFromToGraphManagement)bop).getSourceGraph()); fillInIV(store, ((AbstractFromToGraphManagement)bop).getTargetGraph()); fillInIV(store, ((DeleteInsertGraph)bop).getDataset()); fillInIV(store, ((DeleteInsertGraph)bop).getDeleteClause()); fillInIV(store, ((DeleteInsertGraph)bop).getInsertClause()); fillInIV(store, ((DeleteInsertGraph)bop).getWhereClause()); fillInIV(store, ((QuadsDataOrNamedSolutionSet)bop).getQuadData()); } else if (bop instanceof DatasetNode) { final DatasetNode dataset = ((DatasetNode) bop);
fillInIV(store, ((QueryRoot)queryNode).getDataset()); fillInIV(store, updateRoot); fillInIV(store, update); fillInIV(store, projection); fillInIV(store, constructClause); fillInIV(store, whereClause); fillInIV(store, groupBy); fillInIV(store, having); if (bc!=null) { for (final IBindingSet bs: bc.getBindingSets()) { handleBindingSet(store, bs); prepare(store, namedSubquery);
defer((BigdataURI) astIri.getRDFValue(), new Handler() { deferRunnable(new Runnable(){ public void run() { if (!defaultGraphs.isEmpty() || !namedGraphs.isEmpty()) {
private void handleBindingSet(final AbstractTripleStore store, final IBindingSet s) { final Iterator<Entry<IVariable, IConstant>> itr = s.iterator(); while (itr.hasNext()) { final Entry<IVariable, IConstant> entry = itr.next(); final Object value = entry.getValue().get(); if (value instanceof BigdataValue) { defer((BigdataValue)value, new Handler(){ @Override public void handle(final IV newIV) { entry.setValue(new Constant(newIV)); } }); } else if (value instanceof AbstractIV) { // See BLZG-1788 (Typed literals in VALUES clause not matching data) // Changed from TermId to AbstractIV, as there are other types of IVs, // which could require resolution against the store // (for ex. FullyInlineTypedLiteralIV which represents typed literal) defer(((AbstractIV)value).getValue(), new Handler(){ @Override public void handle(final IV newIV) { entry.setValue(new Constant(newIV)); } }); } } }
/** * Do deferred resolution of IVs, which were left unresolved while preparing * the query * * @param store * - triple store, which will be used for values resolution * @param ast * - AST model of the query, which should be resolved * @throws MalformedQueryException */ public static DeferredResolutionResult resolveQuery(final AbstractTripleStore store, final ASTContainer ast) throws MalformedQueryException { return resolveQuery(store, ast, null, null, null /* context unknown */); }
/** * Do deferred resolution of IVs, which were left unresolved after execution of each Update in UpdateRoot * @param store - triple store, which will be used for values resolution * @param ast - AST model of the update, which should be resolved * @param bs - binding set, which should be resolved * @param dataset * @return * @throws MalformedQueryException */ public static DeferredResolutionResult resolveUpdate(final AbstractTripleStore store, final Update update, final BindingSet bs, final Dataset dataset) throws MalformedQueryException { final ASTDeferredIVResolution termsResolver = new ASTDeferredIVResolution(store); // process provided binding set BindingSet resolvedBindingSet = termsResolver.handleBindingSet(store, bs); // process provided dataset final Dataset resolvedDataset = termsResolver.handleDataset(store, dataset); // final long beginNanos = System.nanoTime(); termsResolver.resolve(store, update, null/*datasetClauseLists*/, bs); // ast.setResolveValuesTime(System.nanoTime() - beginNanos); return new DeferredResolutionResult(resolvedBindingSet, resolvedDataset); }
/** * Do deferred resolution of IVs, which were left unresolved while preparing the update * @param store - triple store, which will be used for values resolution * @param ast - AST model of the update, which should be resolved * @throws MalformedQueryException */ public static DeferredResolutionResult resolveUpdate(final AbstractTripleStore store, final ASTContainer ast) throws MalformedQueryException { return resolveUpdate(store, ast, null, null); }
private URI handleDatasetGraph(final AbstractTripleStore store, final URI uri) { URI value = uri; if (value!= null && !(value instanceof BigdataValue)) { value = store.getValueFactory().asValue(value); } if (value instanceof BigdataValue) { final BigdataValue bValue = (BigdataValue) value; defer((BigdataValue)value, new Handler(){ @Override public void handle(final IV newIV) { bValue.setIV(newIV); } }); } return value; }
/** * Applies the {@link Bigdata2ASTSPARQLParser}. */ public QueryRoot parse(final String queryStr, final String baseURI) throws MalformedQueryException { final Bigdata2ASTSPARQLParser parser = new Bigdata2ASTSPARQLParser(); final ASTContainer astContainer = parser.parseQuery2(queryStr, baseURI); ASTDeferredIVResolution.resolveQuery(tripleStore, astContainer); final QueryRoot ast = astContainer.getOriginalAST(); final Collection<ValueExpressionNode> nodes = new LinkedList<ValueExpressionNode>(); final Iterator<ValueExpressionNode> itr = BOpUtility.visitAll( ast, ValueExpressionNode.class); while (itr.hasNext()) { final ValueExpressionNode node = itr.next(); nodes.add(node); } for (ValueExpressionNode node : nodes) { node.invalidate(); } return ast; }
final ASTDeferredIVResolution termsResolver = new ASTDeferredIVResolution(store); BindingSet resolvedBindingSet = termsResolver.handleBindingSet(store, bs); final Dataset resolvedDataset = termsResolver.handleDataset(store, dataset); termsResolver.resolveIVs(store); termsResolver.resolve(store, qc, dcLists, bs);
/** * Applies the {@link Bigdata2ASTSPARQLParser}. */ protected UpdateRoot parseUpdate(final String updateStr, final String baseURI) throws MalformedQueryException { Bigdata2ASTSPARQLParser parser = new Bigdata2ASTSPARQLParser(); ASTContainer ast = parser.parseUpdate2(updateStr, baseURI); ASTDeferredIVResolution.resolveUpdate(tripleStore, ast); return ast.getOriginalUpdateAST(); }
private URI handleDatasetGraph(final AbstractTripleStore store, final URI uri) { URI value = uri; if (value!= null && !(value instanceof BigdataValue)) { value = store.getValueFactory().asValue(value); } if (value instanceof BigdataValue) { final BigdataValue bValue = (BigdataValue) value; defer((BigdataValue)value, new Handler(){ @Override public void handle(final IV newIV) { bValue.setIV(newIV); } }); } return value; }
/** * Applies the {@link Bigdata2ASTSPARQLParser}. */ public QueryRoot parse(final String queryStr, final String baseURI) throws MalformedQueryException { final Bigdata2ASTSPARQLParser parser = new Bigdata2ASTSPARQLParser(); final ASTContainer astContainer = parser.parseQuery2(queryStr, baseURI); ASTDeferredIVResolution.resolveQuery(tripleStore, astContainer); final QueryRoot ast = astContainer.getOriginalAST(); final Collection<ValueExpressionNode> nodes = new LinkedList<ValueExpressionNode>(); final Iterator<ValueExpressionNode> itr = BOpUtility.visitAll( ast, ValueExpressionNode.class); while (itr.hasNext()) { final ValueExpressionNode node = itr.next(); nodes.add(node); } for (ValueExpressionNode node : nodes) { node.invalidate(); } return ast; }