/** * CONSTRUCT (handled as a TriplesBlock). */ @Override final public ConstructNode visit(final ASTConstruct node, final Object data) throws VisitorException { final GroupGraphPattern parentGP = graphPattern; graphPattern = new GroupGraphPattern();//parentGP); Note: No parent. // visit the children of the node (default behavior). super.visit(node, null); final ConstructNode group = graphPattern.buildGroup(new ConstructNode()); graphPattern = parentGP; return group; }
/** * Flatten the {@link QuadData} into a simple {@link ConstructNode}. The * {@link ConstructNode} MAY use variables as well as constants and supports * the context position, so this is really a quads construct template. * * @param template * The {@link ConstructNode} for the template. * * @return The argument. * * TODO Maybe we could just flatten this in UpdateExprBuilder? */ public ConstructNode flatten(final ConstructNode template) { final QuadData quadData = this; final Iterator<StatementPatternNode> itr = BOpUtility.visitAll( quadData, StatementPatternNode.class); while (itr.hasNext()) { final StatementPatternNode sp = (StatementPatternNode) (itr.next() .clone()); template.addChild(sp); } return template; }
@Override public String toString(final int indent) { final StringBuilder sb = new StringBuilder(); final String s = indent(indent); sb.append("\n").append(s).append("CONSTRUCT {"); for (StatementPatternNode v : this) { sb.append(v.toString(indent+1)); } sb.append("\n").append(s).append("}"); if (isNativeDistinct()) sb.append(" [nativeDistinct]"); return sb.toString(); }
final boolean distinctQuads = construct.isDistinctQuads() && tripleStore.isQuads() && hasMixedQuadData(templates); final boolean nativeDistinct = construct.isNativeDistinct(); if (nativeDistinct && construct.isDistinctQuads()) { flagToCheckNativeDistinctQuadsInvocationForJUnitTesting = true;
final ConstructNode construct = new ConstructNode(); expected.setConstruct(construct); construct.addChild(new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS));
.getQuadData().flatten(new ConstructNode(context)); template.setDistinctQuads(true); template.setNativeDistinct(true); .getQuadData().flatten(new ConstructNode(context)); template.setDistinctQuads(true); template.setNativeDistinct(true);
/** * A simple CONSTRUCT query. * * <pre> * PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> * PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> * PREFIX foaf: <http://xmlns.com/foaf/0.1/> * * CONSTRUCT { * <http://www.bigdata.com/DC> rdfs:label "DC" . * ?x rdf:type foaf:Person . * } where { * ?x rdf:type foaf:Person * } * </pre> */ public void test_construct_1() throws Exception { final ASTContainer ast = new TestHelper( "construct-1", // testURI, "construct-1.rq",// queryFileURL "construct-1.trig",// dataFileURL "construct-1-result.trig"// resultFileURL ).runTest(); final ConstructNode construct = ast.getOptimizedAST().getConstruct(); assertNotNull(construct); assertFalse(construct.isNativeDistinct()); }
public boolean isDistinctQuads() { return getProperty(Annotations.DISTINCT_QUADS, Annotations.DEFAULT_DISTINCT_QUADS); } public void setDistinctQuads(final boolean quads) {
final ConstructNode construct = new ConstructNode(); expected.setConstruct(construct); construct.addChild(new StatementPatternNode(new VarNode("s"), new ConstantNode(makeIV(valueFactory.createURI(RDF.TYPE .toString()))), new VarNode("o"), null/* c */,
.getQuadData().flatten(new ConstructNode(context)); template.setDistinctQuads(true); template.setNativeDistinct(true); .getQuadData().flatten(new ConstructNode(context)); template.setDistinctQuads(true); template.setNativeDistinct(true);
/** * A simple CONSTRUCT query. * * <pre> * PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> * PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> * PREFIX foaf: <http://xmlns.com/foaf/0.1/> * * CONSTRUCT { * <http://www.bigdata.com/DC> rdfs:label "DC" . * ?x rdf:type foaf:Person . * } where { * ?x rdf:type foaf:Person * } * </pre> */ public void test_construct_1() throws Exception { final ASTContainer ast = new TestHelper( "construct-1", // testURI, "construct-1.rq",// queryFileURL "construct-1.trig",// dataFileURL "construct-1-result.trig"// resultFileURL ).runTest(); final ConstructNode construct = ast.getOptimizedAST().getConstruct(); assertNotNull(construct); assertFalse(construct.isNativeDistinct()); }
final boolean distinctQuads = construct.isDistinctQuads() && tripleStore.isQuads() && hasMixedQuadData(templates); final boolean nativeDistinct = construct.isNativeDistinct(); if (nativeDistinct && construct.isDistinctQuads()) { flagToCheckNativeDistinctQuadsInvocationForJUnitTesting = true;
public boolean isDistinctQuads() { return getProperty(Annotations.DISTINCT_QUADS, Annotations.DEFAULT_DISTINCT_QUADS); } public void setDistinctQuads(final boolean quads) {
final ConstructNode construct = new ConstructNode(); expected.setConstruct(construct); construct.addChild(new StatementPatternNode(new VarNode("s"), new ConstantNode(makeIV(valueFactory.createURI(RDF.TYPE .toString()))), new VarNode("o"), null/* c */,
/** * A simple CONSTRUCT query using a native DISTINCT filter. * * <pre> * PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> * PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> * PREFIX foaf: <http://xmlns.com/foaf/0.1/> * * CONSTRUCT { * <http://www.bigdata.com/DC> rdfs:label "DC" . * ?x rdf:type foaf:Person . * } where { * # Enable the native DISTINCT SPO filter. * hint:Query hint:nativeDistinctSPO true . * ?x rdf:type foaf:Person * } * </pre> */ public void test_construct_1a() throws Exception { final ASTContainer ast = new TestHelper( "construct-1", // testURI, "construct-1a.rq",// queryFileURL "construct-1.trig",// dataFileURL "construct-1-result.trig"// resultFileURL ).runTest(); final ConstructNode construct = ast.getOptimizedAST().getConstruct(); assertNotNull(construct); assertTrue(construct.isNativeDistinct()); }
/** * CONSTRUCT (handled as a TriplesBlock). */ @Override final public ConstructNode visit(final ASTConstruct node, final Object data) throws VisitorException { final GroupGraphPattern parentGP = graphPattern; graphPattern = new GroupGraphPattern();//parentGP); Note: No parent. // visit the children of the node (default behavior). super.visit(node, null); final ConstructNode group = graphPattern.buildGroup(new ConstructNode()); graphPattern = parentGP; return group; }
/** * Flatten the {@link QuadData} into a simple {@link ConstructNode}. The * {@link ConstructNode} MAY use variables as well as constants and supports * the context position, so this is really a quads construct template. * * @param template * The {@link ConstructNode} for the template. * * @return The argument. * * TODO Maybe we could just flatten this in UpdateExprBuilder? */ public ConstructNode flatten(final ConstructNode template) { final QuadData quadData = this; final Iterator<StatementPatternNode> itr = BOpUtility.visitAll( quadData, StatementPatternNode.class); while (itr.hasNext()) { final StatementPatternNode sp = (StatementPatternNode) (itr.next() .clone()); template.addChild(sp); } return template; }
@Override public String toString(final int indent) { final StringBuilder sb = new StringBuilder(); final String s = indent(indent); sb.append("\n").append(s).append("CONSTRUCT {"); for (StatementPatternNode v : this) { sb.append(v.toString(indent+1)); } sb.append("\n").append(s).append("}"); if (isNativeDistinct()) sb.append(" [nativeDistinct]"); return sb.toString(); }