Package org.rumbledb.runtime
Class RuntimeTupleIterator
java.lang.Object
org.rumbledb.runtime.RuntimeTupleIterator
- All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable
,Serializable
,RuntimeTupleIteratorInterface
- Direct Known Subclasses:
CountClauseSparkIterator
,ForClauseSparkIterator
,GroupByClauseSparkIterator
,JoinClauseSparkIterator
,LetClauseSparkIterator
,OrderByClauseSparkIterator
,WhereClauseSparkIterator
public abstract class RuntimeTupleIterator
extends Object
implements RuntimeTupleIteratorInterface, com.esotericsoftware.kryo.KryoSerializable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RuntimeTupleIterator
protected DynamicContext
protected int
protected static final String
protected boolean
protected Map<Name,
DynamicContext.VariableDependency> protected boolean
protected Map<Name,
DynamicContext.VariableDependency> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
RuntimeTupleIterator
(RuntimeTupleIterator child, RuntimeStaticContext staticContext) -
Method Summary
Modifier and TypeMethodDescriptionboolean
canSetEvaluationDepthLimit
(int limit) Tells whether it is possible to set the limit on how deep the evaluation occurs.void
close()
abstract 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 iteratorabstract FlworDataFrame
getDataFrame
(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.int
Returns the limit on how deep the evaluation occurs.int
Returns the height of the clause within the current FLWOR expression, i.e., the number of descendant clauses.protected abstract Map<Name,
DynamicContext.VariableDependency> 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.getSubtreeBeyondLimit
(int limit) Returns the clause subtree at the specified offset.boolean
hasNext()
boolean
boolean
isOpen()
abstract boolean
Says whether this expression evaluation triggers a Spark job.abstract sparksoniq.jsoniq.tuple.FlworTuple
next()
void
open
(DynamicContext context) void
print
(StringBuffer buffer, int indent) void
read
(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input) void
reset
(DynamicContext context) void
setEvaluationDepthLimit
(int limit) Sets the limit on how deep the evaluation occurs.void
setInputAndOutputTupleVariableDependencies
(Map<Name, DynamicContext.VariableDependency> parentProjection) Computes and stores the DataFrame projection that this clause needs to receive from its child clause.toString()
void
write
(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output)
-
Field Details
-
FLOW_EXCEPTION_MESSAGE
- See Also:
-
child
-
evaluationDepthLimit
protected int evaluationDepthLimit -
currentDynamicContext
-
hasNext
protected transient boolean hasNext -
isOpen
protected transient boolean isOpen -
inputTupleProjection
-
outputTupleProjection
-
-
Constructor Details
-
RuntimeTupleIterator
-
-
Method Details
-
getChildIterator
-
open
- Specified by:
open
in interfaceRuntimeTupleIteratorInterface
-
close
public void close()- Specified by:
close
in interfaceRuntimeTupleIteratorInterface
-
reset
- Specified by:
reset
in interfaceRuntimeTupleIteratorInterface
-
write
public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output) - Specified by:
write
in interfacecom.esotericsoftware.kryo.KryoSerializable
-
read
public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input) - Specified by:
read
in interfacecom.esotericsoftware.kryo.KryoSerializable
-
isOpen
public boolean isOpen() -
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfaceRuntimeTupleIteratorInterface
-
next
public abstract sparksoniq.jsoniq.tuple.FlworTuple next()- Specified by:
next
in interfaceRuntimeTupleIteratorInterface
-
getMetadata
-
getHighestExecutionMode
-
getConfiguration
-
isDataFrame
public boolean isDataFrame() -
getDataFrame
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.- 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.
-
getInputTupleVariableDependencies
protected abstract Map<Name,DynamicContext.VariableDependency> getInputTupleVariableDependencies(Map<Name, DynamicContext.VariableDependency> parentProjection) 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()- Parameters:
parentProjection
- the projection needed by the parent clause.- Returns:
- the projection needed by this clause.
-
setInputAndOutputTupleVariableDependencies
public void setInputAndOutputTupleVariableDependencies(Map<Name, DynamicContext.VariableDependency> parentProjection) Computes and stores the DataFrame projection that this clause needs to receive from its child clause. Also stores that of its parent for future purposes. The intent is that the result of this method is used in getDataFrame() so it can optimize some values away. Invariant: all keys MUST be output tuple variables, i.e., appear in this.child.getOutputTupleVariableNames()- Parameters:
parentProjection
- the projection needed by the parent clause.
-
getDynamicContextVariableDependencies
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.- Returns:
- a map of variable names to dependencies (FULL, COUNT, ...) that this clause needs to obtain from the dynamic context.
-
getOutputTupleVariableNames
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.- Returns:
- the set of variable names that are bound by descendant clauses.
-
getEvaluationDepthLimit
public int getEvaluationDepthLimit()Returns the limit on how deep the evaluation occurs. If it is 0, the clause ignores its child (this is for join purposes).- Returns:
- The evaluation depth limit. -1 if none.
-
setEvaluationDepthLimit
public void setEvaluationDepthLimit(int limit) Sets the limit on how deep the evaluation occurs. 0 to stop here.- Parameters:
limit
- the limit to set. Must be between 0 and getHeight(), inclusive.
-
canSetEvaluationDepthLimit
public boolean canSetEvaluationDepthLimit(int limit) Tells whether it is possible to set the limit on how deep the evaluation occurs. 0 to stop here.- Parameters:
limit
- the limit to set. Must be between 0 and getHeight(), inclusive.
-
getSubtreeBeyondLimit
Returns the clause subtree at the specified offset. The parameter is compatible with setEvaluationDepthLimit, i.e., it returns the subtree right below where the evaluation stops with the same limit.- Returns:
- The evaluation depth limit. -1 if none.
-
getHeight
public int getHeight()Returns the height of the clause within the current FLWOR expression, i.e., the number of descendant clauses.- Returns:
- The number of descendant clauses. 0 if it is a starting clause.
-
containsClause
Says whether or not the clause and its descendants include a clause of the specified kind.- Parameters:
kind
- the kind of clause to test for.- Returns:
- true if there is one. False otherwise.
-
toString
-
print
-
isSparkJobNeeded
public abstract boolean isSparkJobNeeded()Says whether this expression evaluation triggers a Spark job.- Returns:
- true if the execution triggers a Spark, false otherwise, null if undetermined yet.
-
generateNativeQuery
This function generate (if possible) a native spark-sql query that maps the inner working of the iterator- 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
-