anacommon.hpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifdef WUANALYSIS_EXPORTS
  20. #define WUANALYSIS_API DECL_EXPORT
  21. #else
  22. #define WUANALYSIS_API DECL_IMPORT
  23. #endif
  24. interface IWuScope
  25. {
  26. virtual stat_type getStatRaw(StatisticKind kind, StatisticKind variant = StKindNone) const = 0;
  27. virtual unsigned getAttr(WuAttr kind) const = 0;
  28. virtual void getAttr(StringBuffer & result, WuAttr kind) const = 0;
  29. };
  30. interface IWuActivity;
  31. interface IWuEdge : public IWuScope
  32. {
  33. virtual IWuActivity * querySource() = 0;
  34. virtual IWuActivity * queryTarget() = 0;
  35. };
  36. interface IWuActivity : public IWuScope
  37. {
  38. virtual const char * queryName() const = 0;
  39. virtual const char * getFullScopeName(StringBuffer & fullScopeName) const = 0;
  40. virtual IWuEdge * queryInput(unsigned idx) = 0;
  41. virtual IWuEdge * queryOutput(unsigned idx) = 0;
  42. inline IWuActivity * queryInputActivity(unsigned idx)
  43. {
  44. IWuEdge * edge = queryInput(idx);
  45. return edge ? edge->querySource() : nullptr;
  46. }
  47. inline ThorActivityKind queryThorActivityKind()
  48. {
  49. return (ThorActivityKind) getAttr(WaKind);
  50. }
  51. };
  52. class PerformanceIssue : public CInterface
  53. {
  54. public:
  55. int compareCost(const PerformanceIssue & other) const;
  56. void print() const;
  57. void createException(IWorkUnit * we);
  58. void set(AnalyzerErrorCode _errorCode, stat_type _cost, const char * msg, ...) __attribute__((format(printf, 4, 5)));
  59. void setLocation(const char * definition);
  60. void setScope(const char *_scope) { scope.set(_scope); }
  61. stat_type getCost() const { return cost; }
  62. private:
  63. AnalyzerErrorCode errorCode = ANA_GENERICERROR_ID;
  64. StringBuffer filename;
  65. unsigned line = 0;
  66. unsigned column = 0;
  67. StringAttr scope;
  68. stat_type cost = 0; // number of nanoseconds lost as a result.
  69. StringBuffer comment;
  70. };
  71. extern int compareIssuesCostOrder(CInterface * const * _l, CInterface * const * _r);
  72. #endif