From 82aab9e2f0b562e1867c698fbbe531478da2250c Mon Sep 17 00:00:00 2001 From: "Xiaotian (Jackie) Jiang" Date: Wed, 1 Dec 2021 12:59:16 -0800 Subject: [PATCH] Replace assert with Objects.requireNonNull() --- .../upsert/PartitionUpsertMetadataManager.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/PartitionUpsertMetadataManager.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/PartitionUpsertMetadataManager.java index 7cd3f62eaebb..351d36a9182b 100644 --- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/PartitionUpsertMetadataManager.java +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/PartitionUpsertMetadataManager.java @@ -20,6 +20,7 @@ import com.google.common.annotations.VisibleForTesting; import java.util.Iterator; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; @@ -96,9 +97,8 @@ public PartitionUpsertMetadataManager(String tableNameWithType, int partitionId, public void addSegment(IndexSegment segment, Iterator recordInfoIterator) { String segmentName = segment.getSegmentName(); LOGGER.info("Adding upsert metadata for segment: {}", segmentName); - ThreadSafeMutableRoaringBitmap validDocIds = segment.getValidDocIds(); - assert validDocIds != null; + ThreadSafeMutableRoaringBitmap validDocIds = Objects.requireNonNull(segment.getValidDocIds()); while (recordInfoIterator.hasNext()) { RecordInfo recordInfo = recordInfoIterator.next(); _primaryKeyToRecordLocationMap.compute(hashPrimaryKey(recordInfo._primaryKey, _hashFunction), @@ -144,8 +144,7 @@ public void addSegment(IndexSegment segment, Iterator recordInfoIter && LLCSegmentName.isLowLevelConsumerSegmentName(currentSegmentName) && LLCSegmentName.getSequenceNumber(segmentName) > LLCSegmentName.getSequenceNumber( currentSegmentName))) { - assert currentSegment.getValidDocIds() != null; - currentSegment.getValidDocIds().remove(currentRecordLocation.getDocId()); + Objects.requireNonNull(currentSegment.getValidDocIds()).remove(currentRecordLocation.getDocId()); validDocIds.add(recordInfo._docId); return new RecordLocation(segment, recordInfo._docId, recordInfo._comparisonValue); } else { @@ -182,8 +181,7 @@ public GenericRow updateRecord(IndexSegment segment, RecordInfo recordInfo, Gene } } - ThreadSafeMutableRoaringBitmap validDocIds = segment.getValidDocIds(); - assert validDocIds != null; + ThreadSafeMutableRoaringBitmap validDocIds = Objects.requireNonNull(segment.getValidDocIds()); _result = record; _primaryKeyToRecordLocationMap.compute(hashPrimaryKey(recordInfo._primaryKey, _hashFunction), (primaryKey, currentRecordLocation) -> { @@ -204,8 +202,7 @@ public GenericRow updateRecord(IndexSegment segment, RecordInfo recordInfo, Gene if (segment == currentSegment) { validDocIds.replace(currentDocId, recordInfo._docId); } else { - assert currentSegment.getValidDocIds() != null; - currentSegment.getValidDocIds().remove(currentDocId); + Objects.requireNonNull(currentSegment.getValidDocIds()).remove(currentDocId); validDocIds.add(recordInfo._docId); } return new RecordLocation(segment, recordInfo._docId, recordInfo._comparisonValue); @@ -238,8 +235,7 @@ public void removeSegment(IndexSegment segment) { String segmentName = segment.getSegmentName(); LOGGER.info("Removing upsert metadata for segment: {}", segmentName); - assert segment.getValidDocIds() != null; - if (!segment.getValidDocIds().getMutableRoaringBitmap().isEmpty()) { + if (!Objects.requireNonNull(segment.getValidDocIds()).getMutableRoaringBitmap().isEmpty()) { // Remove all the record locations that point to the removed segment _primaryKeyToRecordLocationMap.forEach((primaryKey, recordLocation) -> { if (recordLocation.getSegment() == segment) {