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
FileSet.cc
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 FILESET_CC
19
#define FILESET_CC
20
21
#include "
FileSet.h
"
22
#include "
FileSetPageIterator.h
"
23
#include <stdio.h>
24
#include <string>
25
#include <cstring>
26
#include <fcntl.h>
27
#include <iostream>
28
#include <fstream>
29
#include <stdlib.h>
30
#include <sys/stat.h>
31
#include <sys/types.h>
32
#include <unistd.h>
33
#include <sys/stat.h>
34
35
FileSet::FileSet
(
PageCachePtr
cache,
36
string
filePath,
37
size_t
pageSize,
38
NodeID
nodeId,
39
DatabaseID
dbId,
40
UserTypeID
typeId,
41
SetID
setId)
42
:
LocalitySet
(
PartialAggregationData
,
MRU
,
Write
,
TryCache
,
Transient
) {
43
this->cache =
cache
;
44
this->filePath =
filePath
;
45
this->pageSize =
pageSize
;
46
this->
fileSize
= 0;
47
this->nodeId =
nodeId
;
48
this->dbId =
dbId
;
49
this->typeId =
typeId
;
50
this->setId =
setId
;
51
#ifdef __APPLE__
52
this->
handle
= open(filePath.c_str(), O_RDWR | O_APPEND | O_CREAT, S_IRWXU | S_IRWXO);
53
#else
54
this->
handle
=
55
open(filePath.c_str(), O_RDWR | O_APPEND | O_CREAT | O_DIRECT, S_IRWXU | S_IRWXO);
56
#endif
57
if
(handle < 0) {
58
cout <<
"file can't be open:"
<< this->filePath <<
"\n"
;
59
exit(-1);
60
}
61
}
62
63
FileSet::~FileSet
() {
64
if
(this->
handle
>= 0) {
65
this->
clear
();
66
}
67
}
68
69
void
FileSet::clear
() {
70
close(this->
handle
);
71
this->
handle
= -1;
72
remove
(this->
filePath
.c_str());
73
}
74
75
int
FileSet::writeData
(
void
* data,
size_t
length) {
76
size_t
retSize = write(this->
handle
, data, length);
77
if
(retSize < length) {
78
return
-1;
79
}
else
{
80
this->
fileSize
= this->
fileSize
+ length;
81
return
0;
82
}
83
}
84
85
PageIteratorPtr
FileSet::getIterator
() {
86
PageIteratorPtr
iter = make_shared<FileSetPageIterator>(this->
cache
,
87
this->
handle
,
88
this->
fileSize
,
89
this->
pageSize
,
90
this->
nodeId
,
91
this->
dbId
,
92
this->
typeId
,
93
this->
setId
);
94
return
iter;
95
}
96
#endif
FileSet::~FileSet
~FileSet()
Definition:
FileSet.cc:63
SetID
unsigned int SetID
Definition:
DataTypes.h:31
FileSet::FileSet
FileSet(PageCachePtr cache, string filePath, size_t pageSize, NodeID nodeId, DatabaseID dbId, UserTypeID typeId, SetID setId)
Definition:
FileSet.cc:35
FileSet::nodeId
NodeID nodeId
Definition:
FileSet.h:71
PartialAggregationData
Definition:
DataTypes.h:50
Transient
Definition:
DataTypes.h:68
PageCachePtr
shared_ptr< PageCache > PageCachePtr
Definition:
PageCache.h:39
TryCache
Definition:
DataTypes.h:59
PageIteratorPtr
shared_ptr< PageIteratorInterface > PageIteratorPtr
Definition:
PageIterator.h:33
NodeID
unsigned int NodeID
Definition:
DataTypes.h:27
FileSetPageIterator.h
LocalitySet
Definition:
LocalitySet.h:36
FileSet::cache
PageCachePtr cache
Definition:
FileSet.h:68
MRU
Definition:
DataTypes.h:52
FileSet.h
DatabaseID
unsigned int DatabaseID
Definition:
DataTypes.h:29
FileSet::writeData
int writeData(void *data, size_t length)
Definition:
FileSet.cc:75
FileSet::filePath
string filePath
Definition:
FileSet.h:66
FileSet::dbId
DatabaseID dbId
Definition:
FileSet.h:72
FileSet::typeId
UserTypeID typeId
Definition:
FileSet.h:73
FileSet::clear
void clear()
Definition:
FileSet.cc:69
FileSet::pageSize
size_t pageSize
Definition:
FileSet.h:69
FileSet::handle
int handle
Definition:
FileSet.h:67
FileSet::setId
SetID setId
Definition:
FileSet.h:74
FileSet::fileSize
size_t fileSize
Definition:
FileSet.h:70
FileSet::getIterator
PageIteratorPtr getIterator()
Definition:
FileSet.cc:85
UserTypeID
unsigned int UserTypeID
Definition:
DataTypes.h:25
Write
Definition:
DataTypes.h:57
plinycompute
pdb
src
storage
source
FileSet.cc
Generated on Mon Jun 18 2018 18:10:36 by
1.8.6