Some more PPC fixes - initialization still doesn't run through, though.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17550 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
/* BPlusTree - BFS B+Tree implementation
|
/* BPlusTree - BFS B+Tree implementation
|
||||||
**
|
*
|
||||||
** Initial version by Axel Dörfler, [email protected]
|
* Initial version by Axel Dörfler, [email protected]
|
||||||
** Roughly based on 'btlib' written by Marcus J. Ranum
|
* Roughly based on 'btlib' written by Marcus J. Ranum
|
||||||
**
|
*
|
||||||
** Copyright (c) 2001-2006 pinc Software. All Rights Reserved.
|
* Copyright (c) 2001-2006 pinc Software. All Rights Reserved.
|
||||||
** This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
@@ -834,16 +834,17 @@ BPlusTree::InsertKey(bplustree_node *node, uint16 index, uint8 *key, uint16 keyL
|
|||||||
|
|
||||||
// move and update key length index
|
// move and update key length index
|
||||||
for (uint16 i = node->NumKeys(); i-- > index + 1;)
|
for (uint16 i = node->NumKeys(); i-- > index + 1;)
|
||||||
newKeyLengths[i] = keyLengths[i - 1] + keyLength;
|
newKeyLengths[i] = HOST_ENDIAN_TO_BFS_INT16(BFS_ENDIAN_TO_HOST_INT16(keyLengths[i - 1]) + keyLength);
|
||||||
memmove(newKeyLengths, keyLengths, sizeof(uint16) * index);
|
memmove(newKeyLengths, keyLengths, sizeof(uint16) * index);
|
||||||
|
|
||||||
int32 keyStart;
|
int32 keyStart;
|
||||||
newKeyLengths[index] = keyLength + (keyStart = index > 0 ? newKeyLengths[index - 1] : 0);
|
newKeyLengths[index] = HOST_ENDIAN_TO_BFS_INT16(keyLength + (keyStart = index > 0 ? BFS_ENDIAN_TO_HOST_INT16(newKeyLengths[index - 1]) : 0));
|
||||||
|
|
||||||
// move keys and copy new key into them
|
// move keys and copy new key into them
|
||||||
int32 size = node->AllKeyLength() - newKeyLengths[index];
|
uint16 length = BFS_ENDIAN_TO_HOST_INT16(newKeyLengths[index]);
|
||||||
|
int32 size = node->AllKeyLength() - length;
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
memmove(keys + newKeyLengths[index], keys + newKeyLengths[index] - keyLength, size);
|
memmove(keys + length, keys + length - keyLength, size);
|
||||||
|
|
||||||
memcpy(keys + keyStart, key, keyLength);
|
memcpy(keys + keyStart, key, keyLength);
|
||||||
}
|
}
|
||||||
@@ -875,13 +876,13 @@ BPlusTree::SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *oth
|
|||||||
int32 out, in;
|
int32 out, in;
|
||||||
for (in = out = 0; in < node->NumKeys() + 1;) {
|
for (in = out = 0; in < node->NumKeys() + 1;) {
|
||||||
if (!bytes)
|
if (!bytes)
|
||||||
bytesBefore = in > 0 ? inKeyLengths[in - 1] : 0;
|
bytesBefore = in > 0 ? BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in - 1]) : 0;
|
||||||
|
|
||||||
if (in == keyIndex && !bytes) {
|
if (in == keyIndex && !bytes) {
|
||||||
bytes = *_keyLength;
|
bytes = *_keyLength;
|
||||||
} else {
|
} else {
|
||||||
if (keyIndex < out)
|
if (keyIndex < out)
|
||||||
bytesAfter = inKeyLengths[in] - bytesBefore;
|
bytesAfter = BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in]) - bytesBefore;
|
||||||
|
|
||||||
in++;
|
in++;
|
||||||
}
|
}
|
||||||
@@ -897,7 +898,7 @@ BPlusTree::SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *oth
|
|||||||
// if the new key was not inserted, set the length of the keys
|
// if the new key was not inserted, set the length of the keys
|
||||||
// that can be copied directly
|
// that can be copied directly
|
||||||
if (keyIndex >= out && in > 0)
|
if (keyIndex >= out && in > 0)
|
||||||
bytesBefore = inKeyLengths[in - 1];
|
bytesBefore = BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in - 1]);
|
||||||
|
|
||||||
if (bytesBefore < 0 || bytesAfter < 0)
|
if (bytesBefore < 0 || bytesAfter < 0)
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
@@ -920,7 +921,7 @@ BPlusTree::SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *oth
|
|||||||
if (bytes) {
|
if (bytes) {
|
||||||
// copy the newly inserted key
|
// copy the newly inserted key
|
||||||
memcpy(outKeys + bytesBefore, key, bytes);
|
memcpy(outKeys + bytesBefore, key, bytes);
|
||||||
outKeyLengths[keyIndex] = bytes + bytesBefore;
|
outKeyLengths[keyIndex] = HOST_ENDIAN_TO_BFS_INT16(bytes + bytesBefore);
|
||||||
outKeyValues[keyIndex] = HOST_ENDIAN_TO_BFS_INT64(*_value);
|
outKeyValues[keyIndex] = HOST_ENDIAN_TO_BFS_INT64(*_value);
|
||||||
|
|
||||||
if (bytesAfter) {
|
if (bytesAfter) {
|
||||||
@@ -928,7 +929,7 @@ BPlusTree::SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *oth
|
|||||||
memcpy(outKeys + bytesBefore + bytes, inKeys + bytesBefore, bytesAfter);
|
memcpy(outKeys + bytesBefore + bytes, inKeys + bytesBefore, bytesAfter);
|
||||||
keys = out - keyIndex - 1;
|
keys = out - keyIndex - 1;
|
||||||
for (int32 i = 0;i < keys;i++)
|
for (int32 i = 0;i < keys;i++)
|
||||||
outKeyLengths[keyIndex + i + 1] = inKeyLengths[keyIndex + i] + bytes;
|
outKeyLengths[keyIndex + i + 1] = HOST_ENDIAN_TO_BFS_INT16(BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[keyIndex + i]) + bytes);
|
||||||
memcpy(outKeyValues + keyIndex + 1, inKeyValues + keyIndex, keys * sizeof(off_t));
|
memcpy(outKeyValues + keyIndex + 1, inKeyValues + keyIndex, keys * sizeof(off_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -971,7 +972,7 @@ BPlusTree::SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *oth
|
|||||||
memcpy(newKey, droppedKey, newLength);
|
memcpy(newKey, droppedKey, newLength);
|
||||||
|
|
||||||
other->overflow_link = inKeyValues[in];
|
other->overflow_link = inKeyValues[in];
|
||||||
total = inKeyLengths[in++];
|
total = BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in++]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -986,14 +987,14 @@ BPlusTree::SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *oth
|
|||||||
// it's enough to set bytesBefore once here, because we do
|
// it's enough to set bytesBefore once here, because we do
|
||||||
// not need to know the exact length of all keys in this
|
// not need to know the exact length of all keys in this
|
||||||
// loop
|
// loop
|
||||||
bytesBefore = in > skip ? inKeyLengths[in - 1] : 0;
|
bytesBefore = in > skip ? BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in - 1]) : 0;
|
||||||
bytes = *_keyLength;
|
bytes = *_keyLength;
|
||||||
} else {
|
} else {
|
||||||
if (in < node->NumKeys()) {
|
if (in < node->NumKeys()) {
|
||||||
inKeyLengths[in] -= total;
|
inKeyLengths[in] = HOST_ENDIAN_TO_BFS_INT16(BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in]) - total);
|
||||||
if (bytes) {
|
if (bytes) {
|
||||||
inKeyLengths[in] += bytes;
|
inKeyLengths[in] = HOST_ENDIAN_TO_BFS_INT16(BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in]) + bytes);
|
||||||
bytesAfter = inKeyLengths[in] - bytesBefore - bytes;
|
bytesAfter = BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in]) - bytesBefore - bytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in++;
|
in++;
|
||||||
@@ -1008,7 +1009,7 @@ BPlusTree::SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *oth
|
|||||||
|
|
||||||
// adjust the byte counts (since we were a bit lazy in the loop)
|
// adjust the byte counts (since we were a bit lazy in the loop)
|
||||||
if (keyIndex >= in && keyIndex - skip < out)
|
if (keyIndex >= in && keyIndex - skip < out)
|
||||||
bytesAfter = inKeyLengths[in] - bytesBefore - total;
|
bytesAfter = BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in]) - bytesBefore - total;
|
||||||
else if (keyIndex < skip)
|
else if (keyIndex < skip)
|
||||||
bytesBefore = node->AllKeyLength() - total;
|
bytesBefore = node->AllKeyLength() - total;
|
||||||
|
|
||||||
@@ -1049,7 +1050,7 @@ BPlusTree::SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *oth
|
|||||||
if (bytes) {
|
if (bytes) {
|
||||||
// finally, copy the newly inserted key (don't overwrite anything)
|
// finally, copy the newly inserted key (don't overwrite anything)
|
||||||
memcpy(inKeys + bytesBefore, key, bytes);
|
memcpy(inKeys + bytesBefore, key, bytes);
|
||||||
outKeyLengths[keyIndex] = bytes + bytesBefore;
|
outKeyLengths[keyIndex] = HOST_ENDIAN_TO_BFS_INT16(bytes + bytesBefore);
|
||||||
outKeyValues[keyIndex] = HOST_ENDIAN_TO_BFS_INT64(*_value);
|
outKeyValues[keyIndex] = HOST_ENDIAN_TO_BFS_INT64(*_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Journal - transaction and logging
|
/* Journal - transaction and logging
|
||||||
*
|
*
|
||||||
* Copyright 2001-2005, Axel Dörfler, [email protected]
|
* Copyright 2001-2006, Axel Dörfler, [email protected]
|
||||||
* This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ LogEntry::InsertBlock(off_t blockNumber)
|
|||||||
block_run run = fJournal->GetVolume()->ToBlockRun(blockNumber);
|
block_run run = fJournal->GetVolume()->ToBlockRun(blockNumber);
|
||||||
|
|
||||||
fArray->runs[CountRuns()] = run;
|
fArray->runs[CountRuns()] = run;
|
||||||
fArray->count = HOST_ENDIAN_TO_BFS_INT16(CountRuns() + 1);
|
fArray->count = HOST_ENDIAN_TO_BFS_INT32(CountRuns() + 1);
|
||||||
fLength++;
|
fLength++;
|
||||||
fCachedBlocks++;
|
fCachedBlocks++;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user