summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <tegge@oath.com>2017-08-15 11:22:42 +0000
committerTor Egge <tegge@oath.com>2017-08-15 11:23:34 +0000
commitd1a7a665cafbabf3170500e8556c0b2b92b8eba5 (patch)
treea1d9f80bfc5e5238c76f2d46e10b0cb8c4a94d35 /searchlib
parenta1682ec2fb64df93939d7131bedb08657ca2b74d (diff)
Rename variables for clarity.
Remove generated test files (saved reference attribute).
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp36
-rw-r--r--searchlib/src/vespa/searchlib/attribute/reference_attribute.h14
3 files changed, 27 insertions, 25 deletions
diff --git a/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp b/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
index 337cdcc30e8..a638309576a 100644
--- a/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
+++ b/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
@@ -364,6 +364,8 @@ TEST_F("require that populateReferencedLids() uses gid-mapper to update lid-2-li
f.save();
f.load();
TEST_DO(checkPopulateReferencedLids(f));
+ EXPECT_TRUE(vespalib::unlink("test.dat"));
+ EXPECT_TRUE(vespalib::unlink("test.udat"));
}
TEST_F("Require that notifyGidToLidChange changes reverse mapping", Fixture)
diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
index 5a088fd1d64..2798127e981 100644
--- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
@@ -52,9 +52,9 @@ ReferenceAttribute::~ReferenceAttribute()
const auto saver = _store.getSaver();
saver.foreach_key([&store,this](EntryRef ref)
{ const Reference &entry = store.get(ref);
- EntryRef pidx = entry.pidx();
- if (pidx.valid()) {
- _reverseMapping.clear(pidx);
+ EntryRef revMapIdx = entry.revMapIdx();
+ if (revMapIdx.valid()) {
+ _reverseMapping.clear(revMapIdx);
}
});
incGeneration(); // Force freeze
@@ -88,7 +88,7 @@ ReferenceAttribute::syncReverseMappingIndices(const Reference &entry)
uint32_t referencedLid = entry.lid();
if (referencedLid != 0u) {
_reverseMappingIndices.ensure_size(referencedLid + 1);
- _reverseMappingIndices[referencedLid] = entry.pidx();
+ _reverseMappingIndices[referencedLid] = entry.revMapIdx();
}
}
@@ -96,10 +96,10 @@ void
ReferenceAttribute::removeReverseMapping(EntryRef oldRef, uint32_t lid)
{
const auto &entry = _store.get(oldRef);
- EntryRef pidx = entry.pidx();
- _reverseMapping.apply(pidx, nullptr, nullptr, &lid, &lid + 1);
+ EntryRef revMapIdx = entry.revMapIdx();
+ _reverseMapping.apply(revMapIdx, nullptr, nullptr, &lid, &lid + 1);
std::atomic_thread_fence(std::memory_order_release);
- entry.setPidx(pidx);
+ entry.setRevMapIdx(revMapIdx);
syncReverseMappingIndices(entry);
}
@@ -107,11 +107,11 @@ void
ReferenceAttribute::addReverseMapping(EntryRef newRef, uint32_t lid)
{
const auto &entry = _store.get(newRef);
- EntryRef pidx = entry.pidx();
+ EntryRef revMapIdx = entry.revMapIdx();
ReverseMapping::KeyDataType add(lid, btree::BTreeNoLeafData());
- _reverseMapping.apply(pidx, &add, &add + 1, nullptr, nullptr);
+ _reverseMapping.apply(revMapIdx, &add, &add + 1, nullptr, nullptr);
std::atomic_thread_fence(std::memory_order_release);
- entry.setPidx(pidx);
+ entry.setRevMapIdx(revMapIdx);
syncReverseMappingIndices(entry);
}
@@ -119,10 +119,10 @@ void
ReferenceAttribute::buildReverseMapping(EntryRef newRef, const std::vector<ReverseMapping::KeyDataType> &adds)
{
const auto &entry = _store.get(newRef);
- EntryRef pidx = entry.pidx();
- assert(!pidx.valid());
- _reverseMapping.apply(pidx, &adds[0], &adds[adds.size()], nullptr, nullptr);
- entry.setPidx(pidx);
+ EntryRef revMapIdx = entry.revMapIdx();
+ assert(!revMapIdx.valid());
+ _reverseMapping.apply(revMapIdx, &adds[0], &adds[adds.size()], nullptr, nullptr);
+ entry.setRevMapIdx(revMapIdx);
}
void
@@ -140,15 +140,15 @@ ReferenceAttribute::buildReverseMapping()
std::sort(indices.begin(), indices.end());
EntryRef prevRef;
std::vector<ReverseMapping::KeyDataType> adds;
- for (const auto & p : indices) {
- if (p.first != prevRef) {
+ for (const auto & elem : indices) {
+ if (elem.first != prevRef) {
if (prevRef.valid()) {
buildReverseMapping(prevRef, adds);
adds.clear();
}
- prevRef = p.first;
+ prevRef = elem.first;
}
- adds.emplace_back(p.second, btree::BTreeNoLeafData());
+ adds.emplace_back(elem.second, btree::BTreeNoLeafData());
}
if (prevRef.valid()) {
buildReverseMapping(prevRef, adds);
diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h
index d6e3badc16e..5647acfd163 100644
--- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h
@@ -31,18 +31,18 @@ public:
class Reference {
GlobalId _gid;
mutable uint32_t _lid; // referenced lid
- mutable EntryRef _pidx; // map from gid to lids referencing gid
+ mutable EntryRef _revMapIdx; // map from gid to lids referencing gid
public:
Reference()
: _gid(),
_lid(0u),
- _pidx()
+ _revMapIdx()
{
}
Reference(const GlobalId &gid_)
: _gid(gid_),
_lid(0u),
- _pidx()
+ _revMapIdx()
{
}
bool operator<(const Reference &rhs) const {
@@ -50,9 +50,9 @@ public:
}
const GlobalId &gid() const { return _gid; }
uint32_t lid() const { return _lid; }
- EntryRef pidx() const { return _pidx; }
+ EntryRef revMapIdx() const { return _revMapIdx; }
void setLid(uint32_t referencedLid) const { _lid = referencedLid; }
- void setPidx(EntryRef newPidx) const { _pidx = newPidx; }
+ void setRevMapIdx(EntryRef newRevMapIdx) const { _revMapIdx = newRevMapIdx; }
};
using ReferenceStore = datastore::UniqueStore<Reference>;
using ReferenceStoreIndices = RcuVectorBase<EntryRef>;
@@ -121,8 +121,8 @@ void
ReferenceAttribute::foreach_lid(uint32_t referencedLid, FunctionType &&func) const
{
if (referencedLid < _reverseMappingIndices.size()) {
- EntryRef pidx = _reverseMappingIndices[referencedLid];
- _reverseMapping.foreach_frozen_key(pidx, func);
+ EntryRef revMapIdx = _reverseMappingIndices[referencedLid];
+ _reverseMapping.foreach_frozen_key(revMapIdx, func);
}
}