mkql_squeeze_state.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. #include <yql/essentials/minikql/computation/mkql_computation_node_pack.h>
  3. #include <yql/essentials/minikql/computation/mkql_computation_node_holders.h>
  4. namespace NKikimr {
  5. namespace NMiniKQL {
  6. enum class ESqueezeState : ui8 {
  7. Idle = 0,
  8. Work,
  9. Finished,
  10. NeedInit
  11. };
  12. struct TSqueezeState {
  13. TSqueezeState(
  14. IComputationExternalNode* item,
  15. IComputationExternalNode* state,
  16. IComputationNode* outSwitch,
  17. IComputationNode* initState,
  18. IComputationNode* newState,
  19. IComputationExternalNode* inSave,
  20. IComputationNode* outSave,
  21. IComputationExternalNode* inLoad,
  22. IComputationNode* outLoad,
  23. const TType* stateType
  24. );
  25. TSqueezeState(const TSqueezeState& state);
  26. NUdf::TUnboxedValue Save(TComputationContext& ctx) const;
  27. void Load(TComputationContext& ctx, const NUdf::TStringRef& state);
  28. ESqueezeState Stage = ESqueezeState::Idle;
  29. IComputationExternalNode* const Item;
  30. IComputationExternalNode* const State;
  31. IComputationNode* const Switch;
  32. IComputationNode* const InitState;
  33. IComputationNode* const UpdateState;
  34. IComputationExternalNode* const InSave;
  35. IComputationNode* const OutSave;
  36. IComputationExternalNode* const InLoad;
  37. IComputationNode* const OutLoad;
  38. private:
  39. const TValuePacker& GetPacker() const;
  40. const TType* StateType;
  41. mutable THolder<TValuePacker> Packer;
  42. };
  43. class TSqueezeCodegenValue : public TComputationValue<TSqueezeCodegenValue> {
  44. public:
  45. using TBase = TComputationValue<TSqueezeCodegenValue>;
  46. using TFetchPtr = NUdf::EFetchStatus (*)(TComputationContext*, NUdf::TUnboxedValuePod, NUdf::TUnboxedValuePod&, ESqueezeState&);
  47. TSqueezeCodegenValue(TMemoryUsageInfo* memInfo, const TSqueezeState& state, TFetchPtr fetch, TComputationContext& ctx, NUdf::TUnboxedValue&& stream);
  48. private:
  49. ui32 GetTraverseCount() const final;
  50. NUdf::TUnboxedValue GetTraverseItem(ui32) const final;
  51. NUdf::TUnboxedValue Save() const final;
  52. void Load(const NUdf::TStringRef& state) final;
  53. NUdf::EFetchStatus Fetch(NUdf::TUnboxedValue& result) final;
  54. const TFetchPtr FetchFunc;
  55. const NUdf::TUnboxedValue Stream;
  56. TComputationContext& Ctx;
  57. TSqueezeState State;
  58. };
  59. }
  60. }