/* $Id: lbaktree.h 5797 2010-10-23 01:41:30Z abehm $ Copyright (C) 2010 by The Regents of the University of California Redistribution of this file is permitted under the terms of the BSD license. Date: 08/19/2010 Author: Sattam Alsubaiee */ #include #include "kwdsstorage.h" #include "rstartree/rstartree.h" #include "rstartree/util.h" #include "filtertree/src/wrappers/wrappers.h" enum AlgorithmType {fl, vl, vlf}; class NodePriority { public: unsigned id; double priority; double pFuzzyTimeCost, cFuzzyTimeCost, pFuzzySpaceCost, cFuzzySpaceCost; vector ancestorsIds; bool operator<(const NodePriority &n) const { return priority < n.priority; }; }; class LBAKTree: public RTree { private: GramGenFixedLen *gramGen; KeywordsFile kf1, kf2; double spaceBudget, avgKwdsLength, sx, sy, sx2, sy2, sxy, n, gradient, intercept; float simThreshold, kfThreshold; unsigned numKwds, q, indexesLevel; string queryWorkloadFile; AlgorithmType algoType; vector dictionary; unordered_map keywordsMap; unordered_map queryWorkloadMap; unordered_map *> recordsMap; unordered_map *> keywordsHashesMap; unordered_map strContainersMap; unordered_map wrappersMap; void init(AlgorithmType type, float simT); void readQueryWorkload(const Rectangle &range); void readQueryWorkload(const Rectangle &range, unsigned objectId); void propagateKeywords(unsigned objectId); void insertKeywords(unsigned objectId, unordered_set &kwds, bool leaf); void parseKeywords(string &text, unordered_set &kwds); void selectSANodes(); void computeGradientIntercept(unsigned objectId, vector &keywords); void useFL(); void useVL(); void useVLF(); void fillKeywordsIntersectionsFile(); void fillKeywordsHashesMap(); void fillWrappersMap(); void rangeQuery(vector &objects, const Rectangle &range, unsigned id, const vector &kwds, vector strings[], vector hashes[]); bool searchWrapper(unsigned objectId, const vector &kwds, vectorstrings[], vectorhashes[], vectorresultStrings[], vectorresultHashes[]); bool searchArray(unsigned objectId, unsigned numKeywords, vector strings[], vector hashes[], vector resultStrings[], vector resultHashes[]); bool searchVector(unsigned objectId, const string &keyword); public: LBAKTree(Storage *storage, AlgorithmType type, unsigned il, float simT); LBAKTree(Storage *storage, string &file, AlgorithmType type, double sb, float simT); LBAKTree(Storage *storage, string &file, AlgorithmType type, double sb, float simT, float kfT); ~LBAKTree(); void insert(const Object &obj, vector &kwds); void buildIndex(); void rangeQuery(vector &objects, const Rectangle &range, const vector &kwds); void getObjectKeywords(unsigned objectId, vector &objectKeywords); void startTimeMeasurement(struct timeval &t1, struct timezone &tz); void stopTimeMeasurement(struct timeval &t2, struct timezone &tz); double getTimeMeasurement(struct timeval &t1, struct timeval &t2); };