Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
95364736
Commit
95364736
authored
Jan 19, 2005
by
joreland@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ndb - HugoCalculator, faster string generation
parent
d96c622c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
30 deletions
+56
-30
ndb/test/src/HugoCalculator.cpp
ndb/test/src/HugoCalculator.cpp
+56
-30
No files found.
ndb/test/src/HugoCalculator.cpp
View file @
95364736
...
@@ -18,6 +18,22 @@
...
@@ -18,6 +18,22 @@
#include <NDBT.hpp>
#include <NDBT.hpp>
#include <Base64.hpp>
#include <Base64.hpp>
static
Uint32
myRand
(
Uint64
*
seed
)
{
const
Uint64
mul
=
0x5deece66dull
;
const
Uint64
add
=
0xb
;
Uint64
loc_result
=
*
seed
*
mul
+
add
;
*
seed
=
loc_result
;
return
loc_result
>>
1
;
}
static
char
base64_table
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/"
;
/* *************************************************************
/* *************************************************************
* HugoCalculator
* HugoCalculator
*
*
...
@@ -79,21 +95,23 @@ HugoCalculator::calcValue(int record,
...
@@ -79,21 +95,23 @@ HugoCalculator::calcValue(int record,
int
updates
,
int
updates
,
char
*
buf
,
char
*
buf
,
int
len
)
const
{
int
len
)
const
{
unsigned
seed
;
Uint64
seed
;
const
NdbDictionary
::
Column
*
attr
=
m_tab
.
getColumn
(
attrib
);
const
NdbDictionary
::
Column
*
attr
=
m_tab
.
getColumn
(
attrib
);
Uint32
val
;
Uint32
val
;
do
do
{
{
if
(
attrib
==
m_idCol
)
if
(
attrib
==
m_idCol
)
{
{
*
((
Uint32
*
)
buf
)
=
record
;
val
=
record
;
memcpy
(
buf
,
&
val
,
4
);
return
buf
;
return
buf
;
}
}
// If this is the update column
// If this is the update column
if
(
attrib
==
m_updatesCol
)
if
(
attrib
==
m_updatesCol
)
{
{
*
((
Uint32
*
)
buf
)
=
updates
;
val
=
updates
;
memcpy
(
buf
,
&
val
,
4
);
return
buf
;
return
buf
;
}
}
...
@@ -106,26 +124,13 @@ HugoCalculator::calcValue(int record,
...
@@ -106,26 +124,13 @@ HugoCalculator::calcValue(int record,
seed
=
record
+
attrib
+
updates
;
seed
=
record
+
attrib
+
updates
;
}
}
}
while
(
0
);
}
while
(
0
);
val
=
rand_r
(
&
seed
);
val
=
myRand
(
&
seed
);
if
(
attr
->
getNullable
()
&&
(((
val
>>
16
)
&
255
)
>
220
))
if
(
attr
->
getNullable
()
&&
(((
val
>>
16
)
&
255
)
>
220
))
return
NULL
;
return
NULL
;
memcpy
(
buf
,
&
val
,
(
len
>
4
?
4
:
len
));
int
pos
=
0
;
int
pos
=
4
;
while
(
pos
+
4
<
len
)
{
val
=
rand_r
(
&
seed
);
memcpy
(
buf
+
pos
,
&
val
,
4
);
pos
++
;
}
if
(
pos
<
len
)
{
val
=
rand_r
(
&
seed
);
memcpy
(
buf
+
pos
,
&
val
,
(
len
-
pos
));
}
switch
(
attr
->
getType
()){
switch
(
attr
->
getType
()){
case
NdbDictionary
:
:
Column
::
Tinyint
:
case
NdbDictionary
:
:
Column
::
Tinyint
:
case
NdbDictionary
:
:
Column
::
Tinyunsigned
:
case
NdbDictionary
:
:
Column
::
Tinyunsigned
:
...
@@ -144,15 +149,24 @@ HugoCalculator::calcValue(int record,
...
@@ -144,15 +149,24 @@ HugoCalculator::calcValue(int record,
case
NdbDictionary
:
:
Column
::
Datetime
:
case
NdbDictionary
:
:
Column
::
Datetime
:
case
NdbDictionary
:
:
Column
::
Time
:
case
NdbDictionary
:
:
Column
::
Time
:
case
NdbDictionary
:
:
Column
::
Date
:
case
NdbDictionary
:
:
Column
::
Date
:
break
;
case
NdbDictionary
:
:
Column
::
Bit
:
case
NdbDictionary
:
:
Column
::
Bit
:
while
(
len
>
4
)
{
memcpy
(
buf
+
pos
,
&
val
,
4
);
pos
+=
4
;
len
-=
4
;
val
=
myRand
(
&
seed
);
}
memcpy
(
buf
+
pos
,
&
val
,
len
);
if
(
attr
->
getType
()
==
NdbDictionary
::
Column
::
Bit
)
{
{
Uint32
bits
=
attr
->
getLength
();
Uint32
bits
=
attr
->
getLength
();
Uint32
tmp
=
bits
>>
5
;
Uint32
tmp
=
bits
>>
5
;
Uint32
size
=
bits
&
31
;
Uint32
size
=
bits
&
31
;
((
Uint32
*
)
buf
)[
tmp
]
&=
((
1
<<
size
)
-
1
);
((
Uint32
*
)
buf
)[
tmp
]
&=
((
1
<<
size
)
-
1
);
break
;
}
}
break
;
case
NdbDictionary
:
:
Column
::
Varbinary
:
case
NdbDictionary
:
:
Column
::
Varbinary
:
case
NdbDictionary
:
:
Column
::
Varchar
:
case
NdbDictionary
:
:
Column
::
Varchar
:
case
NdbDictionary
:
:
Column
::
Text
:
case
NdbDictionary
:
:
Column
::
Text
:
...
@@ -160,9 +174,21 @@ HugoCalculator::calcValue(int record,
...
@@ -160,9 +174,21 @@ HugoCalculator::calcValue(int record,
case
NdbDictionary
:
:
Column
::
Longvarchar
:
case
NdbDictionary
:
:
Column
::
Longvarchar
:
case
NdbDictionary
:
:
Column
::
Longvarbinary
:
case
NdbDictionary
:
:
Column
::
Longvarbinary
:
{
{
BaseString
tmp
;
char
*
ptr
=
(
char
*
)
&
val
;
base64_encode
(
buf
,
len
,
tmp
);
while
(
len
>=
4
)
memcpy
(
buf
,
tmp
.
c_str
(),
len
);
{
len
-=
4
;
buf
[
pos
++
]
=
base64_table
[
ptr
[
0
]
&
0x3f
];
buf
[
pos
++
]
=
base64_table
[
ptr
[
1
]
&
0x3f
];
buf
[
pos
++
]
=
base64_table
[
ptr
[
2
]
&
0x3f
];
buf
[
pos
++
]
=
base64_table
[
ptr
[
3
]
&
0x3f
];
val
=
myRand
(
&
seed
);
}
for
(;
len
;
len
--
,
pos
++
)
buf
[
pos
]
=
base64_table
[
ptr
[
len
]
&
0x3f
];
pos
--
;
break
;
break
;
}
}
case
NdbDictionary
:
:
Column
::
Blob
:
case
NdbDictionary
:
:
Column
::
Blob
:
...
...
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