From fd66ca862d4499378719e2a635c9f97df28b763d Mon Sep 17 00:00:00 2001 From: Andrei Aiordachioaie Date: Tue, 25 Aug 2009 13:33:09 +0200 Subject: Tiling & Indexing options added to rasql grammar --- storagemgr/Makefile.am | 3 +- storagemgr/sstoragelayout.cc | 215 +++++++++++++++++++++++++++++++++++++------ storagemgr/sstoragelayout.hh | 39 ++++++++ storagemgr/stgmddconfig.cc | 92 ++++++++++++++++++ storagemgr/stgmddconfig.hh | 57 ++++++++++++ 5 files changed, 378 insertions(+), 28 deletions(-) create mode 100755 storagemgr/stgmddconfig.cc create mode 100755 storagemgr/stgmddconfig.hh (limited to 'storagemgr') diff --git a/storagemgr/Makefile.am b/storagemgr/Makefile.am index f019320..53d93c0 100644 --- a/storagemgr/Makefile.am +++ b/storagemgr/Makefile.am @@ -29,7 +29,8 @@ ################################################################## lib_LIBRARIES = libstoragemgr.a -libstoragemgr_a_SOURCES = sstoragelayout.cc sstoragelayout.hh +libstoragemgr_a_SOURCES = sstoragelayout.cc sstoragelayout.hh \ + stgmddconfig.cc stgmddconfig.hh CLEANFILES= core client.bm client.dbg client.log ir.out diff --git a/storagemgr/sstoragelayout.cc b/storagemgr/sstoragelayout.cc index fc7a793..0dcef0c 100644 --- a/storagemgr/sstoragelayout.cc +++ b/storagemgr/sstoragelayout.cc @@ -1,29 +1,21 @@ -/* -* This file is part of rasdaman community. -* -* Rasdaman community is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Rasdaman community is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with rasdaman community. If not, see . -* -* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / -rasdaman GmbH. -* -* For more information please see -* or contact Peter Baumann via . -*/ /**************************************************************************** * * + * SOURCE: sstoragelayout.cc + * + * MODULE: indexmgr + * CLASS: StorageLayout * + * CHANGE HISTORY (append further entries): + * when who what + * ----------------------------------------------------------------------- + * 10-Sep-97 furtado creation of preliminary version. + * 09-Oct-97 sivan set, get functions + * 13-Oct-97 furtado extended functionality, class hierarchy + * 4-Nov-98 furtado added RegDirIx< >. + * 13-Nov-00 hoefner startet to do something with this class + * 07-Jan-09 Shams add tiling set to the getLayout method + * 07-Jan-09 Shams add some methods for supporting tiling * COMMENTS: * none * @@ -32,6 +24,9 @@ rasdaman GmbH. #include "sstoragelayout.hh" #include #include "raslib/rmdebug.hh" +#include "rasodmg/alignedtiling.hh" +#include "rasodmg/dirtiling.hh" +#include "rasodmg/stattiling.hh" const r_Bytes StorageLayout::DBSPageSize = 4096; @@ -55,18 +50,21 @@ StorageLayout::StorageLayout(r_Index_Type ixType) : myLayout(new DBStorageLayout()) { setIndexType(ixType); + extraFeatures = new StgMddConfig(); RMDBGONCE(4, RMDebug::module_storagemgr, "StorageLayout", "StorageLayout(" << ixType << ")") } StorageLayout::StorageLayout() : myLayout(new DBStorageLayout()) { + extraFeatures = new StgMddConfig(); RMDBGONCE(4, RMDebug::module_storagemgr, "StorageLayout", "StorageLayout()") } StorageLayout::StorageLayout(const DBStorageLayoutId& id) : myLayout(id) { + extraFeatures = new StgMddConfig(); RMDBGONCE(4, RMDebug::module_storagemgr, "StorageLayout", "StorageLayout(" << id.getOId() << ")") } @@ -84,6 +82,7 @@ StorageLayout::getDBStorageLayout() const return myLayout; } + r_Index_Type StorageLayout::getIndexType() const { @@ -152,6 +151,45 @@ StorageLayout::getDataFormat(const r_Point& where) const return myLayout->getDataFormat(); } +void +StorageLayout::setBBoxes(const vector& input) { + extraFeatures->setBBoxes(input); +} + +void +StorageLayout::setSubTiling() +{extraFeatures->setSubTiling();} + +void +StorageLayout::resetSubTiling() +{extraFeatures->resetSubTiling();} + +void +StorageLayout::setInterestThreshold(double i){ + extraFeatures->setInterestThreshold(i); +} + +void +StorageLayout::setBorderThreshold(unsigned int b){ + extraFeatures->setBorderThreshold(b); +} + +void +StorageLayout::setCellSize(int i){ + extraFeatures->setCellSize(i); +} + + +void +StorageLayout::setDirDecomp(vector* dir){ + vector dec; + for(int i = 0 ; i < dir->size() ; ++i){ + dec.push_back(dir->at(i)); + } + extraFeatures->setDirDecompose(dec); +} + + std::vector< r_Minterval > StorageLayout::getLayout(const r_Minterval& tileDomain) { @@ -169,11 +207,36 @@ StorageLayout::getLayout(const r_Minterval& tileDomain) retval.push_back(tileDomain); } break; - case r_InterestTiling: - case r_StatisticalTiling: - case r_AlignedTiling: - case r_DirectionalTiling: - case r_SizeTiling: + case r_InterestTiling: + retval = calcInterestLayout(tileDomain); + RMInit::logOut << "Interest Tiling chosen Everything is OK" << endl; + RMDBGMIDDLE(0, RMDebug::module_storagemgr, "StorageLayout", "getLayout(" << tileDomain << ") Interest Tiling"); + break; + case r_StatisticalTiling: + retval = calcStatisticLayout(tileDomain); + RMInit::logOut << "Statistical Tiling chosen" << endl; + break; + case r_AlignedTiling: + if (myLayout->getTileConfiguration().dimension() == tileDomain.dimension()) + retval = calcAlignedLayout(tileDomain); + else { + RMInit::logOut << "Aligned Tiling chosen without Tiling Domain!\nPlease specify a Tiling Domain.\nNow using no tiling." << endl; + RMDBGMIDDLE(0, RMDebug::module_storagemgr, "StorageLayout", "getLayout(" << tileDomain << ") Aligned Tiling without Tiling Domain"); + retval.push_back(tileDomain); + } + break; + + case r_DirectionalTiling: +// if (myLayout->getTileConfiguration().dimension() == tileDomain.dimension()) + retval = calcDirectionalLayout(tileDomain); +// else { + RMInit::logOut << "Directional Tiling chosen. Everything is OK." << endl; +// RMDBGMIDDLE(0, RMDebug::module_storagemgr, "StorageLayout", "getLayout(" << tileDomain << ") Directional Tiling without Tiling Domain"); +// retval.push_back(tileDomain); + // } + break; + + case r_SizeTiling: RMInit::logOut << "Tiling Scheme " << myLayout->getTilingScheme() << " " << (int)myLayout->getTilingScheme() << " not supported" << endl; RMDBGMIDDLE(0, RMDebug::module_storagemgr, "StorageLayout", "getLayout(" << tileDomain << ") of " << myLayout->getOId() << " Tiling Scheme " << myLayout->getTilingScheme() << " " << (int)myLayout->getTilingScheme() << " not supported"); retval.push_back(tileDomain); @@ -255,6 +318,104 @@ RMDBGIF(5, RMDebug::module_storagemgr, "StorageLayout", \ RMDBGMIDDLE(1, RMDebug::module_storagemgr, "StorageLayout", *i); \ ); RMDBGEXIT(4, RMDebug::module_storagemgr, "StorageLayout", "calcRegLayout(" << tileDomain << ") " << myLayout->getOId()); + RMInit::logOut << "CalcReg Tiling: tile number: " << retval.size() << endl; return retval; } +std::vector< r_Minterval > +StorageLayout::calcInterestLayout(const r_Minterval& tileDomain) { + RMInit::logOut << "Entering CalcInterest Tiling" << endl; + r_Interest_Tiling* tiling = new r_Interest_Tiling + (tileDomain.dimension(), extraFeatures->getBBoxes(), myLayout->getTileSize(), r_Interest_Tiling::SUB_TILING); + std::vector ret; + std::vector* ret1 = tiling->compute_tiles + (tileDomain, extraFeatures->getCellSize()); + RMInit::logOut << "CalcInterest Tiling: tile number: " << ret1->size() << endl; + for (int i = 0; i < ret1->size(); i++) { + ret.push_back(ret1->at(i)); + } + RMInit::logOut << "CalcInterest Tiling: tile number2: " << ret.size() << endl; + return ret; +} + +std::vector< r_Minterval > +StorageLayout::calcAlignedLayout(const r_Minterval& tileDomain) { + RMInit::logOut << "Entering CalcAligned Tiling" << endl; + r_Aligned_Tiling* tiling = new r_Aligned_Tiling + (myLayout->getTileConfiguration(),myLayout->getTileSize()); + std::vector ret; + std::vector* ret1 = tiling->compute_tiles + (tileDomain, extraFeatures->getCellSize()); + RMInit::logOut << "CalcAligned Tiling: tile number: " << ret1->size() << endl; + for (int i = 0; i < ret1->size(); i++) { + ret.push_back(ret1->at(i)); + } + RMInit::logOut << "CalcAligned Tiling: tile number2: " << ret.size() << endl; + return ret; +} + +std::vector< r_Minterval > +StorageLayout::calcDirectionalLayout(const r_Minterval& tileDomain){ + RMInit::logOut << "Entering CalcDir Tiling" << endl; + r_Dir_Tiling* dirTile ; + if(!extraFeatures->getSubTiling()) + dirTile = new r_Dir_Tiling(tileDomain.dimension(), + extraFeatures->getDirDecompose(),myLayout->getTileSize(), + r_Dir_Tiling::WITHOUT_SUBTILING); + else + dirTile = new r_Dir_Tiling(tileDomain.dimension(), + extraFeatures->getDirDecompose(),myLayout->getTileSize(), + r_Dir_Tiling::WITH_SUBTILING); + + std::vector ret; + std::vector* ret1 = dirTile->compute_tiles + (tileDomain, extraFeatures->getCellSize()); + RMInit::logOut << "CalcDir Tiling: tile number: " << ret1->size() << endl; + for (int i = 0; i < ret1->size(); i++) { + ret.push_back(ret1->at(i)); + } + RMInit::logOut << "End of dirTiling Method Tile numbers = "<< ret.size(); + return ret; +} + +std::vector< r_Minterval > +StorageLayout::calcStatisticLayout(const r_Minterval& tileDomain){ + RMInit::logOut << "Entering CalcStatistic Tiling" << endl; + std::vector ret; + RMInit::logOut << "ret is created" << endl; + RMInit::logOut << "bboxes are " << extraFeatures->getBBoxes().size() << endl; + vector temp = extraFeatures->getBBoxes(); + RMInit::logOut << "bboxes are ok " << temp.size() << endl; + RMInit::logOut << "Statistic areas are "<< endl; + std::vector accesses; + RMInit::logOut << "Beginning of For"<< endl; + for(int i = 0 ; i < temp.size() ; ++i){ + r_Minterval area = temp.at(i); + r_Access ac(area); + RMInit::logOut << ac; + accesses.push_back(ac); + } + RMInit::logOut << "\nStatistic End of for"<getBorderThreshold() < 0) + borderT = r_Stat_Tiling::DEF_BORDER_THR; + else + borderT = extraFeatures->getBorderThreshold(); + if(extraFeatures->getInterestThreshold() < 0) + interestT = r_Stat_Tiling::DEF_INTERESTING_THR; + else + interestT = extraFeatures->getInterestThreshold(); + RMInit::logOut << "Object is : " <getTileSize()<<" "<< borderT<< " "<< interestT <getTileSize(), borderT, + interestT); + RMInit::logOut << "Object created" << endl; + std::vector* ret1 = stat->compute_tiles(tileDomain,extraFeatures->getCellSize()); + RMInit::logOut << "End of CalcStatistic Tiling tile numbers = "<< ret.size() << endl; + for (int i = 0; i < ret1->size(); i++) { + ret.push_back(ret1->at(i)); + } + + return ret; +} diff --git a/storagemgr/sstoragelayout.hh b/storagemgr/sstoragelayout.hh index 4ac9e79..b3e2a25 100644 --- a/storagemgr/sstoragelayout.hh +++ b/storagemgr/sstoragelayout.hh @@ -5,6 +5,10 @@ #include "raslib/minterval.hh" #include "relstorageif/dbstoragelayout.hh" +#include "rasodmg/interesttiling.hh" +#include "rasodmg/stattiling.hh" +#include "rasodmg/dirdecompose.hh" +#include "storagemgr/stgmddconfig.hh" /* @@ -32,7 +36,16 @@ rasdaman GmbH. /**************************************************************************** * * + * INCLUDE: storagelayout.hh * + * MODULE: storagemgr + * CLASS: StorageLayout + * + * CHANGE HISTORY (append further entries): + * when who what + * ----------------------------------------------------------------------- + * 13-Nov-00 hoefner creation of preliminary version + * 07-Jan-09 Shams add tiling attributes * COMMENTS: * ****************************************************************************/ @@ -215,6 +228,16 @@ class StorageLayout return the object which actually stores the option values. */ + // Functions added by Andrei Aiordachioaie, to match function definitions. (17-08-2009) + void setBBoxes(const vector& input); + void setSubTiling(); + void resetSubTiling(); + void setInterestThreshold(double i); + void setBorderThreshold(unsigned int b); + void setCellSize(int size); + void setDirDecomp(vector*); + + protected: std::vector< r_Minterval > calcRegLayout(const r_Minterval& layout) const; /*@Doc: @@ -224,11 +247,27 @@ class StorageLayout //@Man: Actual Parameters: //@{ + StgMddConfig* extraFeatures; + /*@Doc: actual features */ + DBStorageLayoutId myLayout; //@Man: Persistent Representation of a StorageLayout object. //@{ ///All parameters are stored there. //@} + std::vector< r_Minterval > + calcInterestLayout(const r_Minterval& tileDomain); + + //@Man: Actual Parameters: + //@{ + std::vector< r_Minterval > + calcAlignedLayout(const r_Minterval&); + + std::vector< r_Minterval > + calcDirectionalLayout(const r_Minterval&); + + std::vector< r_Minterval > + calcStatisticLayout(const r_Minterval&); //@} diff --git a/storagemgr/stgmddconfig.cc b/storagemgr/stgmddconfig.cc new file mode 100755 index 0000000..c008479 --- /dev/null +++ b/storagemgr/stgmddconfig.cc @@ -0,0 +1,92 @@ +#include "storagemgr/stgmddconfig.hh" + +using namespace std; + +/**************************************************************************** + * + * + * INCLUDE: stgmddconfig.hh + * + * MODULE: qlparser + * CLASS: StgMddConfig + * + * CHANGE HISTORY (append further entries): + * when who what + * ----------------------------------------------------------------------- + * 17-Aug-09 aaiordachi create class (for adding rasql tiling options) + * COMMENTS: + * + ****************************************************************************/ + +StgMddConfig::StgMddConfig() +{} +StgMddConfig::~StgMddConfig() +{} + +// Setter functions +void StgMddConfig::setBBoxes(const vector& input) +{ + bboxes = input; +} + +void StgMddConfig::setSubTiling() +{ + subTiling = true; +} + +void StgMddConfig::resetSubTiling() +{ + subTiling = false; +} + +void StgMddConfig::setInterestThreshold(double i) +{ + interestThreshold = i; +} + +void StgMddConfig::setBorderThreshold(unsigned int b) +{ + borderThreshold = b; +} + +void StgMddConfig::setCellSize(int size) +{ + cellSize = size; +} + +void StgMddConfig::setDirDecompose(const vector& input) +{ + dirDecomp = input; +} + +// Getter functions +vector& StgMddConfig::getBBoxes() +{ + return bboxes; +} + +bool StgMddConfig::getSubTiling() +{ + return subTiling; +} + +double StgMddConfig::getInterestThreshold() +{ + return interestThreshold; +} + +unsigned int StgMddConfig::getBorderThreshold() +{ + return borderThreshold; +} + +int StgMddConfig::getCellSize() +{ + return cellSize; +} + +vector& StgMddConfig::getDirDecompose() +{ + return dirDecomp; +} + diff --git a/storagemgr/stgmddconfig.hh b/storagemgr/stgmddconfig.hh new file mode 100755 index 0000000..4588715 --- /dev/null +++ b/storagemgr/stgmddconfig.hh @@ -0,0 +1,57 @@ +#ifndef _STORAGE_MDD_CONFIG_HH_ +#define _STORAGE_MDD_CONFIG_HH_ + +#include +#include "rasodmg/dirdecompose.hh" +#include "raslib/minterval.hh" + +/**************************************************************************** + * + * + * INCLUDE: stgmddconfig.hh + * + * MODULE: qlparser + * CLASS: StgMddConfig + * + * CHANGE HISTORY (append further entries): + * when who what + * ----------------------------------------------------------------------- + * 17-Aug-09 aaiordachi create class (for adding rasql tiling options) + * COMMENTS: + * + ****************************************************************************/ + +class StgMddConfig + { + private: + std::vector bboxes; + double interestThreshold; + unsigned int borderThreshold; + bool subTiling; + int cellSize; + std::vector dirDecomp; + + public: + + StgMddConfig(); + ~StgMddConfig(); + + // Setter functions + void setBBoxes(const std::vector& input); + void setSubTiling(); + void resetSubTiling(); + void setInterestThreshold(double i); + void setBorderThreshold(unsigned int b); + void setCellSize(int size); + void setDirDecompose(const std::vector& input); + + // Getter functions + std::vector& getBBoxes(); + bool getSubTiling(); + double getInterestThreshold(); + unsigned int getBorderThreshold(); + int getCellSize(); + std::vector& getDirDecompose(); + + }; +#endif -- cgit