Class CountClauseSparkIterator
java.lang.Object
org.rumbledb.runtime.RuntimeTupleIterator
org.rumbledb.runtime.flwor.clauses.CountClauseSparkIterator
- All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable
,Serializable
,RuntimeTupleIteratorInterface
- See Also:
-
Field Summary
Fields inherited from class org.rumbledb.runtime.RuntimeTupleIterator
child, currentDynamicContext, evaluationDepthLimit, FLOW_EXCEPTION_MESSAGE, hasNext, inputTupleProjection, isOpen, outputTupleProjection
-
Constructor Summary
ConstructorsConstructorDescriptionCountClauseSparkIterator
(RuntimeTupleIterator child, Name variableName, RuntimeStaticContext staticContext) -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.spark.sql.Dataset<org.apache.spark.sql.Row>
addSerializedCountColumn
(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> df, Map<Name, DynamicContext.VariableDependency> outputDependencies, Name variableName) void
close()
boolean
containsClause
(FLWOR_CLAUSES kind) Says whether or not the clause and its descendants include a clause of the specified kind.generateNativeQuery
(NativeClauseContext nativeClauseContext) This function generate (if possible) a native spark-sql query that maps the inner working of the iteratorgetDataFrame
(DynamicContext context) Obtains the dataframe from the child clause.Variable dependencies are variables that MUST be provided by the parent clause in the dynamic context for successful execution of this clause.getInputTupleVariableDependencies
(Map<Name, DynamicContext.VariableDependency> parentProjection) Builds the DataFrame projection that this clause needs to receive from its child clause.Returns the output tuple variable names.boolean
Says whether this expression evaluation triggers a Spark job.sparksoniq.jsoniq.tuple.FlworTuple
next()
void
open
(DynamicContext context) void
print
(StringBuffer buffer, int indent) void
reset
(DynamicContext context) Methods inherited from class org.rumbledb.runtime.RuntimeTupleIterator
canSetEvaluationDepthLimit, getChildIterator, getConfiguration, getEvaluationDepthLimit, getHeight, getHighestExecutionMode, getMetadata, getSubtreeBeyondLimit, hasNext, isDataFrame, isOpen, read, setEvaluationDepthLimit, setInputAndOutputTupleVariableDependencies, toString, write
-
Constructor Details
-
CountClauseSparkIterator
public CountClauseSparkIterator(RuntimeTupleIterator child, Name variableName, RuntimeStaticContext staticContext)
-
-
Method Details
-
getVariableName
-
open
- Specified by:
open
in interfaceRuntimeTupleIteratorInterface
- Overrides:
open
in classRuntimeTupleIterator
-
reset
- Specified by:
reset
in interfaceRuntimeTupleIteratorInterface
- Overrides:
reset
in classRuntimeTupleIterator
-
close
public void close()- Specified by:
close
in interfaceRuntimeTupleIteratorInterface
- Overrides:
close
in classRuntimeTupleIterator
-
next
public sparksoniq.jsoniq.tuple.FlworTuple next()- Specified by:
next
in interfaceRuntimeTupleIteratorInterface
- Specified by:
next
in classRuntimeTupleIterator
-
getDataFrame
Description copied from class:RuntimeTupleIterator
Obtains the dataframe from the child clause. It is possible, with the second parameter, to specify the variables it needs to project the others away, or that only a count is needed for a specific variable, which allows projecting away the actual items.- Specified by:
getDataFrame
in classRuntimeTupleIterator
- Parameters:
context
- the dynamic context in which the evaluate the child clause's dataframe.- Returns:
- the DataFrame with the tuples returned by the child clause.
-
addSerializedCountColumn
public static org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> addSerializedCountColumn(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> df, Map<Name, DynamicContext.VariableDependency> outputDependencies, Name variableName) -
getDynamicContextVariableDependencies
Description copied from class:RuntimeTupleIterator
Variable dependencies are variables that MUST be provided by the parent clause in the dynamic context for successful execution of this clause. These variables are: 1. All variables that the expression of the clause depends on (recursive call of getVariableDependencies on the expression) 2. Except those variables bound in the current FLWOR (obtained from the auxiliary method getVariablesBoundInCurrentFLWORExpression), because those are provided in the Tuples 3. Plus (recursively calling getVariableDependencies) all the Variable Dependencies of the child clause if it exists.- Overrides:
getDynamicContextVariableDependencies
in classRuntimeTupleIterator
- Returns:
- a map of variable names to dependencies (FULL, COUNT, ...) that this clause needs to obtain from the dynamic context.
-
getOutputTupleVariableNames
Description copied from class:RuntimeTupleIterator
Returns the output tuple variable names. These variables can be removed from the dependencies of expressions in ascendent (subsequent) clauses, because their values are provided in the tuples rather than the dynamic context object.- Overrides:
getOutputTupleVariableNames
in classRuntimeTupleIterator
- Returns:
- the set of variable names that are bound by descendant clauses.
-
print
- Overrides:
print
in classRuntimeTupleIterator
-
getInputTupleVariableDependencies
public Map<Name,DynamicContext.VariableDependency> getInputTupleVariableDependencies(Map<Name, DynamicContext.VariableDependency> parentProjection) Description copied from class:RuntimeTupleIterator
Builds the DataFrame projection that this clause needs to receive from its child clause. The intent is that the result of this method is forwarded to the child clause in getDataFrame() so it can optimize some values away. Invariant: all keys in getInputTupleVariableDependencies(...) MUST be output tuple variables, i.e., appear in this.child.getOutputTupleVariableNames()- Specified by:
getInputTupleVariableDependencies
in classRuntimeTupleIterator
- Parameters:
parentProjection
- the projection needed by the parent clause.- Returns:
- the projection needed by this clause.
-
containsClause
Description copied from class:RuntimeTupleIterator
Says whether or not the clause and its descendants include a clause of the specified kind.- Specified by:
containsClause
in classRuntimeTupleIterator
- Parameters:
kind
- the kind of clause to test for.- Returns:
- true if there is one. False otherwise.
-
isSparkJobNeeded
public boolean isSparkJobNeeded()Says whether this expression evaluation triggers a Spark job.- Specified by:
isSparkJobNeeded
in classRuntimeTupleIterator
- Returns:
- true if the execution triggers a Spark, false otherwise, null if undetermined yet.
-
generateNativeQuery
Description copied from class:RuntimeTupleIterator
This function generate (if possible) a native spark-sql query that maps the inner working of the iterator- Overrides:
generateNativeQuery
in classRuntimeTupleIterator
- Parameters:
nativeClauseContext
- context information to generate the native query- Returns:
- a native clause context with the spark-sql native query to get an equivalent result of the iterator, or [NativeClauseContext.NoNativeQuery] if it is not possible
-