@@ -2827,18 +2827,23 @@ ExecutionNode* AsyncNode::clone(ExecutionPlan* plan, bool withDependencies,
2827
2827
}
2828
2828
2829
2829
namespace {
2830
- constexpr std::string_view MATERIALIZE_NODE_IN_NM_DOC_PARAM = " inNmDocId" ;
2831
- constexpr std::string_view MATERIALIZE_NODE_OUT_VARIABLE_PARAM = " outVariable" ;
2832
- constexpr std::string_view MATERIALIZE_NODE_MULTI_NODE_PARAM = " multiNode" ;
2830
+ constexpr std::string_view kMaterializeNodeInNmDocParam = " inNmDocId" ;
2831
+ constexpr std::string_view kMaterializeNodeOutVariableParam = " outVariable" ;
2832
+ constexpr std::string_view kMaterializeNodeMultiNodeParam = " multiNode" ;
2833
+ constexpr std::string_view kMaterializeNodeInLocalDocIdParam = " inLocalDocId" ;
2833
2834
} // namespace
2834
2835
2835
2836
MaterializeNode* materialize::createMaterializeNode (
2836
2837
ExecutionPlan* plan, arangodb::velocypack::Slice const base) {
2837
- auto isMulti = base.get (MATERIALIZE_NODE_MULTI_NODE_PARAM );
2838
+ auto isMulti = base.get (kMaterializeNodeMultiNodeParam );
2838
2839
if (isMulti.isBoolean () && isMulti.getBoolean ()) {
2839
2840
return new MaterializeMultiNode (plan, base);
2840
2841
}
2841
- return new MaterializeSingleNode (plan, base);
2842
+ auto inLocalDocId = base.get (kMaterializeNodeInLocalDocIdParam );
2843
+ if (inLocalDocId.isBoolean () && inLocalDocId.getBoolean ()) {
2844
+ return new MaterializeSingleNode<true >(plan, base);
2845
+ }
2846
+ return new MaterializeSingleNode<false >(plan, base);
2842
2847
}
2843
2848
2844
2849
MaterializeNode::MaterializeNode (ExecutionPlan* plan, ExecutionNodeId id,
@@ -2852,27 +2857,19 @@ MaterializeNode::MaterializeNode(ExecutionPlan* plan,
2852
2857
arangodb::velocypack::Slice const & base)
2853
2858
: ExecutionNode(plan, base),
2854
2859
_inNonMaterializedDocId(aql::Variable::varFromVPack(
2855
- plan->getAst (), base, MATERIALIZE_NODE_IN_NM_DOC_PARAM , true)),
2860
+ plan->getAst (), base, kMaterializeNodeInNmDocParam , true)),
2856
2861
_outVariable(aql::Variable::varFromVPack(
2857
- plan->getAst (), base, MATERIALIZE_NODE_OUT_VARIABLE_PARAM )) {}
2862
+ plan->getAst (), base, kMaterializeNodeOutVariableParam )) {}
2858
2863
2859
2864
void MaterializeNode::doToVelocyPack (velocypack::Builder& nodes,
2860
2865
unsigned /* flags*/ ) const {
2861
- nodes.add (VPackValue (MATERIALIZE_NODE_IN_NM_DOC_PARAM ));
2866
+ nodes.add (VPackValue (kMaterializeNodeInNmDocParam ));
2862
2867
_inNonMaterializedDocId->toVelocyPack (nodes);
2863
2868
2864
- nodes.add (VPackValue (MATERIALIZE_NODE_OUT_VARIABLE_PARAM ));
2869
+ nodes.add (VPackValue (kMaterializeNodeOutVariableParam ));
2865
2870
_outVariable->toVelocyPack (nodes);
2866
2871
}
2867
2872
2868
- auto MaterializeNode::getReadableInputRegisters (
2869
- RegisterId const inNmDocId) const -> RegIdSet {
2870
- // TODO (Dronplane) for index exectutor here we possibly will
2871
- // return additional SearchDoc register. So will keep this function for time
2872
- // being.
2873
- return RegIdSet{inNmDocId};
2874
- }
2875
-
2876
2873
CostEstimate MaterializeNode::estimateCost () const {
2877
2874
if (_dependencies.empty ()) {
2878
2875
// we should always have dependency as we need input for materializing
@@ -2907,7 +2904,7 @@ void MaterializeMultiNode::doToVelocyPack(velocypack::Builder& nodes,
2907
2904
unsigned flags) const {
2908
2905
// call base class method
2909
2906
MaterializeNode::doToVelocyPack (nodes, flags);
2910
- nodes.add (MATERIALIZE_NODE_MULTI_NODE_PARAM , velocypack::Value (true ));
2907
+ nodes.add (kMaterializeNodeMultiNodeParam , velocypack::Value (true ));
2911
2908
}
2912
2909
2913
2910
std::unique_ptr<ExecutionBlock> MaterializeMultiNode::createBlock (
@@ -2929,7 +2926,7 @@ std::unique_ptr<ExecutionBlock> MaterializeMultiNode::createBlock(
2929
2926
outDocumentRegId = it->second .registerId ;
2930
2927
}
2931
2928
2932
- auto readableInputRegisters = getReadableInputRegisters ( inNmDocIdRegId) ;
2929
+ RegIdSet readableInputRegisters{ inNmDocIdRegId} ;
2933
2930
auto writableOutputRegisters = RegIdSet{outDocumentRegId};
2934
2931
2935
2932
auto registerInfos = createRegisterInfos (std::move (readableInputRegisters),
@@ -2938,7 +2935,7 @@ std::unique_ptr<ExecutionBlock> MaterializeMultiNode::createBlock(
2938
2935
auto executorInfos = MaterializerExecutorInfos<void >(
2939
2936
inNmDocIdRegId, outDocumentRegId, engine.getQuery ());
2940
2937
2941
- return std::make_unique<ExecutionBlockImpl<MaterializeExecutor<void >>>(
2938
+ return std::make_unique<ExecutionBlockImpl<MaterializeExecutor<void , false >>>(
2942
2939
&engine, this , std::move (registerInfos), std::move (executorInfos));
2943
2940
}
2944
2941
@@ -2961,47 +2958,53 @@ ExecutionNode* MaterializeMultiNode::clone(ExecutionPlan* plan,
2961
2958
return cloneHelper (std::move (c), withDependencies, withProperties);
2962
2959
}
2963
2960
2964
- MaterializeSingleNode::MaterializeSingleNode (ExecutionPlan* plan,
2965
- ExecutionNodeId id,
2966
- aql::Collection const * collection,
2967
- aql::Variable const & inDocId,
2968
- aql::Variable const & outVariable)
2961
+ template <bool localDocumentId>
2962
+ MaterializeSingleNode<localDocumentId>::MaterializeSingleNode(
2963
+ ExecutionPlan* plan, ExecutionNodeId id, aql::Collection const * collection,
2964
+ aql::Variable const & inDocId, aql::Variable const & outVariable)
2969
2965
: MaterializeNode(plan, id, inDocId, outVariable),
2970
2966
CollectionAccessingNode(collection) {}
2971
2967
2972
- MaterializeSingleNode::MaterializeSingleNode (
2968
+ template <bool localDocumentId>
2969
+ MaterializeSingleNode<localDocumentId>::MaterializeSingleNode(
2973
2970
ExecutionPlan* plan, arangodb::velocypack::Slice const & base)
2974
2971
: MaterializeNode(plan, base), CollectionAccessingNode(plan, base) {}
2975
2972
2976
- void MaterializeSingleNode::doToVelocyPack (velocypack::Builder& nodes,
2977
- unsigned flags) const {
2973
+ template <bool localDocumentId>
2974
+ void MaterializeSingleNode<localDocumentId>::doToVelocyPack(
2975
+ velocypack::Builder& nodes, unsigned flags) const {
2978
2976
// call base class method
2979
2977
MaterializeNode::doToVelocyPack (nodes, flags);
2980
2978
2981
2979
// add collection information
2982
2980
CollectionAccessingNode::toVelocyPack (nodes, flags);
2981
+ nodes.add (kMaterializeNodeInLocalDocIdParam , localDocumentId);
2983
2982
}
2984
2983
2985
- std::unique_ptr<ExecutionBlock> MaterializeSingleNode::createBlock (
2984
+ template <bool localDocumentId>
2985
+ std::unique_ptr<ExecutionBlock>
2986
+ MaterializeSingleNode<localDocumentId>::createBlock(
2986
2987
ExecutionEngine& engine,
2987
2988
std::unordered_map<ExecutionNode*, ExecutionBlock*> const &) const {
2988
2989
ExecutionNode const * previousNode = getFirstDependency ();
2989
2990
TRI_ASSERT (previousNode != nullptr );
2990
- RegisterId inNmDocIdRegId;
2991
- {
2992
- auto it = getRegisterPlan ()->varInfo .find (_inNonMaterializedDocId->id );
2993
- TRI_ASSERT (it != getRegisterPlan ()->varInfo .end ());
2994
- inNmDocIdRegId = it->second .registerId ;
2995
- }
2996
2991
RegisterId outDocumentRegId;
2997
2992
{
2998
2993
auto it = getRegisterPlan ()->varInfo .find (_outVariable->id );
2999
2994
TRI_ASSERT (it != getRegisterPlan ()->varInfo .end ());
3000
2995
outDocumentRegId = it->second .registerId ;
3001
2996
}
3002
2997
auto const & name = collection ()->name ();
3003
-
3004
- auto readableInputRegisters = getReadableInputRegisters (inNmDocIdRegId);
2998
+ RegisterId inNmDocIdRegId;
2999
+ {
3000
+ auto it = getRegisterPlan ()->varInfo .find (_inNonMaterializedDocId->id );
3001
+ TRI_ASSERT (it != getRegisterPlan ()->varInfo .end ());
3002
+ inNmDocIdRegId = it->second .registerId ;
3003
+ }
3004
+ RegIdSet readableInputRegisters;
3005
+ if (inNmDocIdRegId.isValid ()) {
3006
+ readableInputRegisters.emplace (inNmDocIdRegId);
3007
+ }
3005
3008
auto writableOutputRegisters = RegIdSet{outDocumentRegId};
3006
3009
3007
3010
auto registerInfos = createRegisterInfos (std::move (readableInputRegisters),
@@ -3010,13 +3013,13 @@ std::unique_ptr<ExecutionBlock> MaterializeSingleNode::createBlock(
3010
3013
auto executorInfos = MaterializerExecutorInfos<decltype (name)>(
3011
3014
inNmDocIdRegId, outDocumentRegId, engine.getQuery (), name);
3012
3015
return std::make_unique<
3013
- ExecutionBlockImpl<MaterializeExecutor<decltype (name)>>>(
3016
+ ExecutionBlockImpl<MaterializeExecutor<decltype (name), localDocumentId >>>(
3014
3017
&engine, this , std::move (registerInfos), std::move (executorInfos));
3015
3018
}
3016
3019
3017
- ExecutionNode* MaterializeSingleNode::clone (ExecutionPlan* plan,
3018
- bool withDependencies,
3019
- bool withProperties) const {
3020
+ template < bool localDocumentId>
3021
+ ExecutionNode* MaterializeSingleNode<localDocumentId>::clone(
3022
+ ExecutionPlan* plan, bool withDependencies, bool withProperties) const {
3020
3023
TRI_ASSERT (plan);
3021
3024
3022
3025
auto * outVariable = _outVariable;
@@ -3028,8 +3031,11 @@ ExecutionNode* MaterializeSingleNode::clone(ExecutionPlan* plan,
3028
3031
plan->getAst ()->variables ()->createVariable (inNonMaterializedDocId);
3029
3032
}
3030
3033
3031
- auto c = std::make_unique<MaterializeSingleNode>(
3034
+ auto c = std::make_unique<MaterializeSingleNode<localDocumentId> >(
3032
3035
plan, _id, collection (), *inNonMaterializedDocId, *outVariable);
3033
3036
CollectionAccessingNode::cloneInto (*c);
3034
3037
return cloneHelper (std::move (c), withDependencies, withProperties);
3035
3038
}
3039
+
3040
+ template class arangodb ::aql::materialize::MaterializeSingleNode<false >;
3041
+ template class arangodb ::aql::materialize::MaterializeSingleNode<true >;
0 commit comments