A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
PartitionedFile.h
Go to the documentation of this file.
1
/*****************************************************************************
2
* *
3
* Copyright 2018 Rice University *
4
* *
5
* Licensed under the Apache License, Version 2.0 (the "License"); *
6
* you may not use this file except in compliance with the License. *
7
* You may obtain a copy of the License at *
8
* *
9
* http://www.apache.org/licenses/LICENSE-2.0 *
10
* *
11
* Unless required by applicable law or agreed to in writing, software *
12
* distributed under the License is distributed on an "AS IS" BASIS, *
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14
* See the License for the specific language governing permissions and *
15
* limitations under the License. *
16
* *
17
*****************************************************************************/
18
#ifndef PARTITIONEDFILE_H
19
#define PARTITIONEDFILE_H
20
21
#include "
PDBFile.h
"
22
#include "
PartitionedFileMetaData.h
"
23
#include "
SharedMem.h
"
24
#include <string>
25
#include <vector>
26
#include <memory>
27
using namespace
std;
28
class
PartitionedFile
;
29
typedef
shared_ptr<PartitionedFile>
PartitionedFilePtr
;
30
69
class
PartitionedFile
:
public
PDBFileInterface
{
70
public
:
74
PartitionedFile
(
NodeID
nodeId,
75
DatabaseID
dbId,
76
UserTypeID
typeId,
77
SetID
setId,
78
string
metaPartitionPath,
79
vector<string> dataPartitionPaths,
80
pdb::PDBLoggerPtr
logger,
81
size_t
pageSize);
82
86
PartitionedFile
(
NodeID
nodeId,
87
DatabaseID
dbId,
88
UserTypeID
typeId,
89
SetID
setId,
90
string
metaPartitionPath,
91
pdb::PDBLoggerPtr
logger);
92
96
~
PartitionedFile
();
97
101
bool
openAll()
override
;
102
106
bool
openMeta();
107
111
bool
openData();
112
116
bool
openDataDirect();
117
121
bool
closeAll()
override
;
122
126
bool
closeDirect();
127
131
void
clear()
override
;
132
137
int
appendPage(
FilePartitionID
partitionId,
PDBPagePtr
page)
override
;
138
142
int
appendPageDirect(
FilePartitionID
partitionId,
PDBPagePtr
page);
143
147
int
writeMeta()
override
;
148
149
153
int
updateMeta()
override
;
154
164
size_t
loadPage(
FilePartitionID
partitionId,
165
unsigned
int
pageSeqInPartition,
166
char
* pageInCache,
167
size_t
length)
override
;
168
172
size_t
loadPageDirect(
FilePartitionID
partitionId,
173
unsigned
int
pageSeqInPartition,
174
char
* pageInCache,
175
size_t
length);
176
177
183
size_t
loadPageFromCurPos(
FilePartitionID
partitionId,
184
unsigned
int
pageSeqInPartition,
185
char
* pageInCache,
186
size_t
length);
187
192
PageID
loadPageId(
FilePartitionID
partitionId,
unsigned
int
pageSeqInPartition);
193
199
PageID
loadPageIdFromCurPos(
FilePartitionID
partitionId,
200
unsigned
int
pageSeqInPartition,
201
char
* pageInCache,
202
size_t
length);
203
204
210
unsigned
int
getAndSetNumFlushedPages()
override
;
211
215
unsigned
int
getNumFlushedPages()
override
;
216
220
PageID
getLastFlushedPageID()
override
;
221
225
PageID
getLatestPageID()
override
;
226
230
NodeID
getNodeId()
override
;
231
235
DatabaseID
getDbId()
override
;
236
240
UserTypeID
getTypeId()
override
;
241
245
SetID
getSetId()
override
;
246
250
size_t
getPageSize()
override
;
251
255
size_t
getPageSizeInMeta()
override
;
256
260
FileType
getFileType()
override
;
261
265
PartitionedFileMetaDataPtr
getMetaData();
266
270
void
initializeDataFiles();
271
275
void
setDataPartitionPaths(
const
vector<string>& dataPartitionPaths);
276
280
void
buildMetaDataFromMetaPartition(
SharedMemPtr
shm);
281
285
unsigned
int
getNumPartitions();
286
287
protected
:
291
int
writeData(FILE* file,
void
* data,
size_t
length);
292
296
int
writeDataDirect(
int
handle,
void
* data,
size_t
length);
297
301
int
seekPage(FILE* file,
unsigned
int
pageSeqInPartition);
302
306
int
seekPageDirect(
int
handle,
unsigned
int
pageSeqInPartition);
307
311
int
seekPageSizeInMeta();
312
316
int
seekNumFlushedPagesInMeta();
317
321
int
seekNumFlushedPagesInPartitionMeta(
FilePartitionID
partitionId);
322
323
324
private
:
328
pthread_mutex_t
fileMutex
;
329
330
334
FILE* metaFile =
nullptr
;
335
// int metaHandle;
336
340
vector<FILE*>
dataFiles
;
341
vector<int>
dataHandles
;
342
346
string
metaPartitionPath
;
347
351
vector<string>
dataPartitionPaths
;
352
356
pdb::PDBLoggerPtr
logger =
nullptr
;
357
361
PartitionedFileMetaDataPtr
metaData =
nullptr
;
362
366
NodeID
nodeId
;
367
371
DatabaseID
dbId
;
372
376
UserTypeID
typeId
;
377
381
SetID
setId
;
382
386
size_t
pageSize = 0;
387
391
bool
usingDirect
;
392
396
bool
cleared
;
397
};
398
399
400
#endif
/* PARTITIONEDFILE_H */
PartitionedFile::dataPartitionPaths
vector< string > dataPartitionPaths
Definition:
PartitionedFile.h:351
SetID
unsigned int SetID
Definition:
DataTypes.h:31
PDBPagePtr
shared_ptr< PDBPage > PDBPagePtr
Definition:
PDBPage.h:32
PartitionedFile::dataFiles
vector< FILE * > dataFiles
Definition:
PartitionedFile.h:340
FileType
FileType
Definition:
DataTypes.h:72
PartitionedFile::dataHandles
vector< int > dataHandles
Definition:
PartitionedFile.h:341
NodeID
unsigned int NodeID
Definition:
DataTypes.h:27
PartitionedFile::typeId
UserTypeID typeId
Definition:
PartitionedFile.h:376
PartitionedFilePtr
shared_ptr< PartitionedFile > PartitionedFilePtr
Definition:
PartitionedFile.h:28
SharedMemPtr
shared_ptr< SharedMem > SharedMemPtr
Definition:
SharedMem.h:32
PartitionedFile::cleared
bool cleared
Definition:
PartitionedFile.h:396
SharedMem.h
DatabaseID
unsigned int DatabaseID
Definition:
DataTypes.h:29
PartitionedFile::dbId
DatabaseID dbId
Definition:
PartitionedFile.h:371
PageID
unsigned int PageID
Definition:
DataTypes.h:26
PartitionedFile::fileMutex
pthread_mutex_t fileMutex
Definition:
PartitionedFile.h:328
PDBFileInterface
Definition:
PDBFile.h:36
PartitionedFile::nodeId
NodeID nodeId
Definition:
PartitionedFile.h:366
PartitionedFileMetaData.h
PartitionedFile::usingDirect
bool usingDirect
Definition:
PartitionedFile.h:391
PartitionedFile::setId
SetID setId
Definition:
PartitionedFile.h:381
PartitionedFile::metaPartitionPath
string metaPartitionPath
Definition:
PartitionedFile.h:346
PartitionedFileMetaDataPtr
shared_ptr< PartitionedFileMetaData > PartitionedFileMetaDataPtr
Definition:
PartitionedFileMetaData.h:37
pdb::PDBLoggerPtr
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition:
PDBLogger.h:40
PDBFile.h
PartitionedFile
Definition:
PartitionedFile.h:69
FilePartitionID
unsigned int FilePartitionID
Definition:
DataTypes.h:32
UserTypeID
unsigned int UserTypeID
Definition:
DataTypes.h:25
plinycompute
pdb
src
storage
headers
PartitionedFile.h
Generated on Mon Jun 18 2018 18:10:36 by
1.8.6