Skip to content

Commit 2bc00ca

Browse files
author
Qi Chen
committed
fix unsafe delete
1 parent 89cac4b commit 2bc00ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

AnnService/inc/Core/SPANN/ExtraDynamicSearcher.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ namespace SPTAG::SPANN {
726726
// double gcEndTime = sw.getElapsedMs();
727727
// m_splitGcCost += gcEndTime;
728728

729-
if (!preReassign && index < m_postingSizeLimit)
729+
if (!preReassign && localIndices.size() < m_postingSizeLimit)
730730
{
731731

732732
//SPTAGLIB_LOG(Helper::LogLevel::LL_Info, "DEBUG: in place or not prereassign & index < m_postingSizeLimit. GC begin...\n");
@@ -737,12 +737,12 @@ namespace SPTAG::SPANN {
737737
memcpy(ptr, postingList.c_str() + localIndices[j] * m_vectorInfoSize, m_vectorInfoSize);
738738
//Serialize(ptr, localIndicesInsert[j], localIndicesInsertVersion[j], smallSample[j]);
739739
}
740-
postingList.resize(index * m_vectorInfoSize);
740+
postingList.resize(localIndices.size() * m_vectorInfoSize);
741741
if ((ret=db->Put(headID, postingList, MaxTimeout, &(p_exWorkSpace->m_diskRequests))) != ErrorCode::Success) {
742742
SPTAGLIB_LOG(Helper::LogLevel::LL_Error, "Split Fail to write back postings\n");
743743
return ret;
744744
}
745-
m_postingSizes.UpdateSize(headID, index);
745+
m_postingSizes.UpdateSize(headID, localIndices.size());
746746
*m_checkSums[headID] = m_checkSum.CalcChecksum(postingList.c_str(), (int)(postingList.size()));
747747
if (m_opt->m_consistencyCheck && (ret = db->Check(headID, m_postingSizes.GetSize(headID) * m_vectorInfoSize, nullptr)) != ErrorCode::Success)
748748
{
@@ -1015,7 +1015,7 @@ namespace SPTAG::SPANN {
10151015
bool listContains = false;
10161016
{
10171017
std::shared_lock<std::shared_timed_mutex> anotherLock(m_mergeListLock);
1018-
listContains = m_mergeList.contains(queryResult->VID);
1018+
listContains = (m_mergeList.find(queryResult->VID) != m_mergeList.end());
10191019
}
10201020
if (currentLength + nextLength < m_postingSizeLimit && !listContains)
10211021
{

0 commit comments

Comments
 (0)