Rahul Patwari
05/15/2023, 1:09 PMMayank
Rahul Patwari
05/15/2023, 2:35 PMMayank
Navina
05/15/2023, 6:30 PMNavina
05/15/2023, 6:31 PMNavina
05/15/2023, 6:32 PMRahul Patwari
05/16/2023, 4:31 AMRahul Patwari
05/16/2023, 7:07 AMNavina
05/16/2023, 3:10 PMRahul Patwari
05/17/2023, 1:47 AMprotected void removeSegment(IndexSegment segment, MutableRoaringBitmap validDocIds) {
assert !validDocIds.isEmpty();
PrimaryKey primaryKey = new PrimaryKey(new Object[_primaryKeyColumns.size()]);
PeekableIntIterator iterator = validDocIds.getIntIterator();
try (
UpsertUtils.PrimaryKeyReader primaryKeyReader = new UpsertUtils.PrimaryKeyReader(segment, _primaryKeyColumns)) {
while (iterator.hasNext()) {
primaryKeyReader.getPrimaryKey(iterator.next(), primaryKey);
_primaryKeyToRecordLocationMap.computeIfPresent(HashUtils.hashPrimaryKey(primaryKey, _hashFunction),
(pk, recordLocation) -> {
if (recordLocation.getSegment() == segment) {
return null;
}
return recordLocation;
});
}
}
}
CMIIW. In this code, I think the primary key entry is removed if the latest value for that primary key is in the segment that is being removed. I have tested that ConcurrentHashMap.computeIfPresent() removes the key when null is returned in the BiFunction.
removeSegment() method is called when the segment is expired, right. I am not sure if all the codepaths call this method when a segment is removed.Rahul Patwari
05/23/2023, 1:50 PMRahul Patwari
05/23/2023, 1:56 PMNavina
05/23/2023, 2:39 PMJackie
05/23/2023, 4:35 PMcomputeIfPresent() returns null in the lambda, it is equivalent to calling remove(). We don't directly call remove() to avoid race condition: if we skip the reference check of the segment, it will remove the wrong entry if the PK is just updated to point to a new locationRahul Patwari
05/23/2023, 4:38 PMJackie
05/23/2023, 5:11 PMConcurrentHashMap that can shrink its size, so probably the only way is to re-construct a new mapJackie
05/23/2023, 5:12 PM