123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- /*##############################################################################
- HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ############################################################################## */
- #ifndef __HQLUSAGE_HPP_
- #define __HQLUSAGE_HPP_
- class HQL_API HqlSelectorAnywhereLocator : public NewHqlTransformer
- {
- public:
- HqlSelectorAnywhereLocator(IHqlExpression * _selector);
- virtual void analyseExpr(IHqlExpression * expr);
- virtual void analyseSelector(IHqlExpression * expr);
- bool containsSelector(IHqlExpression * expr);
- protected:
- bool foundSelector;
- OwnedHqlExpr selector;
- };
- class HQL_API FieldAccessAnalyser : public NewHqlTransformer
- {
- public:
- FieldAccessAnalyser(IHqlExpression * selector);
- inline bool accessedAll() const { return numAccessed == fields.ordinality(); }
- IHqlExpression * queryLastFieldAccessed() const;
- protected:
- virtual void analyseExpr(IHqlExpression * expr);
- virtual void analyseSelector(IHqlExpression * expr);
- inline void setAccessedAll() { numAccessed = fields.ordinality(); }
- protected:
- LinkedHqlExpr selector;
- HqlExprCopyArray fields;
- Owned<IBitSet> accessed;
- unsigned numAccessed;
- };
- class HQL_API SourceFieldUsage : public CInterface
- {
- public:
- SourceFieldUsage(IHqlExpression * _source);
- void noteSelect(IHqlExpression * select, IHqlExpression * selector);
- inline void noteAll() { usedAll = true; }
- inline void noteFilepos() { usedFilepos = true; }
- const char * queryFilenameText() const;
- inline bool matches(IHqlExpression * search) const { return source == search; }
- inline bool seenAll() const { return usedAll; }
- IPropertyTree * createReport(bool includeFieldDetail, const IPropertyTree * exclude) const;
- protected:
- void expandSelects(IPropertyTree * xml, IHqlExpression * record, IHqlExpression * selector, bool allUsed, bool includeFieldDetail, unsigned & numFields, unsigned & numFieldsUsed) const;
- IHqlExpression * queryFilename() const;
- protected:
- LinkedHqlExpr source;
- HqlExprArray selects;
- bool usedAll;
- bool usedFilepos;
- private:
- mutable StringAttr cachedFilenameEcl;
- };
- extern HQL_API unsigned getNumUniqueExpressions(IHqlExpression * expr);
- extern HQL_API unsigned getNumUniqueExpressions(const HqlExprArray & exprs);
- extern HQL_API unsigned getNumOccurences(HqlExprArray & exprs, IHqlExpression * search, unsigned limit);
- extern HQL_API void logTreeStats(IHqlExpression * expr);
- extern HQL_API void logTreeStats(const HqlExprArray & exprs);
- extern HQL_API void gatherSelectExprs(HqlExprArray & target, IHqlExpression * expr);
- extern HQL_API bool containsSelector(IHqlExpression * expr, IHqlExpression * selector);
- extern HQL_API bool containsSelectorAnywhere(IHqlExpression * expr, IHqlExpression * selector); // searches through nested "hidden" definitions
- extern HQL_API void gatherFieldUsage(SourceFieldUsage * fieldUsage, IHqlExpression * expr, IHqlExpression * selector);
- extern HQL_API void gatherParentFieldUsage(SourceFieldUsage * fieldUsage, IHqlExpression * expr);
- #endif
|