Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Duplication reported by PMD tool #1034

Open
KFilipek opened this issue Aug 4, 2021 · 0 comments
Open

Duplication reported by PMD tool #1034

KFilipek opened this issue Aug 4, 2021 · 0 comments
Labels
stree Needs to be resolved to productize stree Type: Bug

Comments

@KFilipek
Copy link
Contributor

KFilipek commented Aug 4, 2021

ISSUE: Duplication reported by PMD tool

Environment Information

Name Version
pmemkv version(s) 54f2660
libpmemobj-cpp version(s) N/A
PMDK (libpmem/libpmemobj) version(s) N/A
OS(es) version(s) N/A
kernel version(s) N/A
compiler, libraries, packaging and other related tools version(s) N/A

Please provide a reproduction of the bug:

./bin/run.sh cpd --minimum-tokens 100 --files ~/Development/work/pmemkv/src/ --language cpp

Details

I removed API related duplications.

Found a 22 line (172 tokens) duplication in the following files: 
Starting at line 1918 of /home/kfilipek/Development/work/pmemkv/src/engines-experimental/stree/persistent_b_tree.h
Starting at line 1960 of /home/kfilipek/Development/work/pmemkv/src/engines-experimental/stree/persistent_b_tree.h

b_tree_base<Key, T, Compare, degree>::split_leaf_node(pool_base &pop,
						      leaf_pptr &split_leaf, K &&key,
						      M &&obj)
{
	assert(split_leaf->full());

	leaf_pptr node;
	std::pair<iterator, bool> result(nullptr, false);
	auto middle = split_leaf->begin() + split_leaf->size() / 2;
	bool less = compare(std::forward<K>(key), middle->first);
	// move second half into node and insert new element where needed
	pmem::obj::transaction::run(pop, [&] {
		node = allocate_leaf();
		node->move(pop, split_leaf, compare);
		/* insert entry(key, obj) into needed half */
		if (less) {
			result = internal_insert(split_leaf, std::forward<K>(key),
						 std::forward<M>(obj));
		} else {
			result = internal_insert(node, std::forward<K>(key),
						 std::forward<M>(obj));
		}
@lukaszstolarczuk lukaszstolarczuk added new need to be triaged stree Needs to be resolved to productize stree labels Aug 4, 2021
@lukaszstolarczuk lukaszstolarczuk removed the new need to be triaged label Aug 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stree Needs to be resolved to productize stree Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants