|
MASA-Core
|
00001 /******************************************************************************* 00002 * 00003 * Copyright (c) 2010-2015 Edans Sandes 00004 * 00005 * This file is part of MASA-Core. 00006 * 00007 * MASA-Core is free software: you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation, either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * MASA-Core is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with MASA-Core. If not, see <http://www.gnu.org/licenses/>. 00019 * 00020 ******************************************************************************/ 00021 00022 class SpecialRowsPartition; 00023 00024 #ifndef SPECIALROWSPARTITION_HPP_ 00025 #define SPECIALROWSPARTITION_HPP_ 00026 00027 #include "SpecialRow.hpp" 00028 00029 #include <string> 00030 #include <map> 00031 using namespace std; 00032 00033 #include "../../libmasa/libmasa.hpp" 00034 #include "FirstRow.hpp" 00035 #include "../io/CellsWriter.hpp" 00036 #include "../io/SeekableCellsReader.hpp" 00037 00038 /** 00039 * 00040 */ 00041 class SpecialRowsPartition { 00042 public: 00043 SpecialRowsPartition(string path, int i0, int j0, int i1, int j1, bool readOnly, const score_params_t* score_params); 00044 virtual ~SpecialRowsPartition(); 00045 void reload(); 00046 void deleteRows(); 00047 00048 void setRamProportion(const long long ram, const long long disk); 00049 00050 // void setFirstRow(const score_params_t* score_params, bool firstRowGapped); 00051 void setFirstColumnReader(SeekableCellsReader* reader); 00052 void setFirstRowReader(SeekableCellsReader* reader); 00053 void setLastColumnWriter(CellsWriter* writer); 00054 void setLastRowWriter(CellsWriter* writer); 00055 00056 int read(cell_t* buf, int len); 00057 int write(int i, const cell_t* buf, int len); 00058 int getLastRowId(); 00059 SpecialRow* getLastRow(); 00060 string getLastRowFilename(); 00061 int getRowsCount() const; 00062 int getReadingRow(); 00063 int getLargestInterval(); 00064 00065 SpecialRow* nextSpecialRow(int i, int j, int min_dist=0) ; 00066 void truncate(int max_i, int max_j); 00067 void changePath(string new_path); 00068 00069 int getI0() const; 00070 int getI1() const; 00071 int getJ0() const; 00072 int getJ1() const; 00073 const string& getPath() const; 00074 00075 CellsWriter* getFirstColumnWriter(); 00076 SeekableCellsReader* getFirstColumnReader(); 00077 SeekableCellsReader* getFirstRowReader(); 00078 CellsWriter* getLastColumnWriter(); 00079 CellsWriter* getLastRowWriter(); 00080 00081 void createChain(SpecialRowsPartition* otherPartition); 00082 00083 string getFirstColumnFilename(); 00084 string getFirstRowFilename(); 00085 00086 int continueFromLastRow(); 00087 00088 bool isPersistent() const; 00089 00090 private: 00091 int i0; 00092 int j0; 00093 int i1; 00094 int j1; 00095 00096 long long ramProportion; 00097 long long diskProportion; 00098 int ramCount; 00099 int diskCount; 00100 const score_params_t* score_params; 00101 00102 bool readOnly; 00103 bool persistent; 00104 string path; 00105 map<int, SpecialRow*> rowsMap; 00106 vector<SpecialRow*> rowsVector; 00107 int largestInterval; 00108 int readingRowId; 00109 int lastRowId; 00110 string lastRowFilename; 00111 //int readingRowOffset; 00112 SpecialRow* readingRow; 00113 FirstRow firstRow; 00114 CellsWriter* firstColumnWriter; 00115 CellsWriter* firstRowWriter; 00116 SeekableCellsReader* firstColumnReader; 00117 SeekableCellsReader* firstRowReader; 00118 CellsWriter* lastColumnWriter; 00119 CellsWriter* lastRowWriter; 00120 void updateLargestInterval(); 00121 00122 //pthread_mutex_t mutex; 00123 00124 void readDirectory(); 00125 SpecialRow* getSpecialRow(int i); 00126 void setBorderReader(char prefix, SeekableCellsReader* &reader, CellsWriter* &writer); 00127 bool loadBorderReader(char prefix, string file, SeekableCellsReader* &reader); 00128 00129 }; 00130 00131 #endif /* SPECIALROWSPARTITION_HPP_ */
1.7.6.1