Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
fcec3ae1
Commit
fcec3ae1
authored
8 years ago
by
Simon Désaulniers
Browse files
Options
Downloads
Patches
Plain Diff
pht: fix invalid comparison, inexact match lookup
parent
08465a6c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/indexation/pht.cpp
+13
-16
13 additions, 16 deletions
src/indexation/pht.cpp
with
13 additions
and
16 deletions
src/indexation/pht.cpp
+
13
−
16
View file @
fcec3ae1
...
...
@@ -67,26 +67,23 @@ void Pht::lookupStep(Prefix p, std::shared_ptr<int> lo, std::shared_ptr<int> hi,
IndexEntry
entry
;
entry
.
unpackValue
(
*
value
);
auto
add_value
=
[
&
](
bool
better
=
true
)
{
vals
->
emplace_back
(
std
::
make_shared
<
Value
>
(
entry
.
value
));
if
(
better
and
max_common_prefix_len
)
*
max_common_prefix_len
=
Prefix
::
commonBits
(
p
,
vals
->
front
()
->
first
);
};
if
(
max_common_prefix_len
)
{
if
(
max_common_prefix_len
)
{
/* inexact match case */
auto
common_bits
=
Prefix
::
commonBits
(
p
,
entry
.
prefix
);
if
(
vals
->
empty
())
{
add_value
();
}
else
{
auto
common_bits
=
Prefix
::
commonBits
(
vals
->
front
()
->
first
,
p
.
getPrefix
(
mid
));
if
(
common_bits
==
*
max_common_prefix_len
)
add_value
(
false
);
else
if
(
common_bits
>
*
max_common_prefix_len
)
{
vals
->
emplace_back
(
std
::
make_shared
<
Value
>
(
entry
.
value
));
*
max_common_prefix_len
=
common_bits
;
}
else
{
if
(
common_bits
==
*
max_common_prefix_len
)
/* this is the max so far */
vals
->
emplace_back
(
std
::
make_shared
<
Value
>
(
entry
.
value
));
else
if
(
common_bits
>
*
max_common_prefix_len
)
{
/* new max found! */
vals
->
clear
();
add_value
();
vals
->
emplace_back
(
std
::
make_shared
<
Value
>
(
entry
.
value
));
*
max_common_prefix_len
=
common_bits
;
}
}
}
else
if
(
all_values
or
entry
.
prefix
==
p
.
content_
)
add_value
(
false
);
}
else
if
(
all_values
or
entry
.
prefix
==
p
.
content_
)
/* exact match case */
vals
->
emplace_back
(
std
::
make_shared
<
Value
>
(
entry
.
value
));
}
return
true
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment