summaryrefslogtreecommitdiff
path: root/db/write_batch_test.cc
diff options
context:
space:
mode:
authorYu Zhang <yuzhangyu@fb.com>2024-03-21 10:00:15 -0700
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>2024-03-21 10:00:15 -0700
commit13e1c32a187832936814bedc63b56e9944ba8a8e (patch)
tree631d78bf59aed1411daea47c38464bbdd22782b7 /db/write_batch_test.cc
parent6a1c2abe9dc13396786cf8930d0f6e4697addab7 (diff)
Follow ups for TimedPut and write time property (#12455)
Summary: This PR contains a few follow ups from https://github.com/facebook/rocksdb/issues/12419 and https://github.com/facebook/rocksdb/issues/12428 including: 1) Handle a special case for `WriteBatch::TimedPut`. When the user specified write time is `std::numeric_limits<uint64_t>::max()`, it's not treated as an error, but it instead creates and writes a regular `Put` entry. 2) Update the `InternalIterator::write_unix_time` APIs to handle `kTypeValuePreferredSeqno` entries. 3) FlushJob is updated to use the seqno to time mapping copy in `SuperVersion`. FlushJob currently copy the DB's seqno to time mapping while holding db mutex and only copies the part of interest, a.k.a, the part that only goes back to the earliest sequence number of the to-be-flushed memtables. While updating FlushJob to use the mapping copy in `SuperVersion`, it's given access to the full mapping to help cover the need to convert `kTypeValuePreferredSeqno`'s write time to preferred seqno as much as possible. Test plans: Added unit tests Pull Request resolved: https://github.com/facebook/rocksdb/pull/12455 Reviewed By: pdillinger Differential Revision: D55165422 Pulled By: jowlyzhang fbshipit-source-id: dc022653077f678c24661de5743146a74cce4b47
Diffstat (limited to 'db/write_batch_test.cc')
-rw-r--r--db/write_batch_test.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/db/write_batch_test.cc b/db/write_batch_test.cc
index 3fe84927a..05aec899a 100644
--- a/db/write_batch_test.cc
+++ b/db/write_batch_test.cc
@@ -406,12 +406,19 @@ TEST_F(WriteBatchTest, PutNotImplemented) {
TEST_F(WriteBatchTest, TimedPutNotImplemented) {
WriteBatch batch;
ASSERT_OK(
- batch.TimedPut(0, Slice("k1"), Slice("v1"), /*unix_write_time=*/30));
+ batch.TimedPut(0, Slice("k1"), Slice("v1"), /*write_unix_time=*/30));
ASSERT_EQ(1u, batch.Count());
ASSERT_EQ("TimedPut(k1, v1, 30)@0", PrintContents(&batch));
WriteBatch::Handler handler;
ASSERT_TRUE(batch.Iterate(&handler).IsInvalidArgument());
+
+ batch.Clear();
+ ASSERT_OK(
+ batch.TimedPut(0, Slice("k1"), Slice("v1"),
+ /*write_unix_time=*/std::numeric_limits<uint64_t>::max()));
+ ASSERT_EQ(1u, batch.Count());
+ ASSERT_EQ("Put(k1, v1)@0", PrintContents(&batch));
}
TEST_F(WriteBatchTest, DeleteNotImplemented) {