Skip to content

Conversation

@jschmieg
Copy link
Contributor

Initial implementation of removal from ARTree using pmemobj_free.

decrementParent(node->parent, key);
if (node->parent && node->parent->refCounter == 0) {
persistent_ptr<Node256> nodeParent;
pmemobj_free(nodeParent->children[0].raw_ptr());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodeParent is declared above, but not initialized. How can this work? Do I miss something?

size_t keyCalc = key[tree->treeRoot->keySize - node->depth - 1];
std::bitset<8> x(keyCalc);
node->children[keyCalc] = nullptr;
node->refCounter--;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see refCounter is atomic, shouldn't we initialize it when loading an existing tree?

}

/*
* TODO: decrement value std::atomic<int> refCounter in parent and free it if

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo can be removed? Also the one in line 378?

std::bitset<8> x(keyCalc);
node->children[keyCalc] = nullptr;
node->refCounter--;
if (node->refCounter == 0) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be an compare and swap instruction? Otherwise we can have a situation in which two threads decrement refCounter in parallel before checking for zero in next line. In this situation, none will decrement the parent

void ARTree::decrementParent(persistent_ptr<Node> node) {}
void ARTree::decrementParent(persistent_ptr<Node256> node, const char *key) {
size_t keyCalc = key[tree->treeRoot->keySize - node->depth - 1];
std::bitset<8> x(keyCalc);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like x is not used for anything

decrementParent(valPrstPtr->parent);
void ARTree::removeFromTree(persistent_ptr<NodeLeafCompressed> compressed,
const char *key) {
persistent_ptr<Node256> current = compressed->parent;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name "current" is confusing, maybe this variable should be called "parent"?

// remove ValueWrapper
pmemobj_free(valPrstPtr.raw_ptr());
} else if (valPrstPtr->location == DISK) {
// TODO: jradtke need to confirm if no extra action required here

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that comment should be updated, for sure extra actions are needed, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants