Added a BPlusTree::Remove() inline method for strings.
Style cleanups. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2051 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -177,6 +177,7 @@ class BPlusTree {
|
|||||||
status_t Remove(Transaction *transaction, const uint8 *key, uint16 keyLength, off_t value);
|
status_t Remove(Transaction *transaction, const uint8 *key, uint16 keyLength, off_t value);
|
||||||
status_t Insert(Transaction *transaction, const uint8 *key, uint16 keyLength, off_t value);
|
status_t Insert(Transaction *transaction, const uint8 *key, uint16 keyLength, off_t value);
|
||||||
|
|
||||||
|
status_t Remove(Transaction *transaction, const char *key, off_t value);
|
||||||
status_t Insert(Transaction *transaction, const char *key, off_t value);
|
status_t Insert(Transaction *transaction, const char *key, off_t value);
|
||||||
status_t Insert(Transaction *transaction, int32 key, off_t value);
|
status_t Insert(Transaction *transaction, int32 key, off_t value);
|
||||||
status_t Insert(Transaction *transaction, uint32 key, off_t value);
|
status_t Insert(Transaction *transaction, uint32 key, off_t value);
|
||||||
@@ -197,18 +198,26 @@ class BPlusTree {
|
|||||||
// no implementation
|
// no implementation
|
||||||
|
|
||||||
int32 CompareKeys(const void *key1, int keylength1, const void *key2, int keylength2);
|
int32 CompareKeys(const void *key1, int keylength1, const void *key2, int keylength2);
|
||||||
status_t FindKey(bplustree_node *node, const uint8 *key, uint16 keyLength, uint16 *index = NULL, off_t *next = NULL);
|
status_t FindKey(bplustree_node *node, const uint8 *key, uint16 keyLength,
|
||||||
|
uint16 *index = NULL, off_t *next = NULL);
|
||||||
status_t SeekDown(Stack<node_and_key> &stack, const uint8 *key, uint16 keyLength);
|
status_t SeekDown(Stack<node_and_key> &stack, const uint8 *key, uint16 keyLength);
|
||||||
|
|
||||||
status_t FindFreeDuplicateFragment(bplustree_node *node, CachedNode *cached, off_t *_offset, bplustree_node **_fragment,uint32 *_index);
|
status_t FindFreeDuplicateFragment(bplustree_node *node, CachedNode *cached,
|
||||||
status_t InsertDuplicate(Transaction *transaction,CachedNode *cached,bplustree_node *node,uint16 index,off_t value);
|
off_t *_offset, bplustree_node **_fragment, uint32 *_index);
|
||||||
void InsertKey(bplustree_node *node, uint16 index, uint8 *key, uint16 keyLength, off_t value);
|
status_t InsertDuplicate(Transaction *transaction, CachedNode *cached,
|
||||||
status_t SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *other, off_t otherOffset, uint16 *_keyIndex, uint8 *key, uint16 *_keyLength, off_t *_value);
|
bplustree_node *node, uint16 index, off_t value);
|
||||||
|
void InsertKey(bplustree_node *node, uint16 index, uint8 *key, uint16 keyLength,
|
||||||
|
off_t value);
|
||||||
|
status_t SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *other,
|
||||||
|
off_t otherOffset, uint16 *_keyIndex, uint8 *key, uint16 *_keyLength,
|
||||||
|
off_t *_value);
|
||||||
|
|
||||||
status_t RemoveDuplicate(Transaction *transaction,bplustree_node *node,CachedNode *cached,uint16 keyIndex, off_t value);
|
status_t RemoveDuplicate(Transaction *transaction, bplustree_node *node,
|
||||||
|
CachedNode *cached, uint16 keyIndex, off_t value);
|
||||||
void RemoveKey(bplustree_node *node, uint16 index);
|
void RemoveKey(bplustree_node *node, uint16 index);
|
||||||
|
|
||||||
void UpdateIterators(off_t offset,off_t nextOffset,uint16 keyIndex,uint16 splitAt,int8 change);
|
void UpdateIterators(off_t offset, off_t nextOffset, uint16 keyIndex,
|
||||||
|
uint16 splitAt, int8 change);
|
||||||
void AddIterator(TreeIterator *iterator);
|
void AddIterator(TreeIterator *iterator);
|
||||||
void RemoveIterator(TreeIterator *iterator);
|
void RemoveIterator(TreeIterator *iterator);
|
||||||
|
|
||||||
@@ -229,7 +238,8 @@ class BPlusTree {
|
|||||||
|
|
||||||
//***** helper classes/functions *****
|
//***** helper classes/functions *****
|
||||||
|
|
||||||
extern int32 compareKeys(type_code type,const void *key1, int keyLength1, const void *key2, int keyLength2);
|
extern int32 compareKeys(type_code type, const void *key1, int keyLength1,
|
||||||
|
const void *key2, int keyLength2);
|
||||||
|
|
||||||
class TreeIterator {
|
class TreeIterator {
|
||||||
public:
|
public:
|
||||||
@@ -237,12 +247,15 @@ class TreeIterator {
|
|||||||
~TreeIterator();
|
~TreeIterator();
|
||||||
|
|
||||||
status_t Goto(int8 to);
|
status_t Goto(int8 to);
|
||||||
status_t Traverse(int8 direction, void *key, uint16 *keyLength, uint16 maxLength, off_t *value,uint16 *duplicate = NULL);
|
status_t Traverse(int8 direction, void *key, uint16 *keyLength, uint16 maxLength,
|
||||||
|
off_t *value, uint16 *duplicate = NULL);
|
||||||
status_t Find(const uint8 *key, uint16 keyLength);
|
status_t Find(const uint8 *key, uint16 keyLength);
|
||||||
|
|
||||||
status_t Rewind();
|
status_t Rewind();
|
||||||
status_t GetNextEntry(void *key,uint16 *keyLength,uint16 maxLength,off_t *value,uint16 *duplicate = NULL);
|
status_t GetNextEntry(void *key, uint16 *keyLength, uint16 maxLength,
|
||||||
status_t GetPreviousEntry(void *key,uint16 *keyLength,uint16 maxLength,off_t *value,uint16 *duplicate = NULL);
|
off_t *value, uint16 *duplicate = NULL);
|
||||||
|
status_t GetPreviousEntry(void *key, uint16 *keyLength, uint16 maxLength,
|
||||||
|
off_t *value, uint16 *duplicate = NULL);
|
||||||
void SkipDuplicates();
|
void SkipDuplicates();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -269,6 +282,14 @@ class TreeIterator {
|
|||||||
|
|
||||||
// BPlusTree's inline functions (most of them may not be needed)
|
// BPlusTree's inline functions (most of them may not be needed)
|
||||||
|
|
||||||
|
inline status_t
|
||||||
|
BPlusTree::Remove(Transaction *transaction, const char *key, off_t value)
|
||||||
|
{
|
||||||
|
if (fHeader->data_type != BPLUSTREE_STRING_TYPE)
|
||||||
|
return B_BAD_TYPE;
|
||||||
|
return Remove(transaction, (uint8 *)key, strlen(key), value);
|
||||||
|
}
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
BPlusTree::Insert(Transaction *transaction, const char *key, off_t value)
|
BPlusTree::Insert(Transaction *transaction, const char *key, off_t value)
|
||||||
{
|
{
|
||||||
@@ -336,13 +357,15 @@ TreeIterator::Rewind()
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
TreeIterator::GetNextEntry(void *key,uint16 *keyLength,uint16 maxLength,off_t *value,uint16 *duplicate)
|
TreeIterator::GetNextEntry(void *key, uint16 *keyLength, uint16 maxLength,
|
||||||
|
off_t *value, uint16 *duplicate)
|
||||||
{
|
{
|
||||||
return Traverse(BPLUSTREE_FORWARD, key, keyLength, maxLength, value, duplicate);
|
return Traverse(BPLUSTREE_FORWARD, key, keyLength, maxLength, value, duplicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
TreeIterator::GetPreviousEntry(void *key,uint16 *keyLength,uint16 maxLength,off_t *value,uint16 *duplicate)
|
TreeIterator::GetPreviousEntry(void *key, uint16 *keyLength, uint16 maxLength,
|
||||||
|
off_t *value, uint16 *duplicate)
|
||||||
{
|
{
|
||||||
return Traverse(BPLUSTREE_BACKWARD, key, keyLength, maxLength, value, duplicate);
|
return Traverse(BPLUSTREE_BACKWARD, key, keyLength, maxLength, value, duplicate);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user