Skip to content

Commit accaaf0

Browse files
committed
Fix test
1 parent fea7fcf commit accaaf0

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/types/redis_bitmap.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,19 @@ rocksdb::Status Bitmap::BitOp(engine::Context &ctx, BitOpFlags op_flag, const st
747747
} else {
748748
frag_maxlen = kBitmapSegmentBytes;
749749
}
750+
} else if (op_flag == kBitOpDiff || op_flag == kBitOpDiff1 || op_flag == kBitOpAndOr ||
751+
op_flag == kBitOpOne) {
752+
// For DIFF, DIFF1, ANDOR, and ONE operations, we need to ensure
753+
// frag_maxlen is correctly set for the last segment
754+
if (frag_index == stop_index) {
755+
if (max_bitmap_size == (frag_index + 1) * kBitmapSegmentBytes) {
756+
frag_maxlen = kBitmapSegmentBytes;
757+
} else {
758+
frag_maxlen = max_bitmap_size % kBitmapSegmentBytes;
759+
}
760+
} else {
761+
frag_maxlen = kBitmapSegmentBytes;
762+
}
750763
}
751764
std::string sub_key = InternalKey(ns_key, std::to_string(frag_index * kBitmapSegmentBytes),
752765
res_metadata.version, storage_->IsSlotIdEncoded())

0 commit comments

Comments
 (0)