Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
6e74886d
Commit
6e74886d
authored
Aug 14, 2009
by
Ivan Donchevskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
function setSize in CycleStorage and few changes in JrnTest to test it
parent
f2377dd4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
5 deletions
+89
-5
JrnTest.cc
Utilities/JrnTests/JrnTest.cc
+18
-4
Storages.h
include/Storages.h
+3
-0
CycleStorage.cc
src/Various/CycleStorage.cc
+68
-1
No files found.
Utilities/JrnTests/JrnTest.cc
View file @
6e74886d
...
...
@@ -211,7 +211,7 @@ bool reOpen()
int
i
,
k
=
0
;
char
*
str
=
new
char
[
30
];
printf
(
"the same after reopen:
\n
"
);
if
(
!
j
.
open
(
"big_file.test"
,
30
,
3
2
000
,
seek
))
if
(
!
j
.
open
(
"big_file.test"
,
30
,
3
3
000
,
seek
))
{
printf
(
"Reopen file error
\n
"
);
delete
str
;
...
...
@@ -237,7 +237,7 @@ bool testJournal1(void)
int
i
,
k
=
0
;
char
*
str
=
new
char
[
30
];
printf
(
"journal test 1
\n
"
);
for
(
i
=
1
;
i
<
33000
;
i
++
)
for
(
i
=
1
;
i
<
64001
;
i
++
)
{
sprintf
(
str
,
"%d"
,
i
);
j
.
addRow
(
str
);
...
...
@@ -257,7 +257,7 @@ bool testJournal1(void)
return
false
;
}
k
=
0
;
j
.
setSize
(
33000
);
TableBlockStorage
t
(
"big_file.test"
,
4
,
40
,
100
,
5
,
28
,
0
);
printf
(
"test of 2 classes working in 1 file together
\n
"
);
char
*
val
=
new
char
[
40
];
...
...
@@ -294,7 +294,7 @@ bool testJournal1(void)
k
=
0
;
printf
(
"first 20 after adding 10 elements
\n
"
);
for
(
i
=
1000
1
;
i
<
1
0011
;
i
++
)
for
(
i
=
1000
0001
;
i
<
1000
0011
;
i
++
)
{
sprintf
(
str
,
"%d"
,
i
);
j
.
addRow
(
str
);
...
...
@@ -319,6 +319,20 @@ bool testJournal1(void)
if
(
!
reOpen
())
return
false
;
j
.
setSize
(
32000
);
for
(
i
=
0
;
i
<
32000
;
i
++
)
{
if
(
j
.
readRow
(
i
,
str
))
{
printf
(
"%s
\n
"
,
str
);
k
++
;
}
}
if
(
k
>
0
)
{
delete
str
;
return
false
;
}
delete
str
;
return
true
;
}
...
...
include/Storages.h
View file @
6e74886d
...
...
@@ -183,6 +183,9 @@ class CycleStorage
/*! - / ( ) */
int
getIter
(
void
);
/*! ( ) */
bool
setSize
(
int
count
);
inline
int
getByteSize
()
{
return
(
size
*
full_size
+
sizeof
(
CycleStorageAttr
));
}
inline
int
getSize
(){
return
size
;
}
inline
int
getInfSize
(){
return
inf_size
;
}
...
...
src/Various/CycleStorage.cc
View file @
6e74886d
...
...
@@ -365,7 +365,7 @@ void* CycleStorage::readRow(int num, void* str)
int
j
=
(
head
+
num
)
%
size
;
if
((
file
==
NULL
)
||
(
num
>=
size
))
return
0
;
if
((
head
!=
tail
+
1
)
&&
(
num
>
tail
))
return
0
;
if
((
head
!=
tail
+
1
)
&&
(
num
>
tail
)
&&
(
head
!=
tail
)
)
return
0
;
CycleStorageElem
*
jrn
=
(
CycleStorageElem
*
)
new
char
[
full_size
];
fseek
(
file
,
seekpos
+
j
*
full_size
,
0
);
...
...
@@ -385,3 +385,70 @@ int CycleStorage::getIter()
{
return
iter
;
}
/*! . , .
, , . , . .
, */
bool
CycleStorage
::
setSize
(
int
count
)
{
if
(
file
==
NULL
)
return
false
;
if
(
count
==
size
)
return
true
;
fseek
(
file
,
seekpos
-
sizeof
(
CycleStorageAttr
),
0
);
/*! */
CycleStorageAttr
csa
;
csa
.
inf_size
=
inf_size
;
csa
.
size
=
count
;
csa
.
seekpos
=
seekpos
-
sizeof
(
CycleStorageAttr
);
fwrite
(
&
csa
,
sizeof
(
CycleStorageAttr
),
1
,
file
);
fflush
(
file
);
if
(
count
<
size
)
{
size
=
count
;
return
delAllRows
();
}
int
num
=
count
-
size
;
size
=
count
;
CycleStorageElem
*
jrn
=
(
CycleStorageElem
*
)
new
char
[
full_size
];
if
((
head
==
tail
+
1
)
||
((
tail
==
size
-
num
-
1
)
&&
(
head
==
0
)))
{
if
(
head
<
size
-
num
-
1
)
fseek
(
file
,
seekpos
+
(
size
-
num
-
1
)
*
full_size
,
0
);
else
fseek
(
file
,
seekpos
,
0
);
fread
(
jrn
,
full_size
,
1
,
file
);
if
((
jrn
->
status
==
2
)
||
(
jrn
->
status
==
3
))
jrn
->
status
=
(
head
<
size
-
num
-
1
)
?
3
:
5
;
else
if
((
jrn
->
status
==
4
)
||
(
jrn
->
status
==
5
))
jrn
->
status
=
(
head
<
size
-
num
-
1
)
?
5
:
3
;
else
{
delete
[]
jrn
;
return
false
;
}
for
(
int
i
=
num
;
i
>
0
;
i
--
)
{
filewrite
(
jrn
,
size
-
i
,
false
);
}
fflush
(
file
);
if
(
head
==
0
)
tail
=
size
-
1
;
}
else
{
jrn
->
status
=
0
;
for
(
int
i
=
num
;
i
>
0
;
i
--
)
filewrite
(
jrn
,
size
-
i
,
false
);
fflush
(
file
);
}
delete
[]
jrn
;
return
true
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment