utils.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. #include <yql/essentials/core/yql_graph_transformer.h>
  3. namespace NYql {
  4. namespace NPureCalc {
  5. /**
  6. * A transformer which wraps the given input node with the pipeline
  7. * converting the input type to the block one.
  8. *
  9. * @param pos the position of the given node to be rewritten.
  10. * @param structType the item type of the container provided by the node.
  11. * @param ctx the context to make ExprNode rewrites.
  12. * @return the resulting ExprNode.
  13. */
  14. TExprNode::TPtr NodeFromBlocks(
  15. const TPositionHandle& pos,
  16. const TStructExprType* structType,
  17. TExprContext& ctx
  18. );
  19. /**
  20. * A transformer which wraps the given root node with the pipeline
  21. * converting the output type to the block one.
  22. *
  23. * @param pos the position of the given node to be rewritten.
  24. * @param structType the item type of the container provided by the node.
  25. * @param ctx the context to make ExprNode rewrites.
  26. * @return the resulting ExprNode.
  27. */
  28. TExprNode::TPtr NodeToBlocks(
  29. const TPositionHandle& pos,
  30. const TStructExprType* structType,
  31. TExprContext& ctx
  32. );
  33. /**
  34. * A transformer to apply the given lambda to the given iterable (either
  35. * list or stream). If the iterable is list, the lambda should be passed
  36. * to the <LMap> callable; if the iterable is stream, the lambda should
  37. * be applied right to the iterable.
  38. *
  39. * @param pos the position of the given node to be rewritten.
  40. * @param iterable the node, that provides the iterable to be processed.
  41. * @param lambda the node, that provides lambda to be applied.
  42. * @param wrapLMap indicator to wrap the result with LMap callable.
  43. * @oaram ctx the context to make ExprNode rewrites.
  44. */
  45. TExprNode::TPtr ApplyToIterable(
  46. const TPositionHandle& pos,
  47. const TExprNode::TPtr iterable,
  48. const TExprNode::TPtr lambda,
  49. bool wrapLMap,
  50. TExprContext& ctx
  51. );
  52. /**
  53. * A helper which wraps the items of the given struct with the block
  54. * type container and appends the new item for _yql_block_length column.
  55. *
  56. * @param structType original struct to be wrapped.
  57. * @param ctx the context to make ExprType rewrite.
  58. * @return the new struct with block items.
  59. */
  60. const TStructExprType* WrapBlockStruct(
  61. const TStructExprType* structType,
  62. TExprContext& ctx
  63. );
  64. /**
  65. * A helper which unwraps the block container from the items of the
  66. * given struct and removes the item for _yql_block_length column.
  67. *
  68. * @param structType original struct to be unwrapped.
  69. * @param ctx the context to make ExprType rewrite.
  70. * @return the new struct without block items.
  71. */
  72. const TStructExprType* UnwrapBlockStruct(
  73. const TStructExprType* structType,
  74. TExprContext& ctx
  75. );
  76. }
  77. }