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
b26d06b3
Commit
b26d06b3
authored
Sep 14, 2009
by
Pavel Vaynerman
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.eter:/projects/uniset
parents
180c78b0
15d30799
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
29 deletions
+37
-29
JrnTest.cc
Utilities/JrnTests/JrnTest.cc
+6
-6
Storages.h
include/Storages.h
+3
-3
CycleStorage.cc
src/Various/CycleStorage.cc
+28
-20
No files found.
Utilities/JrnTests/JrnTest.cc
View file @
b26d06b3
...
...
@@ -33,7 +33,7 @@
int
seek
=
0
;
int
b_size
=
100000
;
int
bj_size
=
1300000
;
void
testTable1
(
void
)
{
char
*
chr
=
new
char
[
20
];
...
...
@@ -212,7 +212,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
,
33000
,
seek
))
if
(
!
j
.
open
(
"big_file.test"
,
bj_size
,
30
,
33000
,
seek
))
{
printf
(
"Reopen file error
\n
"
);
delete
str
;
...
...
@@ -234,7 +234,7 @@ bool reOpen()
bool
testJournal1
(
void
)
{
CycleStorage
j
(
"big_file.test"
,
30
,
32000
,
seek
,
true
);
CycleStorage
j
(
"big_file.test"
,
bj_size
,
30
,
32000
,
seek
,
true
);
int
i
,
k
=
0
;
char
*
str
=
new
char
[
30
];
printf
(
"journal test 1
\n
"
);
...
...
@@ -344,7 +344,7 @@ bool testJournal1(void)
void
testJournal2
(
void
)
{
CycleStorage
j
(
"big_file.test"
,
30
,
32000
,
seek
);
CycleStorage
j
(
"big_file.test"
,
bj_size
,
30
,
32000
,
seek
);
int
i
,
k
;
char
*
str
=
new
char
[
30
];
printf
(
"journal test 2 - checking number of iterations to find head/tail
\n
"
);
...
...
@@ -356,7 +356,7 @@ void testJournal2(void)
sprintf
(
str
,
"%d"
,
k
);
j
.
addRow
(
str
);
}
j
.
open
(
"big_file.test"
,
30
,
32000
,
seek
);
j
.
open
(
"big_file.test"
,
bj_size
,
30
,
32000
,
seek
);
printf
(
"i=%d, iterations = %d
\n
"
,
i
,
j
.
getIter
());
}
printf
(
"
\n
"
);
...
...
@@ -372,7 +372,7 @@ struct JItem
bool
testJournal3
()
{
CycleStorage
j
(
"journal3.test"
,
sizeof
(
JItem
),
10
,
0
,
true
);
CycleStorage
j
(
"journal3.test"
,
bj_size
,
sizeof
(
JItem
),
10
,
0
,
true
);
if
(
!
j
.
isOpen
()
)
{
printf
(
"create journal3.test failed
\n
"
);
...
...
include/Storages.h
View file @
b26d06b3
...
...
@@ -150,7 +150,7 @@ class CycleStorage
/*! Open, create=true
*/
CycleStorage
(
const
char
*
name
,
int
inf_sz
,
int
inf_count
,
int
seek
,
bool
create
=
false
);
CycleStorage
(
const
char
*
name
,
int
byte_sz
,
int
inf_sz
,
int
inf_count
,
int
seek
,
bool
create
=
false
);
~
CycleStorage
();
...
...
@@ -163,8 +163,8 @@ class CycleStorage
-
, getByteSize()
*/
bool
open
(
const
char
*
name
,
int
inf_sz
,
int
inf_count
,
int
seek
);
bool
create
(
const
char
*
name
,
int
inf_sz
,
int
inf_count
,
int
seek
);
bool
open
(
const
char
*
name
,
int
byte_sz
,
int
inf_sz
,
int
inf_count
,
int
seek
);
bool
create
(
const
char
*
name
,
int
byte_sz
,
int
inf_sz
,
int
inf_count
,
int
seek
);
bool
isOpen
(){
return
(
file
!=
NULL
);
}
...
...
src/Various/CycleStorage.cc
View file @
b26d06b3
...
...
@@ -35,13 +35,13 @@ CycleStorage::CycleStorage()
file
=
NULL
;
}
CycleStorage
::
CycleStorage
(
const
char
*
name
,
int
inf_sz
,
int
inf_count
,
int
seek
,
bool
cr
)
:
CycleStorage
::
CycleStorage
(
const
char
*
name
,
int
byte_sz
,
int
inf_sz
,
int
inf_count
,
int
seek
,
bool
cr
)
:
file
(
NULL
)
{
if
(
!
open
(
name
,
inf_sz
,
inf_count
,
seek
))
if
(
!
open
(
name
,
byte_sz
,
inf_sz
,
inf_count
,
seek
))
{
if
(
cr
)
create
(
name
,
inf_sz
,
inf_count
,
seek
);
create
(
name
,
byte_sz
,
inf_sz
,
inf_count
,
seek
);
}
}
...
...
@@ -138,17 +138,17 @@ bool CycleStorage::findHead()
return
true
;
}
bool
CycleStorage
::
open
(
const
char
*
name
,
int
inf_sz
,
int
inf_count
,
int
seek
)
bool
CycleStorage
::
open
(
const
char
*
name
,
int
byte_sz
,
int
inf_sz
,
int
inf_count
,
int
seek
)
{
/*! ,
*/
if
(
file
!=
NULL
)
if
(
file
!=
NULL
)
fclose
(
file
);
file
=
fopen
(
name
,
"r+"
);
if
(
file
==
NULL
)
return
false
;
if
(
file
==
NULL
)
return
false
;
if
(
fseek
(
file
,
seek
,
0
)
==-
1
)
if
(
fseek
(
file
,
seek
,
0
)
==-
1
)
{
fclose
(
file
);
file
=
NULL
;
...
...
@@ -157,10 +157,10 @@ bool CycleStorage::open(const char* name, int inf_sz, int inf_count, int seek)
/*! */
CycleStorageAttr
csa
;
fread
(
&
csa
,
sizeof
(
csa
),
1
,
file
);
fread
(
&
csa
,
sizeof
(
csa
),
1
,
file
);
/*! */
if
(
(
csa
.
size
!=
inf_count
)
||
(
csa
.
inf_size
!=
inf_sz
)
||
(
csa
.
seekpos
!=
seek
)
)
if
(
(
csa
.
size
!=
inf_count
)
||
(
csa
.
inf_size
!=
inf_sz
)
||
(
csa
.
seekpos
!=
seek
)
)
{
fclose
(
file
);
file
=
NULL
;
...
...
@@ -171,27 +171,19 @@ bool CycleStorage::open(const char* name, int inf_sz, int inf_count, int seek)
size
=
inf_count
;
seekpos
=
seek
+
sizeof
(
CycleStorageAttr
);
if
(
!
findHead
()
)
if
(
(
byte_sz
<
getByteSize
()
)
||
!
findHead
()
)
{
fclose
(
file
);
file
=
NULL
;
file
=
NULL
;
return
false
;
}
return
true
;
}
bool
CycleStorage
::
create
(
const
char
*
name
,
int
inf_sz
,
int
inf_count
,
int
seek
)
bool
CycleStorage
::
create
(
const
char
*
name
,
int
byte_sz
,
int
inf_sz
,
int
inf_count
,
int
seek
)
{
if
(
file
!=
NULL
)
fclose
(
file
);
file
=
fopen
(
name
,
"r+"
);
/*! , */
if
(
file
==
NULL
)
{
FILE
*
f
=
fopen
(
name
,
"w"
);
fclose
(
f
);
file
=
fopen
(
name
,
"r+"
);
}
inf_size
=
inf_sz
;
full_size
=
sizeof
(
CycleStorageElem
)
+
inf_size
;
...
...
@@ -200,6 +192,22 @@ bool CycleStorage::create(const char* name, int inf_sz, int inf_count, int seek)
iter
=
0
;
seekpos
=
seek
;
if
(
byte_sz
<
getByteSize
()
)
{
if
(
file
!=
NULL
)
fclose
(
file
);
file
=
NULL
;
return
false
;
}
/*! , */
if
(
file
==
NULL
)
{
FILE
*
f
=
fopen
(
name
,
"w"
);
fclose
(
f
);
file
=
fopen
(
name
,
"r+"
);
}
if
(
fseek
(
file
,
seekpos
,
0
)
==-
1
)
return
false
;
CycleStorageElem
*
jrn
=
(
CycleStorageElem
*
)
new
char
[
full_size
];
...
...
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