Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
b35b5401
Commit
b35b5401
authored
6 years ago
by
Danilo Piparo
Browse files
Options
Downloads
Patches
Plain Diff
[IO] Allow to set the size of the memory blocks
parent
aaa1c34b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
io/io/inc/TMemFile.h
+4
-2
4 additions, 2 deletions
io/io/inc/TMemFile.h
io/io/src/TMemFile.cxx
+21
-18
21 additions, 18 deletions
io/io/src/TMemFile.cxx
with
25 additions
and
20 deletions
io/io/inc/TMemFile.h
+
4
−
2
View file @
b35b5401
...
@@ -45,7 +45,8 @@ private:
...
@@ -45,7 +45,8 @@ private:
TMemBlock
*
fBlockSeek
;
///< Pointer to the block we seeked to.
TMemBlock
*
fBlockSeek
;
///< Pointer to the block we seeked to.
Long64_t
fBlockOffset
;
///< Seek offset within the block
Long64_t
fBlockOffset
;
///< Seek offset within the block
static
Long64_t
fgDefaultBlockSize
;
constexpr
static
Long64_t
fgDefaultBlockSize
=
2
*
1024
*
1024
;
Long64_t
fDefaultBlockSize
=
fgDefaultBlockSize
;
Long64_t
MemRead
(
Int_t
fd
,
void
*
buf
,
Long64_t
len
)
const
;
Long64_t
MemRead
(
Int_t
fd
,
void
*
buf
,
Long64_t
len
)
const
;
...
@@ -77,7 +78,8 @@ private:
...
@@ -77,7 +78,8 @@ private:
TMemFile
&
operator
=
(
const
TMemFile
&
);
// Not implemented.
TMemFile
&
operator
=
(
const
TMemFile
&
);
// Not implemented.
public
:
public
:
TMemFile
(
const
char
*
name
,
Option_t
*
option
=
""
,
const
char
*
ftitle
=
""
,
Int_t
compress
=
ROOT
::
RCompressionSetting
::
EDefaults
::
kUseGeneralPurpose
);
TMemFile
(
const
char
*
name
,
Option_t
*
option
=
""
,
const
char
*
ftitle
=
""
,
Int_t
compress
=
ROOT
::
RCompressionSetting
::
EDefaults
::
kUseGeneralPurpose
,
Long64_t
defBlockSize
=
0LL
);
TMemFile
(
const
char
*
name
,
char
*
buffer
,
Long64_t
size
,
Option_t
*
option
=
""
,
const
char
*
ftitle
=
""
,
Int_t
compress
=
ROOT
::
RCompressionSetting
::
EDefaults
::
kUseGeneralPurpose
);
TMemFile
(
const
char
*
name
,
char
*
buffer
,
Long64_t
size
,
Option_t
*
option
=
""
,
const
char
*
ftitle
=
""
,
Int_t
compress
=
ROOT
::
RCompressionSetting
::
EDefaults
::
kUseGeneralPurpose
);
TMemFile
(
const
char
*
name
,
ExternalDataPtr_t
data
);
TMemFile
(
const
char
*
name
,
ExternalDataPtr_t
data
);
TMemFile
(
const
TMemFile
&
orig
);
TMemFile
(
const
TMemFile
&
orig
);
...
...
This diff is collapsed.
Click to expand it.
io/io/src/TMemFile.cxx
+
21
−
18
View file @
b35b5401
...
@@ -40,8 +40,6 @@ only from memory.
...
@@ -40,8 +40,6 @@ only from memory.
ClassImp
(
TMemFile
);
ClassImp
(
TMemFile
);
Long64_t
TMemFile
::
fgDefaultBlockSize
=
2
*
1024
*
1024
;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// Default constructor.
/// Default constructor.
...
@@ -137,19 +135,24 @@ TMemFile::TMemFile(const char *path, ExternalDataPtr_t data) :
...
@@ -137,19 +135,24 @@ TMemFile::TMemFile(const char *path, ExternalDataPtr_t data) :
}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// Usual Constructor. See the TFile constructor for details.
/// \brief Usual Constructor.
/// The defBlockSize parameter defines the size of the blocks of memory allocated
TMemFile
::
TMemFile
(
const
char
*
path
,
Option_t
*
option
,
/// when expanding the underlying TMemFileBuffer. If the value 0 is passed, the
const
char
*
ftitle
,
Int_t
compress
)
:
/// default block size, fgDefaultBlockSize, is adopted.
TMemFile
(
path
,
nullptr
,
-
1
,
option
,
ftitle
,
compress
)
{}
/// See the TFile constructor for details.
TMemFile
::
TMemFile
(
const
char
*
path
,
Option_t
*
option
,
const
char
*
ftitle
,
Int_t
compress
,
Long64_t
defBlockSize
)
:
TMemFile
(
path
,
nullptr
,
-
1
,
option
,
ftitle
,
compress
)
{
fDefaultBlockSize
=
defBlockSize
==
0LL
?
fgDefaultBlockSize
:
defBlockSize
;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// Usual Constructor. See the TFile constructor for details. Copy data from buffer.
/// Usual Constructor. See the TFile constructor for details. Copy data from buffer.
TMemFile
::
TMemFile
(
const
char
*
path
,
char
*
buffer
,
Long64_t
size
,
Option_t
*
option
,
TMemFile
::
TMemFile
(
const
char
*
path
,
char
*
buffer
,
Long64_t
size
,
Option_t
*
option
,
const
char
*
ftitle
,
Int_t
compress
)
const
char
*
ftitle
,
Int_t
compress
)
:
:
TFile
(
path
,
"WEB"
,
ftitle
,
compress
),
fBlockList
(
size
),
fSize
(
size
),
fSysOffset
(
0
),
fBlockSeek
(
&
(
fBlockList
)),
TFile
(
path
,
"WEB"
,
ftitle
,
compress
),
fBlockList
(
size
),
fBlockOffset
(
0
)
fSize
(
size
),
fSysOffset
(
0
),
fBlockSeek
(
&
(
fBlockList
)),
fBlockOffset
(
0
)
{
{
EMode
optmode
=
ParseOption
(
option
);
EMode
optmode
=
ParseOption
(
option
);
...
@@ -551,9 +554,9 @@ Long64_t TMemFile::SysSeek(Int_t, Long64_t offset, Int_t whence)
...
@@ -551,9 +554,9 @@ Long64_t TMemFile::SysSeek(Int_t, Long64_t offset, Int_t whence)
Int_t
TMemFile
::
SysOpen
(
const
char
*
/* pathname */
,
Int_t
/* flags */
,
UInt_t
/* mode */
)
Int_t
TMemFile
::
SysOpen
(
const
char
*
/* pathname */
,
Int_t
/* flags */
,
UInt_t
/* mode */
)
{
{
if
(
!
fBlockList
.
fBuffer
)
{
if
(
!
fBlockList
.
fBuffer
)
{
fBlockList
.
fBuffer
=
new
UChar_t
[
f
g
DefaultBlockSize
];
fBlockList
.
fBuffer
=
new
UChar_t
[
fDefaultBlockSize
];
fBlockList
.
fSize
=
f
g
DefaultBlockSize
;
fBlockList
.
fSize
=
fDefaultBlockSize
;
fSize
=
f
g
DefaultBlockSize
;
fSize
=
fDefaultBlockSize
;
}
}
if
(
fBlockList
.
fBuffer
)
{
if
(
fBlockList
.
fBuffer
)
{
return
0
;
return
0
;
...
@@ -604,8 +607,8 @@ Int_t TMemFile::SysWriteImpl(Int_t /* fd */, const void *buf, Long64_t len)
...
@@ -604,8 +607,8 @@ Int_t TMemFile::SysWriteImpl(Int_t /* fd */, const void *buf, Long64_t len)
buf
=
(
char
*
)
buf
+
sublen
;
buf
=
(
char
*
)
buf
+
sublen
;
Int_t
len_left
=
len
-
sublen
;
Int_t
len_left
=
len
-
sublen
;
if
(
!
fBlockSeek
->
fNext
)
{
if
(
!
fBlockSeek
->
fNext
)
{
fBlockSeek
->
CreateNext
(
f
g
DefaultBlockSize
);
fBlockSeek
->
CreateNext
(
fDefaultBlockSize
);
fSize
+=
f
g
DefaultBlockSize
;
fSize
+=
fDefaultBlockSize
;
}
}
fBlockSeek
=
fBlockSeek
->
fNext
;
fBlockSeek
=
fBlockSeek
->
fNext
;
...
@@ -617,8 +620,8 @@ Int_t TMemFile::SysWriteImpl(Int_t /* fd */, const void *buf, Long64_t len)
...
@@ -617,8 +620,8 @@ Int_t TMemFile::SysWriteImpl(Int_t /* fd */, const void *buf, Long64_t len)
buf
=
(
char
*
)
buf
+
fBlockSeek
->
fSize
;
buf
=
(
char
*
)
buf
+
fBlockSeek
->
fSize
;
len_left
-=
fBlockSeek
->
fSize
;
len_left
-=
fBlockSeek
->
fSize
;
if
(
!
fBlockSeek
->
fNext
)
{
if
(
!
fBlockSeek
->
fNext
)
{
fBlockSeek
->
CreateNext
(
f
g
DefaultBlockSize
);
fBlockSeek
->
CreateNext
(
fDefaultBlockSize
);
fSize
+=
f
g
DefaultBlockSize
;
fSize
+=
fDefaultBlockSize
;
}
}
fBlockSeek
=
fBlockSeek
->
fNext
;
fBlockSeek
=
fBlockSeek
->
fNext
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment