MCPcopy Create free account
hub / github.com/catboost/catboost / TFileMappedArray

Class TFileMappedArray

util/system/filemap.h:187–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185
186template <class T>
187class TFileMappedArray {
188private:
189 const T* Ptr_;
190 const T* End_;
191 size_t Size_;
192 char DummyData_[sizeof(T) + PLATFORM_DATA_ALIGN];
193 mutable THolder<T, TDestructor> Dummy_;
194 THolder<TFileMap> DataHolder_;
195
196public:
197 TFileMappedArray()
198 : Ptr_(nullptr)
199 , End_(nullptr)
200 , Size_(0)
201 {
202 }
203 ~TFileMappedArray() {
204 Ptr_ = nullptr;
205 End_ = nullptr;
206 }
207 void Init(const char* name) {
208 DataHolder_.Reset(new TFileMap(name));
209 DoInit(name);
210 }
211 void Init(const TFileMap& fileMap) {
212 DataHolder_.Reset(new TFileMap(fileMap));
213 DoInit(fileMap.GetFile().GetName());
214 }
215 void Term() {
216 DataHolder_.Destroy();
217 Ptr_ = nullptr;
218 Size_ = 0;
219 End_ = nullptr;
220 }
221 void Precharge() {
222 DataHolder_->Precharge();
223 }
224 const T& operator[](size_t pos) const {
225 Y_ASSERT(pos < size());
226 return Ptr_[pos];
227 }
228 /// for STL compatibility only, Size() usage is recommended
229 size_t size() const {
230 return Size_;
231 }
232 size_t Size() const {
233 return Size_;
234 }
235 const T& GetAt(size_t pos) const {
236 if (pos < Size_) {
237 return Ptr_[pos];
238 }
239 return Dummy();
240 }
241 void SetDummy(const T& n_Dummy) {
242 Dummy_.Destroy();
243 Dummy_.Reset(new (DummyData()) T(n_Dummy));
244 }

Callers

nothing calls this directly

Calls 3

sizeFunction · 0.50
DummyClass · 0.50
ResetMethod · 0.45

Tested by

no test coverage detected