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
255cf71a
Commit
255cf71a
authored
Dec 06, 2004
by
joreland@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ndb - Use BitmaskImpl in TUP (in BitField operations)
parent
836e13ae
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
68 deletions
+88
-68
ndb/include/util/Bitmask.hpp
ndb/include/util/Bitmask.hpp
+47
-0
ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp
ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp
+41
-68
No files found.
ndb/include/util/Bitmask.hpp
View file @
255cf71a
...
...
@@ -131,6 +131,19 @@ public:
static
void
setField
(
unsigned
size
,
Uint32
data
[],
unsigned
pos
,
unsigned
len
,
Uint32
val
);
/**
* getField - Get bitfield at given position and length
*/
static
void
getField
(
unsigned
size
,
const
Uint32
data
[],
unsigned
pos
,
unsigned
len
,
Uint32
dst
[]);
/**
* setField - Set bitfield at given position and length
*/
static
void
setField
(
unsigned
size
,
Uint32
data
[],
unsigned
pos
,
unsigned
len
,
const
Uint32
src
[]);
/**
* getText - Return as hex-digits (only for debug routines).
*/
...
...
@@ -794,4 +807,38 @@ public:
Bitmask
()
{
this
->
clear
();}
};
inline
void
BitmaskImpl
::
getField
(
unsigned
size
,
const
Uint32
data
[],
unsigned
pos
,
unsigned
len
,
Uint32
dst
[])
{
assert
(
len
>
0
);
assert
(
pos
+
len
<
(
size
<<
5
));
Uint32
word
=
pos
>>
5
;
Uint32
offset
=
pos
&
31
;
if
(
offset
+
len
<=
32
)
{
dst
[
0
]
=
(
data
[
word
]
>>
offset
)
&
((
1
<<
len
)
-
1
);
return
;
}
abort
();
}
inline
void
BitmaskImpl
::
setField
(
unsigned
size
,
Uint32
data
[],
unsigned
pos
,
unsigned
len
,
const
Uint32
src
[])
{
assert
(
len
>
0
);
assert
(
pos
+
len
<
(
size
<<
5
));
Uint32
word
=
pos
>>
5
;
Uint32
offset
=
pos
&
31
;
if
(
offset
+
len
<=
32
)
{
Uint32
mask
=
((
1
<<
len
)
-
1
)
<<
offset
;
data
[
word
]
=
(
data
[
word
]
&
~
mask
)
|
((
src
[
0
]
<<
offset
)
&
mask
);
return
;
}
abort
();
}
#endif
ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp
View file @
255cf71a
...
...
@@ -1028,22 +1028,22 @@ Dbtup::readBitsNotNULL(Uint32* outBuffer,
offsetInTuple
+=
regTabPtr
->
tupNullIndex
;
ndbrequire
(
offsetInTuple
<
tCheckOffset
);
Uint32
pos
=
offsetInTuple
<<
5
+
offsetInWord
;
Uint32
indexBuf
=
tOutBufIndex
;
Uint32
newIndexBuf
=
indexBuf
+
((
bitCount
+
31
)
>>
5
);
Uint32
maxRead
=
tMaxRead
;
outBuffer
[
indexBuf
]
=
(
tTupleHeader
[
offsetInTuple
]
>>
offsetInWord
)
&
((
1
<<
bitCount
)
-
1
);
if
(
offsetInWord
+
bitCount
>
32
)
{
ndbrequire
(
false
);
}
if
(
newIndexBuf
<=
maxRead
)
{
ljam
();
ahOut
->
setDataSize
((
bitCount
+
31
)
>>
5
);
tOutBufIndex
=
newIndexBuf
;
BitmaskImpl
::
getField
(
regTabPtr
->
tupNullWords
,
tTupleHeader
+
regTabPtr
->
tupNullIndex
,
pos
,
bitCount
,
outBuffer
+
indexBuf
);
return
true
;
}
else
{
ljam
();
...
...
@@ -1069,34 +1069,27 @@ Dbtup::readBitsNULLable(Uint32* outBuffer,
Uint32
indexBuf
=
tOutBufIndex
;
Uint32
newIndexBuf
=
indexBuf
+
(
bitCount
+
31
)
>>
5
;
Uint32
maxRead
=
tMaxRead
;
Uint32
pos
=
offsetInWord
<<
5
+
offsetInTuple
;
if
((
tTupleHeader
[
offsetInTuple
]
>>
offsetInWord
)
&
1
)
if
(
BitmaskImpl
::
get
(
regTabPtr
->
tupNullWords
,
tTupleHeader
+
regTabPtr
->
tupNullIndex
,
pos
))
{
ljam
();
ahOut
->
setNULL
();
return
true
;
}
offsetInWord
++
;
if
(
offsetInWord
==
32
)
{
ljam
();
offsetInWord
=
0
;
offsetInTuple
++
;
}
outBuffer
[
indexBuf
]
=
(
tTupleHeader
[
offsetInTuple
]
>>
offsetInWord
)
&
((
1
<<
bitCount
)
-
1
);
if
(
offsetInWord
+
bitCount
>
32
)
{
ndbrequire
(
false
);
}
if
(
newIndexBuf
<=
maxRead
)
{
ljam
();
ahOut
->
setDataSize
((
bitCount
+
31
)
>>
5
);
tOutBufIndex
=
newIndexBuf
;
BitmaskImpl
::
getField
(
regTabPtr
->
tupNullWords
,
tTupleHeader
+
regTabPtr
->
tupNullIndex
,
pos
+
1
,
bitCount
,
outBuffer
+
indexBuf
);
return
true
;
}
else
{
ljam
();
...
...
@@ -1123,24 +1116,16 @@ Dbtup::updateBitsNotNULL(Uint32* inBuffer,
ndbrequire
((
nullFlagOffset
<
regTabPtr
->
tupNullWords
)
&&
(
nullWordOffset
<
tCheckOffset
));
Uint32
nullBits
=
tTupleHeader
[
nullWordOffset
];
Uint32
pos
=
(
nullFlagOffset
<<
5
)
+
nullFlagBitOffset
;
if
(
newIndex
<=
inBufLen
)
{
Uint32
updateWord
=
inBuffer
[
indexBuf
+
1
];
if
(
!
nullIndicator
)
{
BitmaskImpl
::
setField
(
regTabPtr
->
tupNullWords
,
tTupleHeader
+
regTabPtr
->
tupNullIndex
,
pos
,
bitCount
,
inBuffer
+
indexBuf
+
1
);
tInBufIndex
=
newIndex
;
Uint32
mask
=
((
1
<<
bitCount
)
-
1
)
<<
nullFlagBitOffset
;
if
(
nullFlagBitOffset
+
bitCount
<=
32
)
{
ljam
();
tTupleHeader
[
nullWordOffset
]
=
(
nullBits
&
~
mask
)
|
((
updateWord
<<
nullFlagBitOffset
)
&
mask
);
return
true
;
}
else
{
abort
();
}
return
true
;
}
else
{
ljam
();
...
...
@@ -1171,41 +1156,29 @@ Dbtup::updateBitsNULLable(Uint32* inBuffer,
(
nullWordOffset
<
tCheckOffset
));
Uint32
nullBits
=
tTupleHeader
[
nullWordOffset
];
Uint32
bitCount
=
AttributeDescriptor
::
getArraySize
(
attrDescriptor
);
Uint32
pos
=
(
nullFlagOffset
<<
5
)
+
nullFlagBitOffset
;
if
(
!
nullIndicator
)
{
Uint32
newIndex
=
indexBuf
+
1
+
((
bitCount
+
31
)
>>
5
);
nullBits
&=
(
~
(
1
<<
nullFlagBitOffset
));
ljam
();
tTupleHeader
[
nullWordOffset
]
=
nullBits
;
nullFlagBitOffset
++
;
if
(
nullFlagBitOffset
==
32
)
{
ljam
();
nullFlagBitOffset
=
0
;
nullWordOffset
++
;
nullBits
=
tTupleHeader
[
nullWordOffset
];
}
BitmaskImpl
::
clear
(
regTabPtr
->
tupNullWords
,
tTupleHeader
+
regTabPtr
->
tupNullIndex
,
pos
);
BitmaskImpl
::
setField
(
regTabPtr
->
tupNullWords
,
tTupleHeader
+
regTabPtr
->
tupNullIndex
,
pos
+
1
,
bitCount
,
inBuffer
+
indexBuf
+
1
);
Uint32
updateWord
=
inBuffer
[
indexBuf
+
1
];
Uint32
mask
=
((
1
<<
bitCount
)
-
1
)
<<
nullFlagBitOffset
;
Uint32
newIndex
=
indexBuf
+
1
+
((
bitCount
+
31
)
>>
5
);
tInBufLen
=
newIndex
;
if
(
nullFlagBitOffset
+
bitCount
<=
32
)
{
ljam
();
tTupleHeader
[
nullWordOffset
]
=
(
nullBits
&
~
mask
)
|
((
updateWord
<<
nullFlagBitOffset
)
&
mask
);
return
true
;
}
abort
();
}
else
{
Uint32
newIndex
=
tInBufIndex
+
1
;
if
(
newIndex
<=
tInBufLen
)
{
nullBits
|=
(
1
<<
nullFlagBitOffset
);
ljam
();
tTupleHeader
[
nullWordOffset
]
=
nullBits
;
BitmaskImpl
::
set
(
regTabPtr
->
tupNullWords
,
tTupleHeader
+
regTabPtr
->
tupNullIndex
,
pos
);
tInBufIndex
=
newIndex
;
return
true
;
}
else
{
...
...
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