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
8dc14337
Commit
8dc14337
authored
Sep 09, 2009
by
Ivan Donchevskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added check for byte size of TableBlockStorage
parent
833a4b73
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
17 deletions
+34
-17
JrnTest.cc
Utilities/JrnTests/JrnTest.cc
+4
-3
Storages.h
include/Storages.h
+3
-3
TableBlockStorage.cc
src/Various/TableBlockStorage.cc
+27
-11
No files found.
Utilities/JrnTests/JrnTest.cc
View file @
8dc14337
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include "UniXML.h"
#include "UniXML.h"
int
seek
=
0
;
int
seek
=
0
;
int
b_size
=
100000
;
void
testTable1
(
void
)
void
testTable1
(
void
)
{
{
...
@@ -79,7 +80,7 @@ bool testTable2(void)
...
@@ -79,7 +80,7 @@ bool testTable2(void)
char
*
val
=
new
char
[
40
];
char
*
val
=
new
char
[
40
];
TableBlockStorage
t
;
TableBlockStorage
t
;
//t = new TableBlockStorage();
//t = new TableBlockStorage();
t
.
create
(
"big_file.test"
,
4
,
40
,
100
,
5
,
28
,
0
);
t
.
create
(
"big_file.test"
,
b_size
,
4
,
40
,
100
,
5
,
28
,
0
);
seek
=
t
.
getByteSize
();
seek
=
t
.
getByteSize
();
printf
(
"Table size in bytes = %d
\n
"
,
seek
);
printf
(
"Table size in bytes = %d
\n
"
,
seek
);
int
i
;
int
i
;
...
@@ -191,7 +192,7 @@ bool testTable2(void)
...
@@ -191,7 +192,7 @@ bool testTable2(void)
return
false
;
return
false
;
}
}
printf
(
"after reopen:
\n
"
);
printf
(
"after reopen:
\n
"
);
t
.
open
(
"big_file.test"
,
4
,
40
,
100
,
5
,
28
,
0
);
t
.
open
(
"big_file.test"
,
b_size
,
4
,
40
,
100
,
5
,
28
,
0
);
for
(
i
=
1
;
i
<
20
;
i
++
)
for
(
i
=
1
;
i
<
20
;
i
++
)
{
{
if
(
t
.
findKeyValue
(
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
if
(
t
.
findKeyValue
(
&
i
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
...
@@ -259,7 +260,7 @@ bool testJournal1(void)
...
@@ -259,7 +260,7 @@ bool testJournal1(void)
k
=
0
;
k
=
0
;
printf
(
"size changed to 33000 rows (increased)
\n
"
);
printf
(
"size changed to 33000 rows (increased)
\n
"
);
j
.
setSize
(
33000
);
j
.
setSize
(
33000
);
TableBlockStorage
t
(
"big_file.test"
,
4
,
40
,
100
,
5
,
28
,
0
);
TableBlockStorage
t
(
"big_file.test"
,
b_size
,
4
,
40
,
100
,
5
,
28
,
0
);
printf
(
"test of 2 classes working in 1 file together
\n
"
);
printf
(
"test of 2 classes working in 1 file together
\n
"
);
char
*
val
=
new
char
[
40
];
char
*
val
=
new
char
[
40
];
for
(
i
=
1
;
i
<
20
;
i
++
)
for
(
i
=
1
;
i
<
20
;
i
++
)
...
...
include/Storages.h
View file @
8dc14337
...
@@ -92,7 +92,7 @@ class TableBlockStorage
...
@@ -92,7 +92,7 @@ class TableBlockStorage
/*! Open, create=true
/*! Open, create=true
*/
*/
TableBlockStorage
(
const
char
*
name
,
int
key_sz
,
int
inf_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
,
bool
create
=
false
);
TableBlockStorage
(
const
char
*
name
,
int
byte_sz
,
int
key_sz
,
int
inf_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
,
bool
create
=
false
);
~
TableBlockStorage
();
~
TableBlockStorage
();
...
@@ -109,8 +109,8 @@ class TableBlockStorage
...
@@ -109,8 +109,8 @@ class TableBlockStorage
sizeof(StorageAttr), - ,
sizeof(StorageAttr), - ,
, getByteSize()
, getByteSize()
*/
*/
bool
open
(
const
char
*
name
,
int
inf_sz
,
int
key_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
);
bool
open
(
const
char
*
name
,
int
byte_sz
,
int
inf_sz
,
int
key_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
);
bool
create
(
const
char
*
name
,
int
inf_sz
,
int
key_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
);
bool
create
(
const
char
*
name
,
int
byte_sz
,
int
inf_sz
,
int
key_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
);
/*! , */
/*! , */
bool
addRow
(
void
*
key
,
void
*
val
);
bool
addRow
(
void
*
key
,
void
*
val
);
...
...
src/Various/TableBlockStorage.cc
View file @
8dc14337
...
@@ -35,13 +35,13 @@ TableBlockStorage::TableBlockStorage()
...
@@ -35,13 +35,13 @@ TableBlockStorage::TableBlockStorage()
file
=
NULL
;
file
=
NULL
;
}
}
TableBlockStorage
::
TableBlockStorage
(
const
char
*
name
,
int
key_sz
,
int
inf_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
,
bool
cr
)
TableBlockStorage
::
TableBlockStorage
(
const
char
*
name
,
int
byte_sz
,
int
key_sz
,
int
inf_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
,
bool
cr
)
{
{
file
=
NULL
;
file
=
NULL
;
if
(
!
open
(
name
,
key_sz
,
inf_sz
,
inf_count
,
block_num
,
block_lim
,
seek
))
if
(
!
open
(
name
,
byte_sz
,
key_sz
,
inf_sz
,
inf_count
,
block_num
,
block_lim
,
seek
))
{
{
if
(
cr
)
if
(
cr
)
create
(
name
,
key_sz
,
inf_sz
,
inf_count
,
block_num
,
block_lim
,
seek
);
create
(
name
,
byte_sz
,
key_sz
,
inf_sz
,
inf_count
,
block_num
,
block_lim
,
seek
);
else
else
file
=
NULL
;
file
=
NULL
;
}
}
...
@@ -115,7 +115,7 @@ bool TableBlockStorage::copyToNextBlock(void)
...
@@ -115,7 +115,7 @@ bool TableBlockStorage::copyToNextBlock(void)
return
true
;
return
true
;
}
}
bool
TableBlockStorage
::
open
(
const
char
*
name
,
int
key_sz
,
int
inf_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
)
bool
TableBlockStorage
::
open
(
const
char
*
name
,
int
byte_sz
,
int
key_sz
,
int
inf_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
)
{
{
/*! , */
/*! , */
if
(
file
!=
NULL
)
fclose
(
file
);
if
(
file
!=
NULL
)
fclose
(
file
);
...
@@ -154,6 +154,13 @@ bool TableBlockStorage::open(const char* name, int key_sz, int inf_sz, int inf_c
...
@@ -154,6 +154,13 @@ bool TableBlockStorage::open(const char* name, int key_sz, int inf_sz, int inf_c
block_size
=
inf_count
;
block_size
=
inf_count
;
size
=
block_size
*
block_num
;
size
=
block_size
*
block_num
;
if
(
byte_sz
<
getByteSize
()
)
{
fclose
(
file
);
file
=
NULL
;
return
false
;
}
max
=-
1
;
max
=-
1
;
/*! */
/*! */
...
@@ -182,16 +189,11 @@ bool TableBlockStorage::open(const char* name, int key_sz, int inf_sz, int inf_c
...
@@ -182,16 +189,11 @@ bool TableBlockStorage::open(const char* name, int key_sz, int inf_sz, int inf_c
return
true
;
return
true
;
}
}
bool
TableBlockStorage
::
create
(
const
char
*
name
,
int
key_sz
,
int
inf_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
)
bool
TableBlockStorage
::
create
(
const
char
*
name
,
int
byte_sz
,
int
key_sz
,
int
inf_sz
,
int
inf_count
,
int
block_num
,
int
block_lim
,
int
seek
)
{
{
if
(
file
!=
NULL
)
fclose
(
file
);
if
(
file
!=
NULL
)
fclose
(
file
);
file
=
fopen
(
name
,
"r+"
);
file
=
fopen
(
name
,
"r+"
);
if
(
file
==
NULL
)
{
FILE
*
f
=
fopen
(
name
,
"w"
);
fclose
(
f
);
file
=
fopen
(
name
,
"r+"
);
}
k_size
=
key_sz
;
k_size
=
key_sz
;
inf_size
=
inf_sz
;
inf_size
=
inf_sz
;
seekpos
=
seek
;
seekpos
=
seek
;
...
@@ -205,6 +207,20 @@ bool TableBlockStorage::create(const char* name, int key_sz, int inf_sz, int inf
...
@@ -205,6 +207,20 @@ bool TableBlockStorage::create(const char* name, int key_sz, int inf_sz, int inf
size
=
block_size
*
block_num
;
size
=
block_size
*
block_num
;
max
=-
1
;
max
=-
1
;
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
;
if
(
fseek
(
file
,
seekpos
,
0
)
==-
1
)
return
false
;
/*! */
/*! */
...
...
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