anacommon.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2019 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef ANACOMMON_HPP
  14. #define ANACOMMON_HPP
  15. #include "jliball.hpp"
  16. #include "wuattr.hpp"
  17. #include "eclhelper.hpp"
  18. #include "anaerrorcodes.hpp"
  19. interface IWuScope
  20. {
  21. virtual stat_type getStatRaw(StatisticKind kind, StatisticKind variant = StKindNone) const = 0;
  22. virtual unsigned getAttr(WuAttr kind) const = 0;
  23. virtual void getAttr(StringBuffer & result, WuAttr kind) const = 0;
  24. };
  25. interface IWuActivity;
  26. interface IWuEdge : public IWuScope
  27. {
  28. virtual IWuActivity * querySource() = 0;
  29. virtual IWuActivity * queryTarget() = 0;
  30. };
  31. interface IWuActivity : public IWuScope
  32. {
  33. virtual const char * queryName() const = 0;
  34. virtual const char * getFullScopeName(StringBuffer & fullScopeName) const = 0;
  35. virtual IWuEdge * queryInput(unsigned idx) = 0;
  36. virtual IWuEdge * queryOutput(unsigned idx) = 0;
  37. inline IWuActivity * queryInputActivity(unsigned idx)
  38. {
  39. IWuEdge * edge = queryInput(idx);
  40. return edge ? edge->querySource() : nullptr;
  41. }
  42. inline ThorActivityKind queryThorActivityKind()
  43. {
  44. return (ThorActivityKind) getAttr(WaKind);
  45. }
  46. };
  47. class PerformanceIssue : public CInterface
  48. {
  49. public:
  50. int compareCost(const PerformanceIssue & other) const;
  51. void print() const;
  52. void createException(IWorkUnit * we);
  53. void set(AnalyzerErrorCode _errorCode, stat_type _cost, const char * msg, ...) __attribute__((format(printf, 4, 5)));
  54. void setLocation(const char * definition);
  55. void setScope(const char *_scope) { scope.set(_scope); }
  56. stat_type getCost() const { return cost; }
  57. private:
  58. AnalyzerErrorCode errorCode = ANA_GENERICERROR_ID;
  59. StringBuffer filename;
  60. unsigned line = 0;
  61. unsigned column = 0;
  62. StringAttr scope;
  63. stat_type cost = 0; // number of nanoseconds lost as a result.
  64. StringBuffer comment;
  65. };
  66. typedef enum { watOptFirst=0, watOptMinInterestingTime=0, watOptMinInterestingCost, watOptSkewThreshold, watOptMinRowsPerNode, watPreFilteredKJThreshold, watOptMax } WutOptionType ;
  67. interface IAnalyserOptions
  68. {
  69. virtual stat_type queryOption(WutOptionType opt) const = 0;
  70. };
  71. extern int compareIssuesCostOrder(CInterface * const * _l, CInterface * const * _r);
  72. #endif