rocksdb/util
Yu Zhang 0435a9fc31 Add timestamp support in dump_wal/dump/idump (#12690)
Summary:
As titled.  For dumping wal files, since a mapping from column family id to the user comparator object is needed to print the timestamp in human readable format, option `[--db=<db_path>]` is added to `dump_wal` command to allow the user to choose to optionally open the DB as read only instance and dump the wal file with better timestamp formatting.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/12690

Test Plan:
Manually tested

dump_wal:
[dump a wal file specified with --walfile]
```
>> ./ldb --walfile=$TEST_DB/000004.log dump_wal  --print_value
>>1,1,28,13,PUT(0) : 0x666F6F0100000000000000 : 0x7631
(Column family id: [0] contained in WAL are not opened in DB. Applied default hex formatting for user key. Specify --db=<db_path> to open DB for better user key formatting if it contains timestamp.)
```

[dump with --db specified for better timestamp formatting]
```
>> ./ldb --walfile=$TEST_DB/000004.log dump_wal  --db=$TEST_DB --print_value
>> 1,1,28,13,PUT(0) : 0x666F6F|timestamp:1 : 0x7631
```

dump:
[dump a file specified with --path]
```
>>./ldb --path=/tmp/rocksdbtest-501/column_family_test_75359_17910784957761284041/000004.log dump
Sequence,Count,ByteSize,Physical Offset,Key(s) : value
1,1,28,13,PUT(0) : 0x666F6F0100000000000000 : 0x7631
(Column family id: [0] contained in WAL are not opened in DB. Applied default hex formatting for user key. Specify --db=<db_path> to open DB for better user key formatting if it contains timestamp.)
```

[dump db specified with --db]
```
>> ./ldb --db=/tmp/rocksdbtest-501/column_family_test_75359_17910784957761284041 dump
>> foo|timestamp:1 ==> v1
Keys in range: 1
```

idump
```
./ldb --db=$TEST_DB idump
'foo|timestamp:1' seq:1, type:1 => v1
Internal keys in range: 1
```

Reviewed By: ltamasi

Differential Revision: D57755382

Pulled By: jowlyzhang

fbshipit-source-id: a0a2ef80c92801cbf7bfccc64769c1191824362e
2024-08-07 11:33:00 -07:00
..
aligned_buffer.h
async_file_reader.cc
async_file_reader.h
atomic.h
autovector.h
autovector_test.cc
bloom_impl.h
bloom_test.cc
build_version.cc.in
cast_util.h
channel.h
cleanable.cc
coding.cc
coding.h
coding_lean.h
coding_test.cc
compaction_job_stats_impl.cc
comparator.cc
compression.cc
compression.h
compression_context_cache.cc
compression_context_cache.h
concurrent_task_limiter_impl.cc
concurrent_task_limiter_impl.h
core_local.h
coro_utils.h
crc32c.cc
crc32c.h
crc32c_arm64.cc
crc32c_arm64.h
crc32c_ppc.c
crc32c_ppc.h
crc32c_ppc_asm.S
crc32c_ppc_constants.h
crc32c_test.cc
data_structure.cc
defer.h
defer_test.cc
distributed_mutex.h
duplicate_detector.h
dynamic_bloom.cc
dynamic_bloom.h
dynamic_bloom_test.cc
fastrange.h
file_checksum_helper.cc
file_checksum_helper.h
file_reader_writer_test.cc
filelock_test.cc
filter_bench.cc
gflags_compat.h
hash.cc
hash.h
hash128.h
hash_containers.h
hash_map.h
hash_test.cc
heap.h
heap_test.cc
kv_map.h
log_write_bench.cc
math.h
math128.h
murmurhash.cc
murmurhash.h
mutexlock.h
overload.h
ppc-opcode.h
random.cc
random.h
random_test.cc
rate_limiter.cc
rate_limiter_impl.h
rate_limiter_test.cc
repeatable_thread.h
repeatable_thread_test.cc
ribbon_alg.h
ribbon_config.cc
ribbon_config.h
ribbon_impl.h
ribbon_test.cc
set_comparator.h
single_thread_executor.h
slice.cc
slice_test.cc
slice_transform_test.cc
status.cc
stderr_logger.cc
stderr_logger.h
stop_watch.h
string_util.cc
string_util.h
string_util_test.cc
thread_guard.h
thread_list_test.cc
thread_local.cc
thread_local.h
thread_local_test.cc
thread_operation.h
threadpool_imp.cc
threadpool_imp.h
timer.h
timer_queue.h
timer_queue_test.cc
timer_test.cc
udt_util.cc
udt_util.h
udt_util_test.cc
user_comparator_wrapper.h
vector_iterator.h
work_queue.h
work_queue_test.cc
write_batch_util.cc
write_batch_util.h
xxhash.cc
xxhash.h
xxph3.h