All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bigdata.rdf.sparql.ast.ConstructNode Maven / Gradle / Ivy

/**

Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016.  All rights reserved.

Contact:
     SYSTAP, LLC DBA Blazegraph
     2501 Calvert ST NW #106
     Washington, DC 20008
     [email protected]

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
*/
/*
 * Created on Aug 24, 2011
 */

package com.bigdata.rdf.sparql.ast;

import java.util.Map;

import com.bigdata.bop.BOp;
import com.bigdata.rdf.sparql.ast.eval.AST2BOpContext;
import com.bigdata.rdf.spo.ISPO;

/**
 * A template for the construction of one or more graphs based on the solutions
 * projected by a query.
 * 
 * @author Bryan Thompson
 * @version $Id$
 */
public class ConstructNode extends AbstractStatementContainer
//GroupNodeBase
        implements IStatementContainer {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public interface Annotations extends AbstractStatementContainer.Annotations {

        /**
         * Boolean property (default {@value #DEFAULT_NATIVE_DISTINCT}) which is
         * true iff a native DISTINCT {@link ISPO} filter should be
         * applied (large cardinality is expected for the constructed graph).
         * When false, a JVM based DISTINCT {@link ISPO} filter
         * will be applied.
         * 

* Note: This can be set using either {@link QueryHints#ANALYTIC} or * {@link QueryHints#NATIVE_DISTINCT_SPO}. * * @see * CONSTRUCT should apply DISTINCT (s,p,o) filter */ String NATIVE_DISTINCT = "nativeDistinct"; /** * Internal boolean property (default {@value #DEFAULT_DISTINCT_QUDS}) which is * true when used internally for constructing sets of quads rather * than sets of triples. *

* Note: This can only be set programmatically using {@link ConstructNode#setDistinctQuads(boolean)} *

* Note: When this property is set and mixed quads are detected or suspected then the {@link #NATIVE_DISTINCT} property is ignored. * * @see * CONSTRUCT should apply DISTINCT (s,p,o) filter */ String DISTINCT_QUADS = "quadsDistinct"; boolean DEFAULT_NATIVE_DISTINCT = false; boolean DEFAULT_DISTINCT_QUADS = false; } public ConstructNode() { super(); } public ConstructNode(final AST2BOpContext ctx) { super(); if (ctx.nativeDistinctSPO) { // Native DISTINCT SPO FILTER is requested. setNativeDistinct(true); } } /** * Constructor required for {@link com.bigdata.bop.BOpUtility#deepCopy(FilterNode)}. */ public ConstructNode(final ConstructNode op) { super(op); } /** * Required shallow copy constructor. */ public ConstructNode(final BOp[] args, final Map anns) { super(args, anns); } @Override public IGroupNode addChild( final StatementPatternNode child) { if (!(child instanceof StatementPatternNode)) throw new UnsupportedOperationException(); super.addChild(child); return this; } /** * When true, a native DISTINCT {@link ISPO} filter will be * applied to the constructed graph, otherwise a Java Heap based DISTINCT * {@link ISPO} filter will be applied. * * @see Annotations#NATIVE_DISTINCT * * @see * CONSTRUCT should apply DISTINCT (s,p,o) filter */ public boolean isNativeDistinct() { return getProperty(Annotations.NATIVE_DISTINCT, Annotations.DEFAULT_NATIVE_DISTINCT); } public void setNativeDistinct(final boolean nativeDistinct) { setProperty(Annotations.NATIVE_DISTINCT, nativeDistinct); } public boolean isDistinctQuads() { return getProperty(Annotations.DISTINCT_QUADS, Annotations.DEFAULT_DISTINCT_QUADS); } public void setDistinctQuads(final boolean quads) { setProperty(Annotations.DISTINCT_QUADS, quads); } @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(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy